babylon.module.d.ts 5.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3262. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3263. * @param from defines the vector to align
  3264. * @param to defines the vector to align to
  3265. * @param result defines the target matrix
  3266. */
  3267. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3268. /**
  3269. * Creates a rotation matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @returns the new rotation matrix
  3274. */
  3275. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3276. /**
  3277. * Creates a rotation matrix and stores it in a given matrix
  3278. * @param yaw defines the yaw angle in radians (Y axis)
  3279. * @param pitch defines the pitch angle in radians (X axis)
  3280. * @param roll defines the roll angle in radians (X axis)
  3281. * @param result defines the target matrix
  3282. */
  3283. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3284. /**
  3285. * Creates a scaling matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @returns the new matrix
  3290. */
  3291. static Scaling(x: number, y: number, z: number): Matrix;
  3292. /**
  3293. * Creates a scaling matrix and stores it in a given matrix
  3294. * @param x defines the scale factor on X axis
  3295. * @param y defines the scale factor on Y axis
  3296. * @param z defines the scale factor on Z axis
  3297. * @param result defines the target matrix
  3298. */
  3299. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3300. /**
  3301. * Creates a translation matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @returns the new matrix
  3306. */
  3307. static Translation(x: number, y: number, z: number): Matrix;
  3308. /**
  3309. * Creates a translation matrix and stores it in a given matrix
  3310. * @param x defines the translation on X axis
  3311. * @param y defines the translation on Y axis
  3312. * @param z defines the translationon Z axis
  3313. * @param result defines the target matrix
  3314. */
  3315. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3316. /**
  3317. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @returns the new matrix
  3322. */
  3323. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3324. /**
  3325. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3326. * @param startValue defines the start value
  3327. * @param endValue defines the end value
  3328. * @param gradient defines the gradient factor
  3329. * @param result defines the Matrix object where to store data
  3330. */
  3331. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3332. /**
  3333. * Builds a new matrix whose values are computed by:
  3334. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3335. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3336. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3337. * @param startValue defines the first matrix
  3338. * @param endValue defines the second matrix
  3339. * @param gradient defines the gradient between the two matrices
  3340. * @returns the new matrix
  3341. */
  3342. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3343. /**
  3344. * Update a matrix to values which are computed by:
  3345. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3346. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3347. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3348. * @param startValue defines the first matrix
  3349. * @param endValue defines the second matrix
  3350. * @param gradient defines the gradient between the two matrices
  3351. * @param result defines the target matrix
  3352. */
  3353. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3354. /**
  3355. * 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"
  3356. * This function works in left handed mode
  3357. * @param eye defines the final position of the entity
  3358. * @param target defines where the entity should look at
  3359. * @param up defines the up vector for the entity
  3360. * @returns the new matrix
  3361. */
  3362. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3363. /**
  3364. * 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".
  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. * @param result defines the target matrix
  3370. */
  3371. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3372. /**
  3373. * 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"
  3374. * This function works in right 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. * @returns the new matrix
  3379. */
  3380. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3381. /**
  3382. * 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".
  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. * @param result defines the target matrix
  3388. */
  3389. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3390. /**
  3391. * Create a left-handed orthographic projection matrix
  3392. * @param width defines the viewport width
  3393. * @param height defines the viewport height
  3394. * @param znear defines the near clip plane
  3395. * @param zfar defines the far clip plane
  3396. * @returns a new matrix as a left-handed orthographic projection matrix
  3397. */
  3398. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3399. /**
  3400. * Store a left-handed orthographic projection to a given 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. * @param result defines the target matrix
  3406. */
  3407. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3408. /**
  3409. * Create a left-handed orthographic projection matrix
  3410. * @param left defines the viewport left coordinate
  3411. * @param right defines the viewport right coordinate
  3412. * @param bottom defines the viewport bottom coordinate
  3413. * @param top defines the viewport top coordinate
  3414. * @param znear defines the near clip plane
  3415. * @param zfar defines the far clip plane
  3416. * @returns a new matrix as a left-handed orthographic projection matrix
  3417. */
  3418. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3419. /**
  3420. * Stores a left-handed orthographic projection into a given matrix
  3421. * @param left defines the viewport left coordinate
  3422. * @param right defines the viewport right coordinate
  3423. * @param bottom defines the viewport bottom coordinate
  3424. * @param top defines the viewport top coordinate
  3425. * @param znear defines the near clip plane
  3426. * @param zfar defines the far clip plane
  3427. * @param result defines the target matrix
  3428. */
  3429. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3430. /**
  3431. * Creates a right-handed orthographic projection matrix
  3432. * @param left defines the viewport left coordinate
  3433. * @param right defines the viewport right coordinate
  3434. * @param bottom defines the viewport bottom coordinate
  3435. * @param top defines the viewport top coordinate
  3436. * @param znear defines the near clip plane
  3437. * @param zfar defines the far clip plane
  3438. * @returns a new matrix as a right-handed orthographic projection matrix
  3439. */
  3440. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3441. /**
  3442. * Stores a right-handed orthographic projection into a given matrix
  3443. * @param left defines the viewport left coordinate
  3444. * @param right defines the viewport right coordinate
  3445. * @param bottom defines the viewport bottom coordinate
  3446. * @param top defines the viewport top coordinate
  3447. * @param znear defines the near clip plane
  3448. * @param zfar defines the far clip plane
  3449. * @param result defines the target matrix
  3450. */
  3451. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3452. /**
  3453. * Creates a left-handed perspective projection matrix
  3454. * @param width defines the viewport width
  3455. * @param height defines the viewport height
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @returns a new matrix as a left-handed perspective projection matrix
  3459. */
  3460. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3461. /**
  3462. * Creates a left-handed perspective projection matrix
  3463. * @param fov defines the horizontal field of view
  3464. * @param aspect defines the aspect ratio
  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 PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3470. /**
  3471. * Stores a left-handed perspective projection into a given 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. * @param result defines the target matrix
  3477. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3478. */
  3479. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3480. /**
  3481. * Creates a right-handed perspective projection matrix
  3482. * @param fov defines the horizontal field of view
  3483. * @param aspect defines the aspect ratio
  3484. * @param znear defines the near clip plane
  3485. * @param zfar defines the far clip plane
  3486. * @returns a new matrix as a right-handed perspective projection matrix
  3487. */
  3488. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3489. /**
  3490. * Stores a right-handed perspective projection into a given 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. * @param result defines the target matrix
  3496. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3497. */
  3498. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3499. /**
  3500. * Stores a perspective projection for WebVR info a given matrix
  3501. * @param fov defines the field of view
  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 rightHanded defines if the matrix must be in right-handed mode (false by default)
  3506. */
  3507. static PerspectiveFovWebVRToRef(fov: {
  3508. upDegrees: number;
  3509. downDegrees: number;
  3510. leftDegrees: number;
  3511. rightDegrees: number;
  3512. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3513. /**
  3514. * Computes a complete transformation matrix
  3515. * @param viewport defines the viewport to use
  3516. * @param world defines the world matrix
  3517. * @param view defines the view matrix
  3518. * @param projection defines the projection matrix
  3519. * @param zmin defines the near clip plane
  3520. * @param zmax defines the far clip plane
  3521. * @returns the transformation matrix
  3522. */
  3523. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3524. /**
  3525. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3526. * @param matrix defines the matrix to use
  3527. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3528. */
  3529. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3530. /**
  3531. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3532. * @param matrix defines the matrix to use
  3533. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3534. */
  3535. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3536. /**
  3537. * Compute the transpose of a given matrix
  3538. * @param matrix defines the matrix to transpose
  3539. * @returns the new matrix
  3540. */
  3541. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3542. /**
  3543. * Compute the transpose of a matrix and store it in a target matrix
  3544. * @param matrix defines the matrix to transpose
  3545. * @param result defines the target matrix
  3546. */
  3547. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3548. /**
  3549. * Computes a reflection matrix from a plane
  3550. * @param plane defines the reflection plane
  3551. * @returns a new matrix
  3552. */
  3553. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3554. /**
  3555. * Computes a reflection matrix from a plane
  3556. * @param plane defines the reflection plane
  3557. * @param result defines the target matrix
  3558. */
  3559. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3560. /**
  3561. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3562. * @param xaxis defines the value of the 1st axis
  3563. * @param yaxis defines the value of the 2nd axis
  3564. * @param zaxis defines the value of the 3rd axis
  3565. * @param result defines the target matrix
  3566. */
  3567. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3568. /**
  3569. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3570. * @param quat defines the quaternion to use
  3571. * @param result defines the target matrix
  3572. */
  3573. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3574. }
  3575. /**
  3576. * Represens a plane by the equation ax + by + cz + d = 0
  3577. */
  3578. export class Plane {
  3579. /**
  3580. * Normal of the plane (a,b,c)
  3581. */
  3582. normal: Vector3;
  3583. /**
  3584. * d component of the plane
  3585. */
  3586. d: number;
  3587. /**
  3588. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3589. * @param a a component of the plane
  3590. * @param b b component of the plane
  3591. * @param c c component of the plane
  3592. * @param d d component of the plane
  3593. */
  3594. constructor(a: number, b: number, c: number, d: number);
  3595. /**
  3596. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3597. */
  3598. asArray(): number[];
  3599. /**
  3600. * @returns a new plane copied from the current Plane.
  3601. */
  3602. clone(): Plane;
  3603. /**
  3604. * @returns the string "Plane".
  3605. */
  3606. getClassName(): string;
  3607. /**
  3608. * @returns the Plane hash code.
  3609. */
  3610. getHashCode(): number;
  3611. /**
  3612. * Normalize the current Plane in place.
  3613. * @returns the updated Plane.
  3614. */
  3615. normalize(): Plane;
  3616. /**
  3617. * Applies a transformation the plane and returns the result
  3618. * @param transformation the transformation matrix to be applied to the plane
  3619. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3620. */
  3621. transform(transformation: DeepImmutable<Matrix>): Plane;
  3622. /**
  3623. * Calcualtte the dot product between the point and the plane normal
  3624. * @param point point to calculate the dot product with
  3625. * @returns the dot product (float) of the point coordinates and the plane normal.
  3626. */
  3627. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3628. /**
  3629. * Updates the current Plane from the plane defined by the three given points.
  3630. * @param point1 one of the points used to contruct the plane
  3631. * @param point2 one of the points used to contruct the plane
  3632. * @param point3 one of the points used to contruct the plane
  3633. * @returns the updated Plane.
  3634. */
  3635. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3636. /**
  3637. * Checks if the plane is facing a given direction
  3638. * @param direction the direction to check if the plane is facing
  3639. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3640. * @returns True is the vector "direction" is the same side than the plane normal.
  3641. */
  3642. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3643. /**
  3644. * Calculates the distance to a point
  3645. * @param point point to calculate distance to
  3646. * @returns the signed distance (float) from the given point to the Plane.
  3647. */
  3648. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3649. /**
  3650. * Creates a plane from an array
  3651. * @param array the array to create a plane from
  3652. * @returns a new Plane from the given array.
  3653. */
  3654. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3655. /**
  3656. * Creates a plane from three points
  3657. * @param point1 point used to create the plane
  3658. * @param point2 point used to create the plane
  3659. * @param point3 point used to create the plane
  3660. * @returns a new Plane defined by the three given points.
  3661. */
  3662. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Creates a plane from an origin point and a normal
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @returns a new Plane the normal vector to this plane at the given origin point.
  3668. * Note : the vector "normal" is updated because normalized.
  3669. */
  3670. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3671. /**
  3672. * Calculates the distance from a plane and a point
  3673. * @param origin origin of the plane to be constructed
  3674. * @param normal normal of the plane to be constructed
  3675. * @param point point to calculate distance to
  3676. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3677. */
  3678. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3679. }
  3680. /**
  3681. * Class used to represent a viewport on screen
  3682. */
  3683. export class Viewport {
  3684. /** viewport left coordinate */
  3685. x: number;
  3686. /** viewport top coordinate */
  3687. y: number;
  3688. /**viewport width */
  3689. width: number;
  3690. /** viewport height */
  3691. height: number;
  3692. /**
  3693. * Creates a Viewport object located at (x, y) and sized (width, height)
  3694. * @param x defines viewport left coordinate
  3695. * @param y defines viewport top coordinate
  3696. * @param width defines the viewport width
  3697. * @param height defines the viewport height
  3698. */
  3699. constructor(
  3700. /** viewport left coordinate */
  3701. x: number,
  3702. /** viewport top coordinate */
  3703. y: number,
  3704. /**viewport width */
  3705. width: number,
  3706. /** viewport height */
  3707. height: number);
  3708. /**
  3709. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3710. * @param renderWidth defines the rendering width
  3711. * @param renderHeight defines the rendering height
  3712. * @returns a new Viewport
  3713. */
  3714. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3715. /**
  3716. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3717. * @param renderWidth defines the rendering width
  3718. * @param renderHeight defines the rendering height
  3719. * @param ref defines the target viewport
  3720. * @returns the current viewport
  3721. */
  3722. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3723. /**
  3724. * Returns a new Viewport copied from the current one
  3725. * @returns a new Viewport
  3726. */
  3727. clone(): Viewport;
  3728. }
  3729. /**
  3730. * Reprasents a camera frustum
  3731. */
  3732. export class Frustum {
  3733. /**
  3734. * Gets the planes representing the frustum
  3735. * @param transform matrix to be applied to the returned planes
  3736. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3737. */
  3738. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3739. /**
  3740. * Gets the near frustum plane transformed by the transform matrix
  3741. * @param transform transformation matrix to be applied to the resulting frustum plane
  3742. * @param frustumPlane the resuling frustum plane
  3743. */
  3744. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3745. /**
  3746. * Gets the far frustum plane transformed by the transform matrix
  3747. * @param transform transformation matrix to be applied to the resulting frustum plane
  3748. * @param frustumPlane the resuling frustum plane
  3749. */
  3750. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3751. /**
  3752. * Gets the left frustum plane transformed by the transform matrix
  3753. * @param transform transformation matrix to be applied to the resulting frustum plane
  3754. * @param frustumPlane the resuling frustum plane
  3755. */
  3756. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3757. /**
  3758. * Gets the right frustum plane transformed by the transform matrix
  3759. * @param transform transformation matrix to be applied to the resulting frustum plane
  3760. * @param frustumPlane the resuling frustum plane
  3761. */
  3762. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3763. /**
  3764. * Gets the top frustum plane transformed by the transform matrix
  3765. * @param transform transformation matrix to be applied to the resulting frustum plane
  3766. * @param frustumPlane the resuling frustum plane
  3767. */
  3768. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3769. /**
  3770. * Gets the bottom frustum plane transformed by the transform matrix
  3771. * @param transform transformation matrix to be applied to the resulting frustum plane
  3772. * @param frustumPlane the resuling frustum plane
  3773. */
  3774. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3775. /**
  3776. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3777. * @param transform transformation matrix to be applied to the resulting frustum planes
  3778. * @param frustumPlanes the resuling frustum planes
  3779. */
  3780. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3781. }
  3782. /** Defines supported spaces */
  3783. export enum Space {
  3784. /** Local (object) space */
  3785. LOCAL = 0,
  3786. /** World space */
  3787. WORLD = 1,
  3788. /** Bone space */
  3789. BONE = 2
  3790. }
  3791. /** Defines the 3 main axes */
  3792. export class Axis {
  3793. /** X axis */
  3794. static X: Vector3;
  3795. /** Y axis */
  3796. static Y: Vector3;
  3797. /** Z axis */
  3798. static Z: Vector3;
  3799. }
  3800. /** Class used to represent a Bezier curve */
  3801. export class BezierCurve {
  3802. /**
  3803. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3804. * @param t defines the time
  3805. * @param x1 defines the left coordinate on X axis
  3806. * @param y1 defines the left coordinate on Y axis
  3807. * @param x2 defines the right coordinate on X axis
  3808. * @param y2 defines the right coordinate on Y axis
  3809. * @returns the interpolated value
  3810. */
  3811. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3812. }
  3813. /**
  3814. * Defines potential orientation for back face culling
  3815. */
  3816. export enum Orientation {
  3817. /**
  3818. * Clockwise
  3819. */
  3820. CW = 0,
  3821. /** Counter clockwise */
  3822. CCW = 1
  3823. }
  3824. /**
  3825. * Defines angle representation
  3826. */
  3827. export class Angle {
  3828. private _radians;
  3829. /**
  3830. * Creates an Angle object of "radians" radians (float).
  3831. * @param radians the angle in radians
  3832. */
  3833. constructor(radians: number);
  3834. /**
  3835. * Get value in degrees
  3836. * @returns the Angle value in degrees (float)
  3837. */
  3838. degrees(): number;
  3839. /**
  3840. * Get value in radians
  3841. * @returns the Angle value in radians (float)
  3842. */
  3843. radians(): number;
  3844. /**
  3845. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3846. * @param a defines first vector
  3847. * @param b defines second vector
  3848. * @returns a new Angle
  3849. */
  3850. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3851. /**
  3852. * Gets a new Angle object from the given float in radians
  3853. * @param radians defines the angle value in radians
  3854. * @returns a new Angle
  3855. */
  3856. static FromRadians(radians: number): Angle;
  3857. /**
  3858. * Gets a new Angle object from the given float in degrees
  3859. * @param degrees defines the angle value in degrees
  3860. * @returns a new Angle
  3861. */
  3862. static FromDegrees(degrees: number): Angle;
  3863. }
  3864. /**
  3865. * This represents an arc in a 2d space.
  3866. */
  3867. export class Arc2 {
  3868. /** Defines the start point of the arc */
  3869. startPoint: Vector2;
  3870. /** Defines the mid point of the arc */
  3871. midPoint: Vector2;
  3872. /** Defines the end point of the arc */
  3873. endPoint: Vector2;
  3874. /**
  3875. * Defines the center point of the arc.
  3876. */
  3877. centerPoint: Vector2;
  3878. /**
  3879. * Defines the radius of the arc.
  3880. */
  3881. radius: number;
  3882. /**
  3883. * Defines the angle of the arc (from mid point to end point).
  3884. */
  3885. angle: Angle;
  3886. /**
  3887. * Defines the start angle of the arc (from start point to middle point).
  3888. */
  3889. startAngle: Angle;
  3890. /**
  3891. * Defines the orientation of the arc (clock wise/counter clock wise).
  3892. */
  3893. orientation: Orientation;
  3894. /**
  3895. * Creates an Arc object from the three given points : start, middle and end.
  3896. * @param startPoint Defines the start point of the arc
  3897. * @param midPoint Defines the midlle point of the arc
  3898. * @param endPoint Defines the end point of the arc
  3899. */
  3900. constructor(
  3901. /** Defines the start point of the arc */
  3902. startPoint: Vector2,
  3903. /** Defines the mid point of the arc */
  3904. midPoint: Vector2,
  3905. /** Defines the end point of the arc */
  3906. endPoint: Vector2);
  3907. }
  3908. /**
  3909. * Represents a 2D path made up of multiple 2D points
  3910. */
  3911. export class Path2 {
  3912. private _points;
  3913. private _length;
  3914. /**
  3915. * If the path start and end point are the same
  3916. */
  3917. closed: boolean;
  3918. /**
  3919. * Creates a Path2 object from the starting 2D coordinates x and y.
  3920. * @param x the starting points x value
  3921. * @param y the starting points y value
  3922. */
  3923. constructor(x: number, y: number);
  3924. /**
  3925. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3926. * @param x the added points x value
  3927. * @param y the added points y value
  3928. * @returns the updated Path2.
  3929. */
  3930. addLineTo(x: number, y: number): Path2;
  3931. /**
  3932. * 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.
  3933. * @param midX middle point x value
  3934. * @param midY middle point y value
  3935. * @param endX end point x value
  3936. * @param endY end point y value
  3937. * @param numberOfSegments (default: 36)
  3938. * @returns the updated Path2.
  3939. */
  3940. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3941. /**
  3942. * Closes the Path2.
  3943. * @returns the Path2.
  3944. */
  3945. close(): Path2;
  3946. /**
  3947. * Gets the sum of the distance between each sequential point in the path
  3948. * @returns the Path2 total length (float).
  3949. */
  3950. length(): number;
  3951. /**
  3952. * Gets the points which construct the path
  3953. * @returns the Path2 internal array of points.
  3954. */
  3955. getPoints(): Vector2[];
  3956. /**
  3957. * Retreives the point at the distance aways from the starting point
  3958. * @param normalizedLengthPosition the length along the path to retreive the point from
  3959. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3960. */
  3961. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3962. /**
  3963. * Creates a new path starting from an x and y position
  3964. * @param x starting x value
  3965. * @param y starting y value
  3966. * @returns a new Path2 starting at the coordinates (x, y).
  3967. */
  3968. static StartingAt(x: number, y: number): Path2;
  3969. }
  3970. /**
  3971. * Represents a 3D path made up of multiple 3D points
  3972. */
  3973. export class Path3D {
  3974. /**
  3975. * an array of Vector3, the curve axis of the Path3D
  3976. */
  3977. path: Vector3[];
  3978. private _curve;
  3979. private _distances;
  3980. private _tangents;
  3981. private _normals;
  3982. private _binormals;
  3983. private _raw;
  3984. /**
  3985. * new Path3D(path, normal, raw)
  3986. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3987. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3988. * @param path an array of Vector3, the curve axis of the Path3D
  3989. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3990. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3991. */
  3992. constructor(
  3993. /**
  3994. * an array of Vector3, the curve axis of the Path3D
  3995. */
  3996. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3997. /**
  3998. * Returns the Path3D array of successive Vector3 designing its curve.
  3999. * @returns the Path3D array of successive Vector3 designing its curve.
  4000. */
  4001. getCurve(): Vector3[];
  4002. /**
  4003. * Returns an array populated with tangent vectors on each Path3D curve point.
  4004. * @returns an array populated with tangent vectors on each Path3D curve point.
  4005. */
  4006. getTangents(): Vector3[];
  4007. /**
  4008. * Returns an array populated with normal vectors on each Path3D curve point.
  4009. * @returns an array populated with normal vectors on each Path3D curve point.
  4010. */
  4011. getNormals(): Vector3[];
  4012. /**
  4013. * Returns an array populated with binormal vectors on each Path3D curve point.
  4014. * @returns an array populated with binormal vectors on each Path3D curve point.
  4015. */
  4016. getBinormals(): Vector3[];
  4017. /**
  4018. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4019. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4020. */
  4021. getDistances(): number[];
  4022. /**
  4023. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4024. * @param path path which all values are copied into the curves points
  4025. * @param firstNormal which should be projected onto the curve
  4026. * @returns the same object updated.
  4027. */
  4028. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4029. private _compute;
  4030. private _getFirstNonNullVector;
  4031. private _getLastNonNullVector;
  4032. private _normalVector;
  4033. }
  4034. /**
  4035. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4036. * A Curve3 is designed from a series of successive Vector3.
  4037. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4038. */
  4039. export class Curve3 {
  4040. private _points;
  4041. private _length;
  4042. /**
  4043. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4044. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4045. * @param v1 (Vector3) the control point
  4046. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4047. * @param nbPoints (integer) the wanted number of points in the curve
  4048. * @returns the created Curve3
  4049. */
  4050. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4051. /**
  4052. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4053. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4054. * @param v1 (Vector3) the first control point
  4055. * @param v2 (Vector3) the second control point
  4056. * @param v3 (Vector3) the end point of the Cubic Bezier
  4057. * @param nbPoints (integer) the wanted number of points in the curve
  4058. * @returns the created Curve3
  4059. */
  4060. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4061. /**
  4062. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4063. * @param p1 (Vector3) the origin point of the Hermite Spline
  4064. * @param t1 (Vector3) the tangent vector at the origin point
  4065. * @param p2 (Vector3) the end point of the Hermite Spline
  4066. * @param t2 (Vector3) the tangent vector at the end point
  4067. * @param nbPoints (integer) the wanted number of points in the curve
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4071. /**
  4072. * Returns a Curve3 object along a CatmullRom Spline curve :
  4073. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4074. * @param nbPoints (integer) the wanted number of points between each curve control points
  4075. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4076. * @returns the created Curve3
  4077. */
  4078. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4079. /**
  4080. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4081. * A Curve3 is designed from a series of successive Vector3.
  4082. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4083. * @param points points which make up the curve
  4084. */
  4085. constructor(points: Vector3[]);
  4086. /**
  4087. * @returns the Curve3 stored array of successive Vector3
  4088. */
  4089. getPoints(): Vector3[];
  4090. /**
  4091. * @returns the computed length (float) of the curve.
  4092. */
  4093. length(): number;
  4094. /**
  4095. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4096. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4097. * curveA and curveB keep unchanged.
  4098. * @param curve the curve to continue from this curve
  4099. * @returns the newly constructed curve
  4100. */
  4101. continue(curve: DeepImmutable<Curve3>): Curve3;
  4102. private _computeLength;
  4103. }
  4104. /**
  4105. * Contains position and normal vectors for a vertex
  4106. */
  4107. export class PositionNormalVertex {
  4108. /** the position of the vertex (defaut: 0,0,0) */
  4109. position: Vector3;
  4110. /** the normal of the vertex (defaut: 0,1,0) */
  4111. normal: Vector3;
  4112. /**
  4113. * Creates a PositionNormalVertex
  4114. * @param position the position of the vertex (defaut: 0,0,0)
  4115. * @param normal the normal of the vertex (defaut: 0,1,0)
  4116. */
  4117. constructor(
  4118. /** the position of the vertex (defaut: 0,0,0) */
  4119. position?: Vector3,
  4120. /** the normal of the vertex (defaut: 0,1,0) */
  4121. normal?: Vector3);
  4122. /**
  4123. * Clones the PositionNormalVertex
  4124. * @returns the cloned PositionNormalVertex
  4125. */
  4126. clone(): PositionNormalVertex;
  4127. }
  4128. /**
  4129. * Contains position, normal and uv vectors for a vertex
  4130. */
  4131. export class PositionNormalTextureVertex {
  4132. /** the position of the vertex (defaut: 0,0,0) */
  4133. position: Vector3;
  4134. /** the normal of the vertex (defaut: 0,1,0) */
  4135. normal: Vector3;
  4136. /** the uv of the vertex (default: 0,0) */
  4137. uv: Vector2;
  4138. /**
  4139. * Creates a PositionNormalTextureVertex
  4140. * @param position the position of the vertex (defaut: 0,0,0)
  4141. * @param normal the normal of the vertex (defaut: 0,1,0)
  4142. * @param uv the uv of the vertex (default: 0,0)
  4143. */
  4144. constructor(
  4145. /** the position of the vertex (defaut: 0,0,0) */
  4146. position?: Vector3,
  4147. /** the normal of the vertex (defaut: 0,1,0) */
  4148. normal?: Vector3,
  4149. /** the uv of the vertex (default: 0,0) */
  4150. uv?: Vector2);
  4151. /**
  4152. * Clones the PositionNormalTextureVertex
  4153. * @returns the cloned PositionNormalTextureVertex
  4154. */
  4155. clone(): PositionNormalTextureVertex;
  4156. }
  4157. /**
  4158. * @hidden
  4159. */
  4160. export class Tmp {
  4161. static Color3: Color3[];
  4162. static Color4: Color4[];
  4163. static Vector2: Vector2[];
  4164. static Vector3: Vector3[];
  4165. static Vector4: Vector4[];
  4166. static Quaternion: Quaternion[];
  4167. static Matrix: Matrix[];
  4168. }
  4169. }
  4170. declare module "babylonjs/Offline/IOfflineProvider" {
  4171. /**
  4172. * Class used to enable access to offline support
  4173. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4174. */
  4175. export interface IOfflineProvider {
  4176. /**
  4177. * Gets a boolean indicating if scene must be saved in the database
  4178. */
  4179. enableSceneOffline: boolean;
  4180. /**
  4181. * Gets a boolean indicating if textures must be saved in the database
  4182. */
  4183. enableTexturesOffline: boolean;
  4184. /**
  4185. * Open the offline support and make it available
  4186. * @param successCallback defines the callback to call on success
  4187. * @param errorCallback defines the callback to call on error
  4188. */
  4189. open(successCallback: () => void, errorCallback: () => void): void;
  4190. /**
  4191. * Loads an image from the offline support
  4192. * @param url defines the url to load from
  4193. * @param image defines the target DOM image
  4194. */
  4195. loadImage(url: string, image: HTMLImageElement): void;
  4196. /**
  4197. * Loads a file from offline support
  4198. * @param url defines the URL to load from
  4199. * @param sceneLoaded defines a callback to call on success
  4200. * @param progressCallBack defines a callback to call when progress changed
  4201. * @param errorCallback defines a callback to call on error
  4202. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4203. */
  4204. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4205. }
  4206. }
  4207. declare module "babylonjs/Misc/observable" {
  4208. import { Nullable } from "babylonjs/types";
  4209. /**
  4210. * A class serves as a medium between the observable and its observers
  4211. */
  4212. export class EventState {
  4213. /**
  4214. * Create a new EventState
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. */
  4220. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4221. /**
  4222. * Initialize the current event state
  4223. * @param mask defines the mask associated with this state
  4224. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4225. * @param target defines the original target of the state
  4226. * @param currentTarget defines the current target of the state
  4227. * @returns the current event state
  4228. */
  4229. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4230. /**
  4231. * An Observer can set this property to true to prevent subsequent observers of being notified
  4232. */
  4233. skipNextObservers: boolean;
  4234. /**
  4235. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4236. */
  4237. mask: number;
  4238. /**
  4239. * The object that originally notified the event
  4240. */
  4241. target?: any;
  4242. /**
  4243. * The current object in the bubbling phase
  4244. */
  4245. currentTarget?: any;
  4246. /**
  4247. * This will be populated with the return value of the last function that was executed.
  4248. * If it is the first function in the callback chain it will be the event data.
  4249. */
  4250. lastReturnValue?: any;
  4251. }
  4252. /**
  4253. * Represent an Observer registered to a given Observable object.
  4254. */
  4255. export class Observer<T> {
  4256. /**
  4257. * Defines the callback to call when the observer is notified
  4258. */
  4259. callback: (eventData: T, eventState: EventState) => void;
  4260. /**
  4261. * Defines the mask of the observer (used to filter notifications)
  4262. */
  4263. mask: number;
  4264. /**
  4265. * Defines the current scope used to restore the JS context
  4266. */
  4267. scope: any;
  4268. /** @hidden */
  4269. _willBeUnregistered: boolean;
  4270. /**
  4271. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4272. */
  4273. unregisterOnNextCall: boolean;
  4274. /**
  4275. * Creates a new observer
  4276. * @param callback defines the callback to call when the observer is notified
  4277. * @param mask defines the mask of the observer (used to filter notifications)
  4278. * @param scope defines the current scope used to restore the JS context
  4279. */
  4280. constructor(
  4281. /**
  4282. * Defines the callback to call when the observer is notified
  4283. */
  4284. callback: (eventData: T, eventState: EventState) => void,
  4285. /**
  4286. * Defines the mask of the observer (used to filter notifications)
  4287. */
  4288. mask: number,
  4289. /**
  4290. * Defines the current scope used to restore the JS context
  4291. */
  4292. scope?: any);
  4293. }
  4294. /**
  4295. * Represent a list of observers registered to multiple Observables object.
  4296. */
  4297. export class MultiObserver<T> {
  4298. private _observers;
  4299. private _observables;
  4300. /**
  4301. * Release associated resources
  4302. */
  4303. dispose(): void;
  4304. /**
  4305. * Raise a callback when one of the observable will notify
  4306. * @param observables defines a list of observables to watch
  4307. * @param callback defines the callback to call on notification
  4308. * @param mask defines the mask used to filter notifications
  4309. * @param scope defines the current scope used to restore the JS context
  4310. * @returns the new MultiObserver
  4311. */
  4312. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4313. }
  4314. /**
  4315. * The Observable class is a simple implementation of the Observable pattern.
  4316. *
  4317. * 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.
  4318. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4319. * 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).
  4320. * 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.
  4321. */
  4322. export class Observable<T> {
  4323. private _observers;
  4324. private _eventState;
  4325. private _onObserverAdded;
  4326. /**
  4327. * Creates a new observable
  4328. * @param onObserverAdded defines a callback to call when a new observer is added
  4329. */
  4330. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4331. /**
  4332. * Create a new Observer with the specified callback
  4333. * @param callback the callback that will be executed for that Observer
  4334. * @param mask the mask used to filter observers
  4335. * @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.
  4336. * @param scope optional scope for the callback to be called from
  4337. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4338. * @returns the new observer created for the callback
  4339. */
  4340. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4341. /**
  4342. * Create a new Observer with the specified callback and unregisters after the next notification
  4343. * @param callback the callback that will be executed for that Observer
  4344. * @returns the new observer created for the callback
  4345. */
  4346. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4347. /**
  4348. * Remove an Observer from the Observable object
  4349. * @param observer the instance of the Observer to remove
  4350. * @returns false if it doesn't belong to this Observable
  4351. */
  4352. remove(observer: Nullable<Observer<T>>): boolean;
  4353. /**
  4354. * Remove a callback from the Observable object
  4355. * @param callback the callback to remove
  4356. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4357. * @returns false if it doesn't belong to this Observable
  4358. */
  4359. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4360. private _deferUnregister;
  4361. private _remove;
  4362. /**
  4363. * Moves the observable to the top of the observer list making it get called first when notified
  4364. * @param observer the observer to move
  4365. */
  4366. makeObserverTopPriority(observer: Observer<T>): void;
  4367. /**
  4368. * Moves the observable to the bottom of the observer list making it get called last when notified
  4369. * @param observer the observer to move
  4370. */
  4371. makeObserverBottomPriority(observer: Observer<T>): void;
  4372. /**
  4373. * Notify all Observers by calling their respective callback with the given data
  4374. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4375. * @param eventData defines the data to send to all observers
  4376. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4377. * @param target defines the original target of the state
  4378. * @param currentTarget defines the current target of the state
  4379. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4380. */
  4381. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4382. /**
  4383. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4384. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4385. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4386. * and it is crucial that all callbacks will be executed.
  4387. * The order of the callbacks is kept, callbacks are not executed parallel.
  4388. *
  4389. * @param eventData The data to be sent to each callback
  4390. * @param mask is used to filter observers defaults to -1
  4391. * @param target defines the callback target (see EventState)
  4392. * @param currentTarget defines he current object in the bubbling phase
  4393. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4394. */
  4395. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4396. /**
  4397. * Notify a specific observer
  4398. * @param observer defines the observer to notify
  4399. * @param eventData defines the data to be sent to each callback
  4400. * @param mask is used to filter observers defaults to -1
  4401. */
  4402. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4403. /**
  4404. * Gets a boolean indicating if the observable has at least one observer
  4405. * @returns true is the Observable has at least one Observer registered
  4406. */
  4407. hasObservers(): boolean;
  4408. /**
  4409. * Clear the list of observers
  4410. */
  4411. clear(): void;
  4412. /**
  4413. * Clone the current observable
  4414. * @returns a new observable
  4415. */
  4416. clone(): Observable<T>;
  4417. /**
  4418. * Does this observable handles observer registered with a given mask
  4419. * @param mask defines the mask to be tested
  4420. * @return whether or not one observer registered with the given mask is handeled
  4421. **/
  4422. hasSpecificMask(mask?: number): boolean;
  4423. }
  4424. }
  4425. declare module "babylonjs/Misc/filesInputStore" {
  4426. /**
  4427. * Class used to help managing file picking and drag'n'drop
  4428. * File Storage
  4429. */
  4430. export class FilesInputStore {
  4431. /**
  4432. * List of files ready to be loaded
  4433. */
  4434. static FilesToLoad: {
  4435. [key: string]: File;
  4436. };
  4437. }
  4438. }
  4439. declare module "babylonjs/Engines/constants" {
  4440. /** Defines the cross module used constants to avoid circular dependncies */
  4441. export class Constants {
  4442. /** Defines that alpha blending is disabled */
  4443. static readonly ALPHA_DISABLE: number;
  4444. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4445. static readonly ALPHA_ADD: number;
  4446. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4447. static readonly ALPHA_COMBINE: number;
  4448. /** Defines that alpha blending to DEST - SRC * DEST */
  4449. static readonly ALPHA_SUBTRACT: number;
  4450. /** Defines that alpha blending to SRC * DEST */
  4451. static readonly ALPHA_MULTIPLY: number;
  4452. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4453. static readonly ALPHA_MAXIMIZED: number;
  4454. /** Defines that alpha blending to SRC + DEST */
  4455. static readonly ALPHA_ONEONE: number;
  4456. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4457. static readonly ALPHA_PREMULTIPLIED: number;
  4458. /**
  4459. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4460. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4461. */
  4462. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4463. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4464. static readonly ALPHA_INTERPOLATE: number;
  4465. /**
  4466. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4467. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4468. */
  4469. static readonly ALPHA_SCREENMODE: number;
  4470. /** Defines that the ressource is not delayed*/
  4471. static readonly DELAYLOADSTATE_NONE: number;
  4472. /** Defines that the ressource was successfully delay loaded */
  4473. static readonly DELAYLOADSTATE_LOADED: number;
  4474. /** Defines that the ressource is currently delay loading */
  4475. static readonly DELAYLOADSTATE_LOADING: number;
  4476. /** Defines that the ressource is delayed and has not started loading */
  4477. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4478. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4479. static readonly NEVER: number;
  4480. /** 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 */
  4481. static readonly ALWAYS: number;
  4482. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4483. static readonly LESS: number;
  4484. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4485. static readonly EQUAL: number;
  4486. /** 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 */
  4487. static readonly LEQUAL: number;
  4488. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4489. static readonly GREATER: number;
  4490. /** 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 */
  4491. static readonly GEQUAL: number;
  4492. /** 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 */
  4493. static readonly NOTEQUAL: number;
  4494. /** Passed to stencilOperation to specify that stencil value must be kept */
  4495. static readonly KEEP: number;
  4496. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4497. static readonly REPLACE: number;
  4498. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4499. static readonly INCR: number;
  4500. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4501. static readonly DECR: number;
  4502. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4503. static readonly INVERT: number;
  4504. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4505. static readonly INCR_WRAP: number;
  4506. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4507. static readonly DECR_WRAP: number;
  4508. /** Texture is not repeating outside of 0..1 UVs */
  4509. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4510. /** Texture is repeating outside of 0..1 UVs */
  4511. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4512. /** Texture is repeating and mirrored */
  4513. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4514. /** ALPHA */
  4515. static readonly TEXTUREFORMAT_ALPHA: number;
  4516. /** LUMINANCE */
  4517. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4518. /** LUMINANCE_ALPHA */
  4519. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4520. /** RGB */
  4521. static readonly TEXTUREFORMAT_RGB: number;
  4522. /** RGBA */
  4523. static readonly TEXTUREFORMAT_RGBA: number;
  4524. /** RED */
  4525. static readonly TEXTUREFORMAT_RED: number;
  4526. /** RED (2nd reference) */
  4527. static readonly TEXTUREFORMAT_R: number;
  4528. /** RG */
  4529. static readonly TEXTUREFORMAT_RG: number;
  4530. /** RED_INTEGER */
  4531. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4532. /** RED_INTEGER (2nd reference) */
  4533. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4534. /** RG_INTEGER */
  4535. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4536. /** RGB_INTEGER */
  4537. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4538. /** RGBA_INTEGER */
  4539. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4540. /** UNSIGNED_BYTE */
  4541. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4542. /** UNSIGNED_BYTE (2nd reference) */
  4543. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4544. /** FLOAT */
  4545. static readonly TEXTURETYPE_FLOAT: number;
  4546. /** HALF_FLOAT */
  4547. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4548. /** BYTE */
  4549. static readonly TEXTURETYPE_BYTE: number;
  4550. /** SHORT */
  4551. static readonly TEXTURETYPE_SHORT: number;
  4552. /** UNSIGNED_SHORT */
  4553. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4554. /** INT */
  4555. static readonly TEXTURETYPE_INT: number;
  4556. /** UNSIGNED_INT */
  4557. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4558. /** UNSIGNED_SHORT_4_4_4_4 */
  4559. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4560. /** UNSIGNED_SHORT_5_5_5_1 */
  4561. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4562. /** UNSIGNED_SHORT_5_6_5 */
  4563. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4564. /** UNSIGNED_INT_2_10_10_10_REV */
  4565. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4566. /** UNSIGNED_INT_24_8 */
  4567. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4568. /** UNSIGNED_INT_10F_11F_11F_REV */
  4569. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4570. /** UNSIGNED_INT_5_9_9_9_REV */
  4571. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4572. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4573. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4574. /** nearest is mag = nearest and min = nearest and mip = linear */
  4575. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4576. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4577. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4578. /** Trilinear is mag = linear and min = linear and mip = linear */
  4579. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4580. /** nearest is mag = nearest and min = nearest and mip = linear */
  4581. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4582. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4583. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4584. /** Trilinear is mag = linear and min = linear and mip = linear */
  4585. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4586. /** mag = nearest and min = nearest and mip = nearest */
  4587. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4588. /** mag = nearest and min = linear and mip = nearest */
  4589. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4590. /** mag = nearest and min = linear and mip = linear */
  4591. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4592. /** mag = nearest and min = linear and mip = none */
  4593. static readonly TEXTURE_NEAREST_LINEAR: number;
  4594. /** mag = nearest and min = nearest and mip = none */
  4595. static readonly TEXTURE_NEAREST_NEAREST: number;
  4596. /** mag = linear and min = nearest and mip = nearest */
  4597. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4598. /** mag = linear and min = nearest and mip = linear */
  4599. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4600. /** mag = linear and min = linear and mip = none */
  4601. static readonly TEXTURE_LINEAR_LINEAR: number;
  4602. /** mag = linear and min = nearest and mip = none */
  4603. static readonly TEXTURE_LINEAR_NEAREST: number;
  4604. /** Explicit coordinates mode */
  4605. static readonly TEXTURE_EXPLICIT_MODE: number;
  4606. /** Spherical coordinates mode */
  4607. static readonly TEXTURE_SPHERICAL_MODE: number;
  4608. /** Planar coordinates mode */
  4609. static readonly TEXTURE_PLANAR_MODE: number;
  4610. /** Cubic coordinates mode */
  4611. static readonly TEXTURE_CUBIC_MODE: number;
  4612. /** Projection coordinates mode */
  4613. static readonly TEXTURE_PROJECTION_MODE: number;
  4614. /** Skybox coordinates mode */
  4615. static readonly TEXTURE_SKYBOX_MODE: number;
  4616. /** Inverse Cubic coordinates mode */
  4617. static readonly TEXTURE_INVCUBIC_MODE: number;
  4618. /** Equirectangular coordinates mode */
  4619. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4620. /** Equirectangular Fixed coordinates mode */
  4621. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4622. /** Equirectangular Fixed Mirrored coordinates mode */
  4623. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4624. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4625. static readonly SCALEMODE_FLOOR: number;
  4626. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4627. static readonly SCALEMODE_NEAREST: number;
  4628. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4629. static readonly SCALEMODE_CEILING: number;
  4630. /**
  4631. * The dirty texture flag value
  4632. */
  4633. static readonly MATERIAL_TextureDirtyFlag: number;
  4634. /**
  4635. * The dirty light flag value
  4636. */
  4637. static readonly MATERIAL_LightDirtyFlag: number;
  4638. /**
  4639. * The dirty fresnel flag value
  4640. */
  4641. static readonly MATERIAL_FresnelDirtyFlag: number;
  4642. /**
  4643. * The dirty attribute flag value
  4644. */
  4645. static readonly MATERIAL_AttributesDirtyFlag: number;
  4646. /**
  4647. * The dirty misc flag value
  4648. */
  4649. static readonly MATERIAL_MiscDirtyFlag: number;
  4650. /**
  4651. * The all dirty flag value
  4652. */
  4653. static readonly MATERIAL_AllDirtyFlag: number;
  4654. /**
  4655. * Returns the triangle fill mode
  4656. */
  4657. static readonly MATERIAL_TriangleFillMode: number;
  4658. /**
  4659. * Returns the wireframe mode
  4660. */
  4661. static readonly MATERIAL_WireFrameFillMode: number;
  4662. /**
  4663. * Returns the point fill mode
  4664. */
  4665. static readonly MATERIAL_PointFillMode: number;
  4666. /**
  4667. * Returns the point list draw mode
  4668. */
  4669. static readonly MATERIAL_PointListDrawMode: number;
  4670. /**
  4671. * Returns the line list draw mode
  4672. */
  4673. static readonly MATERIAL_LineListDrawMode: number;
  4674. /**
  4675. * Returns the line loop draw mode
  4676. */
  4677. static readonly MATERIAL_LineLoopDrawMode: number;
  4678. /**
  4679. * Returns the line strip draw mode
  4680. */
  4681. static readonly MATERIAL_LineStripDrawMode: number;
  4682. /**
  4683. * Returns the triangle strip draw mode
  4684. */
  4685. static readonly MATERIAL_TriangleStripDrawMode: number;
  4686. /**
  4687. * Returns the triangle fan draw mode
  4688. */
  4689. static readonly MATERIAL_TriangleFanDrawMode: number;
  4690. /**
  4691. * Stores the clock-wise side orientation
  4692. */
  4693. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4694. /**
  4695. * Stores the counter clock-wise side orientation
  4696. */
  4697. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4698. /**
  4699. * Nothing
  4700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4701. */
  4702. static readonly ACTION_NothingTrigger: number;
  4703. /**
  4704. * On pick
  4705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4706. */
  4707. static readonly ACTION_OnPickTrigger: number;
  4708. /**
  4709. * On left pick
  4710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4711. */
  4712. static readonly ACTION_OnLeftPickTrigger: number;
  4713. /**
  4714. * On right pick
  4715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4716. */
  4717. static readonly ACTION_OnRightPickTrigger: number;
  4718. /**
  4719. * On center pick
  4720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4721. */
  4722. static readonly ACTION_OnCenterPickTrigger: number;
  4723. /**
  4724. * On pick down
  4725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4726. */
  4727. static readonly ACTION_OnPickDownTrigger: number;
  4728. /**
  4729. * On double pick
  4730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4731. */
  4732. static readonly ACTION_OnDoublePickTrigger: number;
  4733. /**
  4734. * On pick up
  4735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4736. */
  4737. static readonly ACTION_OnPickUpTrigger: number;
  4738. /**
  4739. * On pick out.
  4740. * This trigger will only be raised if you also declared a OnPickDown
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPickOutTrigger: number;
  4744. /**
  4745. * On long press
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnLongPressTrigger: number;
  4749. /**
  4750. * On pointer over
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnPointerOverTrigger: number;
  4754. /**
  4755. * On pointer out
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnPointerOutTrigger: number;
  4759. /**
  4760. * On every frame
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnEveryFrameTrigger: number;
  4764. /**
  4765. * On intersection enter
  4766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4767. */
  4768. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4769. /**
  4770. * On intersection exit
  4771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4772. */
  4773. static readonly ACTION_OnIntersectionExitTrigger: number;
  4774. /**
  4775. * On key down
  4776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4777. */
  4778. static readonly ACTION_OnKeyDownTrigger: number;
  4779. /**
  4780. * On key up
  4781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4782. */
  4783. static readonly ACTION_OnKeyUpTrigger: number;
  4784. /**
  4785. * Billboard mode will only apply to Y axis
  4786. */
  4787. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4788. /**
  4789. * Billboard mode will apply to all axes
  4790. */
  4791. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4792. /**
  4793. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4794. */
  4795. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4796. /**
  4797. * Gets or sets base Assets URL
  4798. */
  4799. static readonly PARTICLES_BaseAssetsUrl: string;
  4800. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4801. * Test order :
  4802. * Is the bounding sphere outside the frustum ?
  4803. * If not, are the bounding box vertices outside the frustum ?
  4804. * It not, then the cullable object is in the frustum.
  4805. */
  4806. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4807. /** Culling strategy : Bounding Sphere Only.
  4808. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4809. * It's also less accurate than the standard because some not visible objects can still be selected.
  4810. * Test : is the bounding sphere outside the frustum ?
  4811. * If not, then the cullable object is in the frustum.
  4812. */
  4813. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4814. /** Culling strategy : Optimistic Inclusion.
  4815. * This in an inclusion test first, then the standard exclusion test.
  4816. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4817. * 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.
  4818. * Anyway, it's as accurate as the standard strategy.
  4819. * Test :
  4820. * Is the cullable object bounding sphere center in the frustum ?
  4821. * If not, apply the default culling strategy.
  4822. */
  4823. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4824. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4825. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4826. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4827. * 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.
  4828. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4829. * Test :
  4830. * Is the cullable object bounding sphere center in the frustum ?
  4831. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4832. */
  4833. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4834. /**
  4835. * No logging while loading
  4836. */
  4837. static readonly SCENELOADER_NO_LOGGING: number;
  4838. /**
  4839. * Minimal logging while loading
  4840. */
  4841. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4842. /**
  4843. * Summary logging while loading
  4844. */
  4845. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4846. /**
  4847. * Detailled logging while loading
  4848. */
  4849. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4850. }
  4851. }
  4852. declare module "babylonjs/Misc/domManagement" {
  4853. /**
  4854. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4855. * Babylon.js
  4856. */
  4857. export class DomManagement {
  4858. /**
  4859. * Checks if the window object exists
  4860. * @returns true if the window object exists
  4861. */
  4862. static IsWindowObjectExist(): boolean;
  4863. /**
  4864. * Extracts text content from a DOM element hierarchy
  4865. * @param element defines the root element
  4866. * @returns a string
  4867. */
  4868. static GetDOMTextContent(element: HTMLElement): string;
  4869. }
  4870. }
  4871. declare module "babylonjs/Misc/logger" {
  4872. /**
  4873. * Logger used througouht the application to allow configuration of
  4874. * the log level required for the messages.
  4875. */
  4876. export class Logger {
  4877. /**
  4878. * No log
  4879. */
  4880. static readonly NoneLogLevel: number;
  4881. /**
  4882. * Only message logs
  4883. */
  4884. static readonly MessageLogLevel: number;
  4885. /**
  4886. * Only warning logs
  4887. */
  4888. static readonly WarningLogLevel: number;
  4889. /**
  4890. * Only error logs
  4891. */
  4892. static readonly ErrorLogLevel: number;
  4893. /**
  4894. * All logs
  4895. */
  4896. static readonly AllLogLevel: number;
  4897. private static _LogCache;
  4898. /**
  4899. * Gets a value indicating the number of loading errors
  4900. * @ignorenaming
  4901. */
  4902. static errorsCount: number;
  4903. /**
  4904. * Callback called when a new log is added
  4905. */
  4906. static OnNewCacheEntry: (entry: string) => void;
  4907. private static _AddLogEntry;
  4908. private static _FormatMessage;
  4909. private static _LogDisabled;
  4910. private static _LogEnabled;
  4911. private static _WarnDisabled;
  4912. private static _WarnEnabled;
  4913. private static _ErrorDisabled;
  4914. private static _ErrorEnabled;
  4915. /**
  4916. * Log a message to the console
  4917. */
  4918. static Log: (message: string) => void;
  4919. /**
  4920. * Write a warning message to the console
  4921. */
  4922. static Warn: (message: string) => void;
  4923. /**
  4924. * Write an error message to the console
  4925. */
  4926. static Error: (message: string) => void;
  4927. /**
  4928. * Gets current log cache (list of logs)
  4929. */
  4930. static readonly LogCache: string;
  4931. /**
  4932. * Clears the log cache
  4933. */
  4934. static ClearLogCache(): void;
  4935. /**
  4936. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4937. */
  4938. static LogLevels: number;
  4939. }
  4940. }
  4941. declare module "babylonjs/Misc/typeStore" {
  4942. /** @hidden */
  4943. export class _TypeStore {
  4944. /** @hidden */
  4945. static RegisteredTypes: {
  4946. [key: string]: Object;
  4947. };
  4948. /** @hidden */
  4949. static GetClass(fqdn: string): any;
  4950. }
  4951. }
  4952. declare module "babylonjs/Misc/deepCopier" {
  4953. /**
  4954. * Class containing a set of static utilities functions for deep copy.
  4955. */
  4956. export class DeepCopier {
  4957. /**
  4958. * Tries to copy an object by duplicating every property
  4959. * @param source defines the source object
  4960. * @param destination defines the target object
  4961. * @param doNotCopyList defines a list of properties to avoid
  4962. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4963. */
  4964. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4965. }
  4966. }
  4967. declare module "babylonjs/Misc/precisionDate" {
  4968. /**
  4969. * Class containing a set of static utilities functions for precision date
  4970. */
  4971. export class PrecisionDate {
  4972. /**
  4973. * Gets either window.performance.now() if supported or Date.now() else
  4974. */
  4975. static readonly Now: number;
  4976. }
  4977. }
  4978. declare module "babylonjs/Misc/devTools" {
  4979. /** @hidden */
  4980. export class _DevTools {
  4981. static WarnImport(name: string): string;
  4982. }
  4983. }
  4984. declare module "babylonjs/Misc/webRequest" {
  4985. /**
  4986. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4987. */
  4988. export class WebRequest {
  4989. private _xhr;
  4990. /**
  4991. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4992. * i.e. when loading files, where the server/service expects an Authorization header
  4993. */
  4994. static CustomRequestHeaders: {
  4995. [key: string]: string;
  4996. };
  4997. /**
  4998. * Add callback functions in this array to update all the requests before they get sent to the network
  4999. */
  5000. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5001. private _injectCustomRequestHeaders;
  5002. /**
  5003. * Gets or sets a function to be called when loading progress changes
  5004. */
  5005. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5006. /**
  5007. * Returns client's state
  5008. */
  5009. readonly readyState: number;
  5010. /**
  5011. * Returns client's status
  5012. */
  5013. readonly status: number;
  5014. /**
  5015. * Returns client's status as a text
  5016. */
  5017. readonly statusText: string;
  5018. /**
  5019. * Returns client's response
  5020. */
  5021. readonly response: any;
  5022. /**
  5023. * Returns client's response url
  5024. */
  5025. readonly responseURL: string;
  5026. /**
  5027. * Returns client's response as text
  5028. */
  5029. readonly responseText: string;
  5030. /**
  5031. * Gets or sets the expected response type
  5032. */
  5033. responseType: XMLHttpRequestResponseType;
  5034. /** @hidden */
  5035. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5036. /** @hidden */
  5037. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5038. /**
  5039. * Cancels any network activity
  5040. */
  5041. abort(): void;
  5042. /**
  5043. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5044. * @param body defines an optional request body
  5045. */
  5046. send(body?: Document | BodyInit | null): void;
  5047. /**
  5048. * Sets the request method, request URL
  5049. * @param method defines the method to use (GET, POST, etc..)
  5050. * @param url defines the url to connect with
  5051. */
  5052. open(method: string, url: string): void;
  5053. }
  5054. }
  5055. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5056. /**
  5057. * Class used to evalaute queries containing `and` and `or` operators
  5058. */
  5059. export class AndOrNotEvaluator {
  5060. /**
  5061. * Evaluate a query
  5062. * @param query defines the query to evaluate
  5063. * @param evaluateCallback defines the callback used to filter result
  5064. * @returns true if the query matches
  5065. */
  5066. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5067. private static _HandleParenthesisContent;
  5068. private static _SimplifyNegation;
  5069. }
  5070. }
  5071. declare module "babylonjs/Misc/tags" {
  5072. /**
  5073. * Class used to store custom tags
  5074. */
  5075. export class Tags {
  5076. /**
  5077. * Adds support for tags on the given object
  5078. * @param obj defines the object to use
  5079. */
  5080. static EnableFor(obj: any): void;
  5081. /**
  5082. * Removes tags support
  5083. * @param obj defines the object to use
  5084. */
  5085. static DisableFor(obj: any): void;
  5086. /**
  5087. * Gets a boolean indicating if the given object has tags
  5088. * @param obj defines the object to use
  5089. * @returns a boolean
  5090. */
  5091. static HasTags(obj: any): boolean;
  5092. /**
  5093. * Gets the tags available on a given object
  5094. * @param obj defines the object to use
  5095. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5096. * @returns the tags
  5097. */
  5098. static GetTags(obj: any, asString?: boolean): any;
  5099. /**
  5100. * Adds tags to an object
  5101. * @param obj defines the object to use
  5102. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5103. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5104. */
  5105. static AddTagsTo(obj: any, tagsString: string): void;
  5106. /**
  5107. * @hidden
  5108. */
  5109. static _AddTagTo(obj: any, tag: string): void;
  5110. /**
  5111. * Removes specific tags from a specific object
  5112. * @param obj defines the object to use
  5113. * @param tagsString defines the tags to remove
  5114. */
  5115. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5116. /**
  5117. * @hidden
  5118. */
  5119. static _RemoveTagFrom(obj: any, tag: string): void;
  5120. /**
  5121. * Defines if tags hosted on an object match a given query
  5122. * @param obj defines the object to use
  5123. * @param tagsQuery defines the tag query
  5124. * @returns a boolean
  5125. */
  5126. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5127. }
  5128. }
  5129. declare module "babylonjs/Materials/materialDefines" {
  5130. /**
  5131. * Manages the defines for the Material
  5132. */
  5133. export class MaterialDefines {
  5134. private _keys;
  5135. private _isDirty;
  5136. /** @hidden */
  5137. _renderId: number;
  5138. /** @hidden */
  5139. _areLightsDirty: boolean;
  5140. /** @hidden */
  5141. _areAttributesDirty: boolean;
  5142. /** @hidden */
  5143. _areTexturesDirty: boolean;
  5144. /** @hidden */
  5145. _areFresnelDirty: boolean;
  5146. /** @hidden */
  5147. _areMiscDirty: boolean;
  5148. /** @hidden */
  5149. _areImageProcessingDirty: boolean;
  5150. /** @hidden */
  5151. _normals: boolean;
  5152. /** @hidden */
  5153. _uvs: boolean;
  5154. /** @hidden */
  5155. _needNormals: boolean;
  5156. /** @hidden */
  5157. _needUVs: boolean;
  5158. /**
  5159. * Specifies if the material needs to be re-calculated
  5160. */
  5161. readonly isDirty: boolean;
  5162. /**
  5163. * Marks the material to indicate that it has been re-calculated
  5164. */
  5165. markAsProcessed(): void;
  5166. /**
  5167. * Marks the material to indicate that it needs to be re-calculated
  5168. */
  5169. markAsUnprocessed(): void;
  5170. /**
  5171. * Marks the material to indicate all of its defines need to be re-calculated
  5172. */
  5173. markAllAsDirty(): void;
  5174. /**
  5175. * Marks the material to indicate that image processing needs to be re-calculated
  5176. */
  5177. markAsImageProcessingDirty(): void;
  5178. /**
  5179. * Marks the material to indicate the lights need to be re-calculated
  5180. */
  5181. markAsLightDirty(): void;
  5182. /**
  5183. * Marks the attribute state as changed
  5184. */
  5185. markAsAttributesDirty(): void;
  5186. /**
  5187. * Marks the texture state as changed
  5188. */
  5189. markAsTexturesDirty(): void;
  5190. /**
  5191. * Marks the fresnel state as changed
  5192. */
  5193. markAsFresnelDirty(): void;
  5194. /**
  5195. * Marks the misc state as changed
  5196. */
  5197. markAsMiscDirty(): void;
  5198. /**
  5199. * Rebuilds the material defines
  5200. */
  5201. rebuild(): void;
  5202. /**
  5203. * Specifies if two material defines are equal
  5204. * @param other - A material define instance to compare to
  5205. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5206. */
  5207. isEqual(other: MaterialDefines): boolean;
  5208. /**
  5209. * Clones this instance's defines to another instance
  5210. * @param other - material defines to clone values to
  5211. */
  5212. cloneTo(other: MaterialDefines): void;
  5213. /**
  5214. * Resets the material define values
  5215. */
  5216. reset(): void;
  5217. /**
  5218. * Converts the material define values to a string
  5219. * @returns - String of material define information
  5220. */
  5221. toString(): string;
  5222. }
  5223. }
  5224. declare module "babylonjs/Misc/performanceMonitor" {
  5225. /**
  5226. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5227. */
  5228. export class PerformanceMonitor {
  5229. private _enabled;
  5230. private _rollingFrameTime;
  5231. private _lastFrameTimeMs;
  5232. /**
  5233. * constructor
  5234. * @param frameSampleSize The number of samples required to saturate the sliding window
  5235. */
  5236. constructor(frameSampleSize?: number);
  5237. /**
  5238. * Samples current frame
  5239. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5240. */
  5241. sampleFrame(timeMs?: number): void;
  5242. /**
  5243. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5244. */
  5245. readonly averageFrameTime: number;
  5246. /**
  5247. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5248. */
  5249. readonly averageFrameTimeVariance: number;
  5250. /**
  5251. * Returns the frame time of the most recent frame
  5252. */
  5253. readonly instantaneousFrameTime: number;
  5254. /**
  5255. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5256. */
  5257. readonly averageFPS: number;
  5258. /**
  5259. * Returns the average framerate in frames per second using the most recent frame time
  5260. */
  5261. readonly instantaneousFPS: number;
  5262. /**
  5263. * Returns true if enough samples have been taken to completely fill the sliding window
  5264. */
  5265. readonly isSaturated: boolean;
  5266. /**
  5267. * Enables contributions to the sliding window sample set
  5268. */
  5269. enable(): void;
  5270. /**
  5271. * Disables contributions to the sliding window sample set
  5272. * Samples will not be interpolated over the disabled period
  5273. */
  5274. disable(): void;
  5275. /**
  5276. * Returns true if sampling is enabled
  5277. */
  5278. readonly isEnabled: boolean;
  5279. /**
  5280. * Resets performance monitor
  5281. */
  5282. reset(): void;
  5283. }
  5284. /**
  5285. * RollingAverage
  5286. *
  5287. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5288. */
  5289. export class RollingAverage {
  5290. /**
  5291. * Current average
  5292. */
  5293. average: number;
  5294. /**
  5295. * Current variance
  5296. */
  5297. variance: number;
  5298. protected _samples: Array<number>;
  5299. protected _sampleCount: number;
  5300. protected _pos: number;
  5301. protected _m2: number;
  5302. /**
  5303. * constructor
  5304. * @param length The number of samples required to saturate the sliding window
  5305. */
  5306. constructor(length: number);
  5307. /**
  5308. * Adds a sample to the sample set
  5309. * @param v The sample value
  5310. */
  5311. add(v: number): void;
  5312. /**
  5313. * Returns previously added values or null if outside of history or outside the sliding window domain
  5314. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5315. * @return Value previously recorded with add() or null if outside of range
  5316. */
  5317. history(i: number): number;
  5318. /**
  5319. * Returns true if enough samples have been taken to completely fill the sliding window
  5320. * @return true if sample-set saturated
  5321. */
  5322. isSaturated(): boolean;
  5323. /**
  5324. * Resets the rolling average (equivalent to 0 samples taken so far)
  5325. */
  5326. reset(): void;
  5327. /**
  5328. * Wraps a value around the sample range boundaries
  5329. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5330. * @return Wrapped position in sample range
  5331. */
  5332. protected _wrapPosition(i: number): number;
  5333. }
  5334. }
  5335. declare module "babylonjs/Misc/stringDictionary" {
  5336. import { Nullable } from "babylonjs/types";
  5337. /**
  5338. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5339. * The underlying implementation relies on an associative array to ensure the best performances.
  5340. * The value can be anything including 'null' but except 'undefined'
  5341. */
  5342. export class StringDictionary<T> {
  5343. /**
  5344. * This will clear this dictionary and copy the content from the 'source' one.
  5345. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5346. * @param source the dictionary to take the content from and copy to this dictionary
  5347. */
  5348. copyFrom(source: StringDictionary<T>): void;
  5349. /**
  5350. * Get a value based from its key
  5351. * @param key the given key to get the matching value from
  5352. * @return the value if found, otherwise undefined is returned
  5353. */
  5354. get(key: string): T | undefined;
  5355. /**
  5356. * Get a value from its key or add it if it doesn't exist.
  5357. * This method will ensure you that a given key/data will be present in the dictionary.
  5358. * @param key the given key to get the matching value from
  5359. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5360. * The factory will only be invoked if there's no data for the given key.
  5361. * @return the value corresponding to the key.
  5362. */
  5363. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5364. /**
  5365. * Get a value from its key if present in the dictionary otherwise add it
  5366. * @param key the key to get the value from
  5367. * @param val if there's no such key/value pair in the dictionary add it with this value
  5368. * @return the value corresponding to the key
  5369. */
  5370. getOrAdd(key: string, val: T): T;
  5371. /**
  5372. * Check if there's a given key in the dictionary
  5373. * @param key the key to check for
  5374. * @return true if the key is present, false otherwise
  5375. */
  5376. contains(key: string): boolean;
  5377. /**
  5378. * Add a new key and its corresponding value
  5379. * @param key the key to add
  5380. * @param value the value corresponding to the key
  5381. * @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
  5382. */
  5383. add(key: string, value: T): boolean;
  5384. /**
  5385. * Update a specific value associated to a key
  5386. * @param key defines the key to use
  5387. * @param value defines the value to store
  5388. * @returns true if the value was updated (or false if the key was not found)
  5389. */
  5390. set(key: string, value: T): boolean;
  5391. /**
  5392. * Get the element of the given key and remove it from the dictionary
  5393. * @param key defines the key to search
  5394. * @returns the value associated with the key or null if not found
  5395. */
  5396. getAndRemove(key: string): Nullable<T>;
  5397. /**
  5398. * Remove a key/value from the dictionary.
  5399. * @param key the key to remove
  5400. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5401. */
  5402. remove(key: string): boolean;
  5403. /**
  5404. * Clear the whole content of the dictionary
  5405. */
  5406. clear(): void;
  5407. /**
  5408. * Gets the current count
  5409. */
  5410. readonly count: number;
  5411. /**
  5412. * Execute a callback on each key/val of the dictionary.
  5413. * Note that you can remove any element in this dictionary in the callback implementation
  5414. * @param callback the callback to execute on a given key/value pair
  5415. */
  5416. forEach(callback: (key: string, val: T) => void): void;
  5417. /**
  5418. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5419. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5420. * Note that you can remove any element in this dictionary in the callback implementation
  5421. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5422. * @returns the first item
  5423. */
  5424. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5425. private _count;
  5426. private _data;
  5427. }
  5428. }
  5429. declare module "babylonjs/Misc/promise" {
  5430. /**
  5431. * Helper class that provides a small promise polyfill
  5432. */
  5433. export class PromisePolyfill {
  5434. /**
  5435. * Static function used to check if the polyfill is required
  5436. * If this is the case then the function will inject the polyfill to window.Promise
  5437. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5438. */
  5439. static Apply(force?: boolean): void;
  5440. }
  5441. }
  5442. declare module "babylonjs/Meshes/buffer" {
  5443. import { Nullable, DataArray } from "babylonjs/types";
  5444. /**
  5445. * Class used to store data that will be store in GPU memory
  5446. */
  5447. export class Buffer {
  5448. private _engine;
  5449. private _buffer;
  5450. /** @hidden */
  5451. _data: Nullable<DataArray>;
  5452. private _updatable;
  5453. private _instanced;
  5454. /**
  5455. * Gets the byte stride.
  5456. */
  5457. readonly byteStride: number;
  5458. /**
  5459. * Constructor
  5460. * @param engine the engine
  5461. * @param data the data to use for this buffer
  5462. * @param updatable whether the data is updatable
  5463. * @param stride the stride (optional)
  5464. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5465. * @param instanced whether the buffer is instanced (optional)
  5466. * @param useBytes set to true if the stride in in bytes (optional)
  5467. */
  5468. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5469. /**
  5470. * Create a new VertexBuffer based on the current buffer
  5471. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5472. * @param offset defines offset in the buffer (0 by default)
  5473. * @param size defines the size in floats of attributes (position is 3 for instance)
  5474. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5475. * @param instanced defines if the vertex buffer contains indexed data
  5476. * @param useBytes defines if the offset and stride are in bytes
  5477. * @returns the new vertex buffer
  5478. */
  5479. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5480. /**
  5481. * Gets a boolean indicating if the Buffer is updatable?
  5482. * @returns true if the buffer is updatable
  5483. */
  5484. isUpdatable(): boolean;
  5485. /**
  5486. * Gets current buffer's data
  5487. * @returns a DataArray or null
  5488. */
  5489. getData(): Nullable<DataArray>;
  5490. /**
  5491. * Gets underlying native buffer
  5492. * @returns underlying native buffer
  5493. */
  5494. getBuffer(): Nullable<WebGLBuffer>;
  5495. /**
  5496. * Gets the stride in float32 units (i.e. byte stride / 4).
  5497. * May not be an integer if the byte stride is not divisible by 4.
  5498. * DEPRECATED. Use byteStride instead.
  5499. * @returns the stride in float32 units
  5500. */
  5501. getStrideSize(): number;
  5502. /**
  5503. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5504. * @param data defines the data to store
  5505. */
  5506. create(data?: Nullable<DataArray>): void;
  5507. /** @hidden */
  5508. _rebuild(): void;
  5509. /**
  5510. * Update current buffer data
  5511. * @param data defines the data to store
  5512. */
  5513. update(data: DataArray): void;
  5514. /**
  5515. * Updates the data directly.
  5516. * @param data the new data
  5517. * @param offset the new offset
  5518. * @param vertexCount the vertex count (optional)
  5519. * @param useBytes set to true if the offset is in bytes
  5520. */
  5521. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5522. /**
  5523. * Release all resources
  5524. */
  5525. dispose(): void;
  5526. }
  5527. /**
  5528. * Specialized buffer used to store vertex data
  5529. */
  5530. export class VertexBuffer {
  5531. /** @hidden */
  5532. _buffer: Buffer;
  5533. private _kind;
  5534. private _size;
  5535. private _ownsBuffer;
  5536. private _instanced;
  5537. private _instanceDivisor;
  5538. /**
  5539. * The byte type.
  5540. */
  5541. static readonly BYTE: number;
  5542. /**
  5543. * The unsigned byte type.
  5544. */
  5545. static readonly UNSIGNED_BYTE: number;
  5546. /**
  5547. * The short type.
  5548. */
  5549. static readonly SHORT: number;
  5550. /**
  5551. * The unsigned short type.
  5552. */
  5553. static readonly UNSIGNED_SHORT: number;
  5554. /**
  5555. * The integer type.
  5556. */
  5557. static readonly INT: number;
  5558. /**
  5559. * The unsigned integer type.
  5560. */
  5561. static readonly UNSIGNED_INT: number;
  5562. /**
  5563. * The float type.
  5564. */
  5565. static readonly FLOAT: number;
  5566. /**
  5567. * Gets or sets the instance divisor when in instanced mode
  5568. */
  5569. instanceDivisor: number;
  5570. /**
  5571. * Gets the byte stride.
  5572. */
  5573. readonly byteStride: number;
  5574. /**
  5575. * Gets the byte offset.
  5576. */
  5577. readonly byteOffset: number;
  5578. /**
  5579. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5580. */
  5581. readonly normalized: boolean;
  5582. /**
  5583. * Gets the data type of each component in the array.
  5584. */
  5585. readonly type: number;
  5586. /**
  5587. * Constructor
  5588. * @param engine the engine
  5589. * @param data the data to use for this vertex buffer
  5590. * @param kind the vertex buffer kind
  5591. * @param updatable whether the data is updatable
  5592. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5593. * @param stride the stride (optional)
  5594. * @param instanced whether the buffer is instanced (optional)
  5595. * @param offset the offset of the data (optional)
  5596. * @param size the number of components (optional)
  5597. * @param type the type of the component (optional)
  5598. * @param normalized whether the data contains normalized data (optional)
  5599. * @param useBytes set to true if stride and offset are in bytes (optional)
  5600. */
  5601. 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);
  5602. /** @hidden */
  5603. _rebuild(): void;
  5604. /**
  5605. * Returns the kind of the VertexBuffer (string)
  5606. * @returns a string
  5607. */
  5608. getKind(): string;
  5609. /**
  5610. * Gets a boolean indicating if the VertexBuffer is updatable?
  5611. * @returns true if the buffer is updatable
  5612. */
  5613. isUpdatable(): boolean;
  5614. /**
  5615. * Gets current buffer's data
  5616. * @returns a DataArray or null
  5617. */
  5618. getData(): Nullable<DataArray>;
  5619. /**
  5620. * Gets underlying native buffer
  5621. * @returns underlying native buffer
  5622. */
  5623. getBuffer(): Nullable<WebGLBuffer>;
  5624. /**
  5625. * Gets the stride in float32 units (i.e. byte stride / 4).
  5626. * May not be an integer if the byte stride is not divisible by 4.
  5627. * DEPRECATED. Use byteStride instead.
  5628. * @returns the stride in float32 units
  5629. */
  5630. getStrideSize(): number;
  5631. /**
  5632. * Returns the offset as a multiple of the type byte length.
  5633. * DEPRECATED. Use byteOffset instead.
  5634. * @returns the offset in bytes
  5635. */
  5636. getOffset(): number;
  5637. /**
  5638. * Returns the number of components per vertex attribute (integer)
  5639. * @returns the size in float
  5640. */
  5641. getSize(): number;
  5642. /**
  5643. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5644. * @returns true if this buffer is instanced
  5645. */
  5646. getIsInstanced(): boolean;
  5647. /**
  5648. * Returns the instancing divisor, zero for non-instanced (integer).
  5649. * @returns a number
  5650. */
  5651. getInstanceDivisor(): number;
  5652. /**
  5653. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5654. * @param data defines the data to store
  5655. */
  5656. create(data?: DataArray): void;
  5657. /**
  5658. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5659. * This function will create a new buffer if the current one is not updatable
  5660. * @param data defines the data to store
  5661. */
  5662. update(data: DataArray): void;
  5663. /**
  5664. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5665. * Returns the directly updated WebGLBuffer.
  5666. * @param data the new data
  5667. * @param offset the new offset
  5668. * @param useBytes set to true if the offset is in bytes
  5669. */
  5670. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5671. /**
  5672. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5673. */
  5674. dispose(): void;
  5675. /**
  5676. * Enumerates each value of this vertex buffer as numbers.
  5677. * @param count the number of values to enumerate
  5678. * @param callback the callback function called for each value
  5679. */
  5680. forEach(count: number, callback: (value: number, index: number) => void): void;
  5681. /**
  5682. * Positions
  5683. */
  5684. static readonly PositionKind: string;
  5685. /**
  5686. * Normals
  5687. */
  5688. static readonly NormalKind: string;
  5689. /**
  5690. * Tangents
  5691. */
  5692. static readonly TangentKind: string;
  5693. /**
  5694. * Texture coordinates
  5695. */
  5696. static readonly UVKind: string;
  5697. /**
  5698. * Texture coordinates 2
  5699. */
  5700. static readonly UV2Kind: string;
  5701. /**
  5702. * Texture coordinates 3
  5703. */
  5704. static readonly UV3Kind: string;
  5705. /**
  5706. * Texture coordinates 4
  5707. */
  5708. static readonly UV4Kind: string;
  5709. /**
  5710. * Texture coordinates 5
  5711. */
  5712. static readonly UV5Kind: string;
  5713. /**
  5714. * Texture coordinates 6
  5715. */
  5716. static readonly UV6Kind: string;
  5717. /**
  5718. * Colors
  5719. */
  5720. static readonly ColorKind: string;
  5721. /**
  5722. * Matrix indices (for bones)
  5723. */
  5724. static readonly MatricesIndicesKind: string;
  5725. /**
  5726. * Matrix weights (for bones)
  5727. */
  5728. static readonly MatricesWeightsKind: string;
  5729. /**
  5730. * Additional matrix indices (for bones)
  5731. */
  5732. static readonly MatricesIndicesExtraKind: string;
  5733. /**
  5734. * Additional matrix weights (for bones)
  5735. */
  5736. static readonly MatricesWeightsExtraKind: string;
  5737. /**
  5738. * Deduces the stride given a kind.
  5739. * @param kind The kind string to deduce
  5740. * @returns The deduced stride
  5741. */
  5742. static DeduceStride(kind: string): number;
  5743. /**
  5744. * Gets the byte length of the given type.
  5745. * @param type the type
  5746. * @returns the number of bytes
  5747. */
  5748. static GetTypeByteLength(type: number): number;
  5749. /**
  5750. * Enumerates each value of the given parameters as numbers.
  5751. * @param data the data to enumerate
  5752. * @param byteOffset the byte offset of the data
  5753. * @param byteStride the byte stride of the data
  5754. * @param componentCount the number of components per element
  5755. * @param componentType the type of the component
  5756. * @param count the total number of components
  5757. * @param normalized whether the data is normalized
  5758. * @param callback the callback function called for each value
  5759. */
  5760. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5761. private static _GetFloatValue;
  5762. }
  5763. }
  5764. declare module "babylonjs/Maths/sphericalPolynomial" {
  5765. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5766. /**
  5767. * Class representing spherical polynomial coefficients to the 3rd degree
  5768. */
  5769. export class SphericalPolynomial {
  5770. /**
  5771. * The x coefficients of the spherical polynomial
  5772. */
  5773. x: Vector3;
  5774. /**
  5775. * The y coefficients of the spherical polynomial
  5776. */
  5777. y: Vector3;
  5778. /**
  5779. * The z coefficients of the spherical polynomial
  5780. */
  5781. z: Vector3;
  5782. /**
  5783. * The xx coefficients of the spherical polynomial
  5784. */
  5785. xx: Vector3;
  5786. /**
  5787. * The yy coefficients of the spherical polynomial
  5788. */
  5789. yy: Vector3;
  5790. /**
  5791. * The zz coefficients of the spherical polynomial
  5792. */
  5793. zz: Vector3;
  5794. /**
  5795. * The xy coefficients of the spherical polynomial
  5796. */
  5797. xy: Vector3;
  5798. /**
  5799. * The yz coefficients of the spherical polynomial
  5800. */
  5801. yz: Vector3;
  5802. /**
  5803. * The zx coefficients of the spherical polynomial
  5804. */
  5805. zx: Vector3;
  5806. /**
  5807. * Adds an ambient color to the spherical polynomial
  5808. * @param color the color to add
  5809. */
  5810. addAmbient(color: Color3): void;
  5811. /**
  5812. * Scales the spherical polynomial by the given amount
  5813. * @param scale the amount to scale
  5814. */
  5815. scale(scale: number): void;
  5816. /**
  5817. * Gets the spherical polynomial from harmonics
  5818. * @param harmonics the spherical harmonics
  5819. * @returns the spherical polynomial
  5820. */
  5821. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5822. /**
  5823. * Constructs a spherical polynomial from an array.
  5824. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5825. * @returns the spherical polynomial
  5826. */
  5827. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5828. }
  5829. /**
  5830. * Class representing spherical harmonics coefficients to the 3rd degree
  5831. */
  5832. export class SphericalHarmonics {
  5833. /**
  5834. * The l0,0 coefficients of the spherical harmonics
  5835. */
  5836. l00: Vector3;
  5837. /**
  5838. * The l1,-1 coefficients of the spherical harmonics
  5839. */
  5840. l1_1: Vector3;
  5841. /**
  5842. * The l1,0 coefficients of the spherical harmonics
  5843. */
  5844. l10: Vector3;
  5845. /**
  5846. * The l1,1 coefficients of the spherical harmonics
  5847. */
  5848. l11: Vector3;
  5849. /**
  5850. * The l2,-2 coefficients of the spherical harmonics
  5851. */
  5852. l2_2: Vector3;
  5853. /**
  5854. * The l2,-1 coefficients of the spherical harmonics
  5855. */
  5856. l2_1: Vector3;
  5857. /**
  5858. * The l2,0 coefficients of the spherical harmonics
  5859. */
  5860. l20: Vector3;
  5861. /**
  5862. * The l2,1 coefficients of the spherical harmonics
  5863. */
  5864. l21: Vector3;
  5865. /**
  5866. * The l2,2 coefficients of the spherical harmonics
  5867. */
  5868. lL22: Vector3;
  5869. /**
  5870. * Adds a light to the spherical harmonics
  5871. * @param direction the direction of the light
  5872. * @param color the color of the light
  5873. * @param deltaSolidAngle the delta solid angle of the light
  5874. */
  5875. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5876. /**
  5877. * Scales the spherical harmonics by the given amount
  5878. * @param scale the amount to scale
  5879. */
  5880. scale(scale: number): void;
  5881. /**
  5882. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5883. *
  5884. * ```
  5885. * E_lm = A_l * L_lm
  5886. * ```
  5887. *
  5888. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5889. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5890. * the scaling factors are given in equation 9.
  5891. */
  5892. convertIncidentRadianceToIrradiance(): void;
  5893. /**
  5894. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5895. *
  5896. * ```
  5897. * L = (1/pi) * E * rho
  5898. * ```
  5899. *
  5900. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5901. */
  5902. convertIrradianceToLambertianRadiance(): void;
  5903. /**
  5904. * Gets the spherical harmonics from polynomial
  5905. * @param polynomial the spherical polynomial
  5906. * @returns the spherical harmonics
  5907. */
  5908. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5909. /**
  5910. * Constructs a spherical harmonics from an array.
  5911. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5912. * @returns the spherical harmonics
  5913. */
  5914. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5915. }
  5916. }
  5917. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5918. import { Nullable } from "babylonjs/types";
  5919. /**
  5920. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5921. */
  5922. export interface CubeMapInfo {
  5923. /**
  5924. * The pixel array for the front face.
  5925. * This is stored in format, left to right, up to down format.
  5926. */
  5927. front: Nullable<ArrayBufferView>;
  5928. /**
  5929. * The pixel array for the back face.
  5930. * This is stored in format, left to right, up to down format.
  5931. */
  5932. back: Nullable<ArrayBufferView>;
  5933. /**
  5934. * The pixel array for the left face.
  5935. * This is stored in format, left to right, up to down format.
  5936. */
  5937. left: Nullable<ArrayBufferView>;
  5938. /**
  5939. * The pixel array for the right face.
  5940. * This is stored in format, left to right, up to down format.
  5941. */
  5942. right: Nullable<ArrayBufferView>;
  5943. /**
  5944. * The pixel array for the up face.
  5945. * This is stored in format, left to right, up to down format.
  5946. */
  5947. up: Nullable<ArrayBufferView>;
  5948. /**
  5949. * The pixel array for the down face.
  5950. * This is stored in format, left to right, up to down format.
  5951. */
  5952. down: Nullable<ArrayBufferView>;
  5953. /**
  5954. * The size of the cubemap stored.
  5955. *
  5956. * Each faces will be size * size pixels.
  5957. */
  5958. size: number;
  5959. /**
  5960. * The format of the texture.
  5961. *
  5962. * RGBA, RGB.
  5963. */
  5964. format: number;
  5965. /**
  5966. * The type of the texture data.
  5967. *
  5968. * UNSIGNED_INT, FLOAT.
  5969. */
  5970. type: number;
  5971. /**
  5972. * Specifies whether the texture is in gamma space.
  5973. */
  5974. gammaSpace: boolean;
  5975. }
  5976. /**
  5977. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5978. */
  5979. export class PanoramaToCubeMapTools {
  5980. private static FACE_FRONT;
  5981. private static FACE_BACK;
  5982. private static FACE_RIGHT;
  5983. private static FACE_LEFT;
  5984. private static FACE_DOWN;
  5985. private static FACE_UP;
  5986. /**
  5987. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5988. *
  5989. * @param float32Array The source data.
  5990. * @param inputWidth The width of the input panorama.
  5991. * @param inputHeight The height of the input panorama.
  5992. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5993. * @return The cubemap data
  5994. */
  5995. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5996. private static CreateCubemapTexture;
  5997. private static CalcProjectionSpherical;
  5998. }
  5999. }
  6000. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6001. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6002. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6003. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6004. /**
  6005. * Helper class dealing with the extraction of spherical polynomial dataArray
  6006. * from a cube map.
  6007. */
  6008. export class CubeMapToSphericalPolynomialTools {
  6009. private static FileFaces;
  6010. /**
  6011. * Converts a texture to the according Spherical Polynomial data.
  6012. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6013. *
  6014. * @param texture The texture to extract the information from.
  6015. * @return The Spherical Polynomial data.
  6016. */
  6017. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6018. /**
  6019. * Converts a cubemap to the according Spherical Polynomial data.
  6020. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6021. *
  6022. * @param cubeInfo The Cube map to extract the information from.
  6023. * @return The Spherical Polynomial data.
  6024. */
  6025. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6026. }
  6027. }
  6028. declare module "babylonjs/Engines/engineStore" {
  6029. import { Nullable } from "babylonjs/types";
  6030. import { Engine } from "babylonjs/Engines/engine";
  6031. import { Scene } from "babylonjs/scene";
  6032. /**
  6033. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6034. * during the life time of the application.
  6035. */
  6036. export class EngineStore {
  6037. /** Gets the list of created engines */
  6038. static Instances: import("babylonjs/Engines/engine").Engine[];
  6039. /**
  6040. * Gets the latest created engine
  6041. */
  6042. static readonly LastCreatedEngine: Nullable<Engine>;
  6043. /**
  6044. * Gets the latest created scene
  6045. */
  6046. static readonly LastCreatedScene: Nullable<Scene>;
  6047. }
  6048. }
  6049. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6050. /**
  6051. * Define options used to create a render target texture
  6052. */
  6053. export class RenderTargetCreationOptions {
  6054. /**
  6055. * Specifies is mipmaps must be generated
  6056. */
  6057. generateMipMaps?: boolean;
  6058. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6059. generateDepthBuffer?: boolean;
  6060. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6061. generateStencilBuffer?: boolean;
  6062. /** Defines texture type (int by default) */
  6063. type?: number;
  6064. /** Defines sampling mode (trilinear by default) */
  6065. samplingMode?: number;
  6066. /** Defines format (RGBA by default) */
  6067. format?: number;
  6068. }
  6069. }
  6070. declare module "babylonjs/States/alphaCullingState" {
  6071. /**
  6072. * @hidden
  6073. **/
  6074. export class _AlphaState {
  6075. private _isAlphaBlendDirty;
  6076. private _isBlendFunctionParametersDirty;
  6077. private _isBlendEquationParametersDirty;
  6078. private _isBlendConstantsDirty;
  6079. private _alphaBlend;
  6080. private _blendFunctionParameters;
  6081. private _blendEquationParameters;
  6082. private _blendConstants;
  6083. /**
  6084. * Initializes the state.
  6085. */
  6086. constructor();
  6087. readonly isDirty: boolean;
  6088. alphaBlend: boolean;
  6089. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6090. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6091. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6092. reset(): void;
  6093. apply(gl: WebGLRenderingContext): void;
  6094. }
  6095. }
  6096. declare module "babylonjs/States/depthCullingState" {
  6097. import { Nullable } from "babylonjs/types";
  6098. /**
  6099. * @hidden
  6100. **/
  6101. export class _DepthCullingState {
  6102. private _isDepthTestDirty;
  6103. private _isDepthMaskDirty;
  6104. private _isDepthFuncDirty;
  6105. private _isCullFaceDirty;
  6106. private _isCullDirty;
  6107. private _isZOffsetDirty;
  6108. private _isFrontFaceDirty;
  6109. private _depthTest;
  6110. private _depthMask;
  6111. private _depthFunc;
  6112. private _cull;
  6113. private _cullFace;
  6114. private _zOffset;
  6115. private _frontFace;
  6116. /**
  6117. * Initializes the state.
  6118. */
  6119. constructor();
  6120. readonly isDirty: boolean;
  6121. zOffset: number;
  6122. cullFace: Nullable<number>;
  6123. cull: Nullable<boolean>;
  6124. depthFunc: Nullable<number>;
  6125. depthMask: boolean;
  6126. depthTest: boolean;
  6127. frontFace: Nullable<number>;
  6128. reset(): void;
  6129. apply(gl: WebGLRenderingContext): void;
  6130. }
  6131. }
  6132. declare module "babylonjs/States/stencilState" {
  6133. /**
  6134. * @hidden
  6135. **/
  6136. export class _StencilState {
  6137. /** 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 */
  6138. static readonly ALWAYS: number;
  6139. /** Passed to stencilOperation to specify that stencil value must be kept */
  6140. static readonly KEEP: number;
  6141. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6142. static readonly REPLACE: number;
  6143. private _isStencilTestDirty;
  6144. private _isStencilMaskDirty;
  6145. private _isStencilFuncDirty;
  6146. private _isStencilOpDirty;
  6147. private _stencilTest;
  6148. private _stencilMask;
  6149. private _stencilFunc;
  6150. private _stencilFuncRef;
  6151. private _stencilFuncMask;
  6152. private _stencilOpStencilFail;
  6153. private _stencilOpDepthFail;
  6154. private _stencilOpStencilDepthPass;
  6155. readonly isDirty: boolean;
  6156. stencilFunc: number;
  6157. stencilFuncRef: number;
  6158. stencilFuncMask: number;
  6159. stencilOpStencilFail: number;
  6160. stencilOpDepthFail: number;
  6161. stencilOpStencilDepthPass: number;
  6162. stencilMask: number;
  6163. stencilTest: boolean;
  6164. constructor();
  6165. reset(): void;
  6166. apply(gl: WebGLRenderingContext): void;
  6167. }
  6168. }
  6169. declare module "babylonjs/States/index" {
  6170. export * from "babylonjs/States/alphaCullingState";
  6171. export * from "babylonjs/States/depthCullingState";
  6172. export * from "babylonjs/States/stencilState";
  6173. }
  6174. declare module "babylonjs/Instrumentation/timeToken" {
  6175. import { Nullable } from "babylonjs/types";
  6176. /**
  6177. * @hidden
  6178. **/
  6179. export class _TimeToken {
  6180. _startTimeQuery: Nullable<WebGLQuery>;
  6181. _endTimeQuery: Nullable<WebGLQuery>;
  6182. _timeElapsedQuery: Nullable<WebGLQuery>;
  6183. _timeElapsedQueryEnded: boolean;
  6184. }
  6185. }
  6186. declare module "babylonjs/Materials/Textures/internalTexture" {
  6187. import { Observable } from "babylonjs/Misc/observable";
  6188. import { Nullable, int } from "babylonjs/types";
  6189. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6190. import { Engine } from "babylonjs/Engines/engine";
  6191. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6192. /**
  6193. * Class used to store data associated with WebGL texture data for the engine
  6194. * This class should not be used directly
  6195. */
  6196. export class InternalTexture {
  6197. /** hidden */
  6198. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6199. /**
  6200. * The source of the texture data is unknown
  6201. */
  6202. static DATASOURCE_UNKNOWN: number;
  6203. /**
  6204. * Texture data comes from an URL
  6205. */
  6206. static DATASOURCE_URL: number;
  6207. /**
  6208. * Texture data is only used for temporary storage
  6209. */
  6210. static DATASOURCE_TEMP: number;
  6211. /**
  6212. * Texture data comes from raw data (ArrayBuffer)
  6213. */
  6214. static DATASOURCE_RAW: number;
  6215. /**
  6216. * Texture content is dynamic (video or dynamic texture)
  6217. */
  6218. static DATASOURCE_DYNAMIC: number;
  6219. /**
  6220. * Texture content is generated by rendering to it
  6221. */
  6222. static DATASOURCE_RENDERTARGET: number;
  6223. /**
  6224. * Texture content is part of a multi render target process
  6225. */
  6226. static DATASOURCE_MULTIRENDERTARGET: number;
  6227. /**
  6228. * Texture data comes from a cube data file
  6229. */
  6230. static DATASOURCE_CUBE: number;
  6231. /**
  6232. * Texture data comes from a raw cube data
  6233. */
  6234. static DATASOURCE_CUBERAW: number;
  6235. /**
  6236. * Texture data come from a prefiltered cube data file
  6237. */
  6238. static DATASOURCE_CUBEPREFILTERED: number;
  6239. /**
  6240. * Texture content is raw 3D data
  6241. */
  6242. static DATASOURCE_RAW3D: number;
  6243. /**
  6244. * Texture content is a depth texture
  6245. */
  6246. static DATASOURCE_DEPTHTEXTURE: number;
  6247. /**
  6248. * Texture data comes from a raw cube data encoded with RGBD
  6249. */
  6250. static DATASOURCE_CUBERAW_RGBD: number;
  6251. /**
  6252. * Defines if the texture is ready
  6253. */
  6254. isReady: boolean;
  6255. /**
  6256. * Defines if the texture is a cube texture
  6257. */
  6258. isCube: boolean;
  6259. /**
  6260. * Defines if the texture contains 3D data
  6261. */
  6262. is3D: boolean;
  6263. /**
  6264. * Defines if the texture contains multiview data
  6265. */
  6266. isMultiview: boolean;
  6267. /**
  6268. * Gets the URL used to load this texture
  6269. */
  6270. url: string;
  6271. /**
  6272. * Gets the sampling mode of the texture
  6273. */
  6274. samplingMode: number;
  6275. /**
  6276. * Gets a boolean indicating if the texture needs mipmaps generation
  6277. */
  6278. generateMipMaps: boolean;
  6279. /**
  6280. * Gets the number of samples used by the texture (WebGL2+ only)
  6281. */
  6282. samples: number;
  6283. /**
  6284. * Gets the type of the texture (int, float...)
  6285. */
  6286. type: number;
  6287. /**
  6288. * Gets the format of the texture (RGB, RGBA...)
  6289. */
  6290. format: number;
  6291. /**
  6292. * Observable called when the texture is loaded
  6293. */
  6294. onLoadedObservable: Observable<InternalTexture>;
  6295. /**
  6296. * Gets the width of the texture
  6297. */
  6298. width: number;
  6299. /**
  6300. * Gets the height of the texture
  6301. */
  6302. height: number;
  6303. /**
  6304. * Gets the depth of the texture
  6305. */
  6306. depth: number;
  6307. /**
  6308. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6309. */
  6310. baseWidth: number;
  6311. /**
  6312. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6313. */
  6314. baseHeight: number;
  6315. /**
  6316. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6317. */
  6318. baseDepth: number;
  6319. /**
  6320. * Gets a boolean indicating if the texture is inverted on Y axis
  6321. */
  6322. invertY: boolean;
  6323. /** @hidden */
  6324. _invertVScale: boolean;
  6325. /** @hidden */
  6326. _associatedChannel: number;
  6327. /** @hidden */
  6328. _dataSource: number;
  6329. /** @hidden */
  6330. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6331. /** @hidden */
  6332. _bufferView: Nullable<ArrayBufferView>;
  6333. /** @hidden */
  6334. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6335. /** @hidden */
  6336. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6337. /** @hidden */
  6338. _size: number;
  6339. /** @hidden */
  6340. _extension: string;
  6341. /** @hidden */
  6342. _files: Nullable<string[]>;
  6343. /** @hidden */
  6344. _workingCanvas: HTMLCanvasElement;
  6345. /** @hidden */
  6346. _workingContext: CanvasRenderingContext2D;
  6347. /** @hidden */
  6348. _framebuffer: Nullable<WebGLFramebuffer>;
  6349. /** @hidden */
  6350. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6351. /** @hidden */
  6352. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6353. /** @hidden */
  6354. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6355. /** @hidden */
  6356. _attachments: Nullable<number[]>;
  6357. /** @hidden */
  6358. _cachedCoordinatesMode: Nullable<number>;
  6359. /** @hidden */
  6360. _cachedWrapU: Nullable<number>;
  6361. /** @hidden */
  6362. _cachedWrapV: Nullable<number>;
  6363. /** @hidden */
  6364. _cachedWrapR: Nullable<number>;
  6365. /** @hidden */
  6366. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6367. /** @hidden */
  6368. _isDisabled: boolean;
  6369. /** @hidden */
  6370. _compression: Nullable<string>;
  6371. /** @hidden */
  6372. _generateStencilBuffer: boolean;
  6373. /** @hidden */
  6374. _generateDepthBuffer: boolean;
  6375. /** @hidden */
  6376. _comparisonFunction: number;
  6377. /** @hidden */
  6378. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6379. /** @hidden */
  6380. _lodGenerationScale: number;
  6381. /** @hidden */
  6382. _lodGenerationOffset: number;
  6383. /** @hidden */
  6384. _colorTextureArray: Nullable<WebGLTexture>;
  6385. /** @hidden */
  6386. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6387. /** @hidden */
  6388. _lodTextureHigh: BaseTexture;
  6389. /** @hidden */
  6390. _lodTextureMid: BaseTexture;
  6391. /** @hidden */
  6392. _lodTextureLow: BaseTexture;
  6393. /** @hidden */
  6394. _isRGBD: boolean;
  6395. /** @hidden */
  6396. _webGLTexture: Nullable<WebGLTexture>;
  6397. /** @hidden */
  6398. _references: number;
  6399. private _engine;
  6400. /**
  6401. * Gets the Engine the texture belongs to.
  6402. * @returns The babylon engine
  6403. */
  6404. getEngine(): Engine;
  6405. /**
  6406. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6407. */
  6408. readonly dataSource: number;
  6409. /**
  6410. * Creates a new InternalTexture
  6411. * @param engine defines the engine to use
  6412. * @param dataSource defines the type of data that will be used
  6413. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6414. */
  6415. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6416. /**
  6417. * Increments the number of references (ie. the number of Texture that point to it)
  6418. */
  6419. incrementReferences(): void;
  6420. /**
  6421. * Change the size of the texture (not the size of the content)
  6422. * @param width defines the new width
  6423. * @param height defines the new height
  6424. * @param depth defines the new depth (1 by default)
  6425. */
  6426. updateSize(width: int, height: int, depth?: int): void;
  6427. /** @hidden */
  6428. _rebuild(): void;
  6429. /** @hidden */
  6430. _swapAndDie(target: InternalTexture): void;
  6431. /**
  6432. * Dispose the current allocated resources
  6433. */
  6434. dispose(): void;
  6435. }
  6436. }
  6437. declare module "babylonjs/Animations/easing" {
  6438. /**
  6439. * This represents the main contract an easing function should follow.
  6440. * Easing functions are used throughout the animation system.
  6441. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6442. */
  6443. export interface IEasingFunction {
  6444. /**
  6445. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6446. * of the easing function.
  6447. * The link below provides some of the most common examples of easing functions.
  6448. * @see https://easings.net/
  6449. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6450. * @returns the corresponding value on the curve defined by the easing function
  6451. */
  6452. ease(gradient: number): number;
  6453. }
  6454. /**
  6455. * Base class used for every default easing function.
  6456. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6457. */
  6458. export class EasingFunction implements IEasingFunction {
  6459. /**
  6460. * Interpolation follows the mathematical formula associated with the easing function.
  6461. */
  6462. static readonly EASINGMODE_EASEIN: number;
  6463. /**
  6464. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6465. */
  6466. static readonly EASINGMODE_EASEOUT: number;
  6467. /**
  6468. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6469. */
  6470. static readonly EASINGMODE_EASEINOUT: number;
  6471. private _easingMode;
  6472. /**
  6473. * Sets the easing mode of the current function.
  6474. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6475. */
  6476. setEasingMode(easingMode: number): void;
  6477. /**
  6478. * Gets the current easing mode.
  6479. * @returns the easing mode
  6480. */
  6481. getEasingMode(): number;
  6482. /**
  6483. * @hidden
  6484. */
  6485. easeInCore(gradient: number): number;
  6486. /**
  6487. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6488. * of the easing function.
  6489. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6490. * @returns the corresponding value on the curve defined by the easing function
  6491. */
  6492. ease(gradient: number): number;
  6493. }
  6494. /**
  6495. * Easing function with a circle shape (see link below).
  6496. * @see https://easings.net/#easeInCirc
  6497. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6498. */
  6499. export class CircleEase extends EasingFunction implements IEasingFunction {
  6500. /** @hidden */
  6501. easeInCore(gradient: number): number;
  6502. }
  6503. /**
  6504. * Easing function with a ease back shape (see link below).
  6505. * @see https://easings.net/#easeInBack
  6506. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6507. */
  6508. export class BackEase extends EasingFunction implements IEasingFunction {
  6509. /** Defines the amplitude of the function */
  6510. amplitude: number;
  6511. /**
  6512. * Instantiates a back ease easing
  6513. * @see https://easings.net/#easeInBack
  6514. * @param amplitude Defines the amplitude of the function
  6515. */
  6516. constructor(
  6517. /** Defines the amplitude of the function */
  6518. amplitude?: number);
  6519. /** @hidden */
  6520. easeInCore(gradient: number): number;
  6521. }
  6522. /**
  6523. * Easing function with a bouncing shape (see link below).
  6524. * @see https://easings.net/#easeInBounce
  6525. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6526. */
  6527. export class BounceEase extends EasingFunction implements IEasingFunction {
  6528. /** Defines the number of bounces */
  6529. bounces: number;
  6530. /** Defines the amplitude of the bounce */
  6531. bounciness: number;
  6532. /**
  6533. * Instantiates a bounce easing
  6534. * @see https://easings.net/#easeInBounce
  6535. * @param bounces Defines the number of bounces
  6536. * @param bounciness Defines the amplitude of the bounce
  6537. */
  6538. constructor(
  6539. /** Defines the number of bounces */
  6540. bounces?: number,
  6541. /** Defines the amplitude of the bounce */
  6542. bounciness?: number);
  6543. /** @hidden */
  6544. easeInCore(gradient: number): number;
  6545. }
  6546. /**
  6547. * Easing function with a power of 3 shape (see link below).
  6548. * @see https://easings.net/#easeInCubic
  6549. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6550. */
  6551. export class CubicEase extends EasingFunction implements IEasingFunction {
  6552. /** @hidden */
  6553. easeInCore(gradient: number): number;
  6554. }
  6555. /**
  6556. * Easing function with an elastic shape (see link below).
  6557. * @see https://easings.net/#easeInElastic
  6558. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6559. */
  6560. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6561. /** Defines the number of oscillations*/
  6562. oscillations: number;
  6563. /** Defines the amplitude of the oscillations*/
  6564. springiness: number;
  6565. /**
  6566. * Instantiates an elastic easing function
  6567. * @see https://easings.net/#easeInElastic
  6568. * @param oscillations Defines the number of oscillations
  6569. * @param springiness Defines the amplitude of the oscillations
  6570. */
  6571. constructor(
  6572. /** Defines the number of oscillations*/
  6573. oscillations?: number,
  6574. /** Defines the amplitude of the oscillations*/
  6575. springiness?: number);
  6576. /** @hidden */
  6577. easeInCore(gradient: number): number;
  6578. }
  6579. /**
  6580. * Easing function with an exponential shape (see link below).
  6581. * @see https://easings.net/#easeInExpo
  6582. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6583. */
  6584. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6585. /** Defines the exponent of the function */
  6586. exponent: number;
  6587. /**
  6588. * Instantiates an exponential easing function
  6589. * @see https://easings.net/#easeInExpo
  6590. * @param exponent Defines the exponent of the function
  6591. */
  6592. constructor(
  6593. /** Defines the exponent of the function */
  6594. exponent?: number);
  6595. /** @hidden */
  6596. easeInCore(gradient: number): number;
  6597. }
  6598. /**
  6599. * Easing function with a power shape (see link below).
  6600. * @see https://easings.net/#easeInQuad
  6601. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6602. */
  6603. export class PowerEase extends EasingFunction implements IEasingFunction {
  6604. /** Defines the power of the function */
  6605. power: number;
  6606. /**
  6607. * Instantiates an power base easing function
  6608. * @see https://easings.net/#easeInQuad
  6609. * @param power Defines the power of the function
  6610. */
  6611. constructor(
  6612. /** Defines the power of the function */
  6613. power?: number);
  6614. /** @hidden */
  6615. easeInCore(gradient: number): number;
  6616. }
  6617. /**
  6618. * Easing function with a power of 2 shape (see link below).
  6619. * @see https://easings.net/#easeInQuad
  6620. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6621. */
  6622. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6623. /** @hidden */
  6624. easeInCore(gradient: number): number;
  6625. }
  6626. /**
  6627. * Easing function with a power of 4 shape (see link below).
  6628. * @see https://easings.net/#easeInQuart
  6629. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6630. */
  6631. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6632. /** @hidden */
  6633. easeInCore(gradient: number): number;
  6634. }
  6635. /**
  6636. * Easing function with a power of 5 shape (see link below).
  6637. * @see https://easings.net/#easeInQuint
  6638. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6639. */
  6640. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6641. /** @hidden */
  6642. easeInCore(gradient: number): number;
  6643. }
  6644. /**
  6645. * Easing function with a sin shape (see link below).
  6646. * @see https://easings.net/#easeInSine
  6647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6648. */
  6649. export class SineEase extends EasingFunction implements IEasingFunction {
  6650. /** @hidden */
  6651. easeInCore(gradient: number): number;
  6652. }
  6653. /**
  6654. * Easing function with a bezier shape (see link below).
  6655. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6656. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6657. */
  6658. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6659. /** Defines the x component of the start tangent in the bezier curve */
  6660. x1: number;
  6661. /** Defines the y component of the start tangent in the bezier curve */
  6662. y1: number;
  6663. /** Defines the x component of the end tangent in the bezier curve */
  6664. x2: number;
  6665. /** Defines the y component of the end tangent in the bezier curve */
  6666. y2: number;
  6667. /**
  6668. * Instantiates a bezier function
  6669. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6670. * @param x1 Defines the x component of the start tangent in the bezier curve
  6671. * @param y1 Defines the y component of the start tangent in the bezier curve
  6672. * @param x2 Defines the x component of the end tangent in the bezier curve
  6673. * @param y2 Defines the y component of the end tangent in the bezier curve
  6674. */
  6675. constructor(
  6676. /** Defines the x component of the start tangent in the bezier curve */
  6677. x1?: number,
  6678. /** Defines the y component of the start tangent in the bezier curve */
  6679. y1?: number,
  6680. /** Defines the x component of the end tangent in the bezier curve */
  6681. x2?: number,
  6682. /** Defines the y component of the end tangent in the bezier curve */
  6683. y2?: number);
  6684. /** @hidden */
  6685. easeInCore(gradient: number): number;
  6686. }
  6687. }
  6688. declare module "babylonjs/Animations/animationKey" {
  6689. /**
  6690. * Defines an interface which represents an animation key frame
  6691. */
  6692. export interface IAnimationKey {
  6693. /**
  6694. * Frame of the key frame
  6695. */
  6696. frame: number;
  6697. /**
  6698. * Value at the specifies key frame
  6699. */
  6700. value: any;
  6701. /**
  6702. * The input tangent for the cubic hermite spline
  6703. */
  6704. inTangent?: any;
  6705. /**
  6706. * The output tangent for the cubic hermite spline
  6707. */
  6708. outTangent?: any;
  6709. /**
  6710. * The animation interpolation type
  6711. */
  6712. interpolation?: AnimationKeyInterpolation;
  6713. }
  6714. /**
  6715. * Enum for the animation key frame interpolation type
  6716. */
  6717. export enum AnimationKeyInterpolation {
  6718. /**
  6719. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6720. */
  6721. STEP = 1
  6722. }
  6723. }
  6724. declare module "babylonjs/Animations/animationRange" {
  6725. /**
  6726. * Represents the range of an animation
  6727. */
  6728. export class AnimationRange {
  6729. /**The name of the animation range**/
  6730. name: string;
  6731. /**The starting frame of the animation */
  6732. from: number;
  6733. /**The ending frame of the animation*/
  6734. to: number;
  6735. /**
  6736. * Initializes the range of an animation
  6737. * @param name The name of the animation range
  6738. * @param from The starting frame of the animation
  6739. * @param to The ending frame of the animation
  6740. */
  6741. constructor(
  6742. /**The name of the animation range**/
  6743. name: string,
  6744. /**The starting frame of the animation */
  6745. from: number,
  6746. /**The ending frame of the animation*/
  6747. to: number);
  6748. /**
  6749. * Makes a copy of the animation range
  6750. * @returns A copy of the animation range
  6751. */
  6752. clone(): AnimationRange;
  6753. }
  6754. }
  6755. declare module "babylonjs/Animations/animationEvent" {
  6756. /**
  6757. * Composed of a frame, and an action function
  6758. */
  6759. export class AnimationEvent {
  6760. /** The frame for which the event is triggered **/
  6761. frame: number;
  6762. /** The event to perform when triggered **/
  6763. action: (currentFrame: number) => void;
  6764. /** Specifies if the event should be triggered only once**/
  6765. onlyOnce?: boolean | undefined;
  6766. /**
  6767. * Specifies if the animation event is done
  6768. */
  6769. isDone: boolean;
  6770. /**
  6771. * Initializes the animation event
  6772. * @param frame The frame for which the event is triggered
  6773. * @param action The event to perform when triggered
  6774. * @param onlyOnce Specifies if the event should be triggered only once
  6775. */
  6776. constructor(
  6777. /** The frame for which the event is triggered **/
  6778. frame: number,
  6779. /** The event to perform when triggered **/
  6780. action: (currentFrame: number) => void,
  6781. /** Specifies if the event should be triggered only once**/
  6782. onlyOnce?: boolean | undefined);
  6783. /** @hidden */
  6784. _clone(): AnimationEvent;
  6785. }
  6786. }
  6787. declare module "babylonjs/Behaviors/behavior" {
  6788. import { Nullable } from "babylonjs/types";
  6789. /**
  6790. * Interface used to define a behavior
  6791. */
  6792. export interface Behavior<T> {
  6793. /** gets or sets behavior's name */
  6794. name: string;
  6795. /**
  6796. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6797. */
  6798. init(): void;
  6799. /**
  6800. * Called when the behavior is attached to a target
  6801. * @param target defines the target where the behavior is attached to
  6802. */
  6803. attach(target: T): void;
  6804. /**
  6805. * Called when the behavior is detached from its target
  6806. */
  6807. detach(): void;
  6808. }
  6809. /**
  6810. * Interface implemented by classes supporting behaviors
  6811. */
  6812. export interface IBehaviorAware<T> {
  6813. /**
  6814. * Attach a behavior
  6815. * @param behavior defines the behavior to attach
  6816. * @returns the current host
  6817. */
  6818. addBehavior(behavior: Behavior<T>): T;
  6819. /**
  6820. * Remove a behavior from the current object
  6821. * @param behavior defines the behavior to detach
  6822. * @returns the current host
  6823. */
  6824. removeBehavior(behavior: Behavior<T>): T;
  6825. /**
  6826. * Gets a behavior using its name to search
  6827. * @param name defines the name to search
  6828. * @returns the behavior or null if not found
  6829. */
  6830. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6831. }
  6832. }
  6833. declare module "babylonjs/Collisions/intersectionInfo" {
  6834. import { Nullable } from "babylonjs/types";
  6835. /**
  6836. * @hidden
  6837. */
  6838. export class IntersectionInfo {
  6839. bu: Nullable<number>;
  6840. bv: Nullable<number>;
  6841. distance: number;
  6842. faceId: number;
  6843. subMeshId: number;
  6844. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6845. }
  6846. }
  6847. declare module "babylonjs/Culling/boundingSphere" {
  6848. import { DeepImmutable } from "babylonjs/types";
  6849. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6850. /**
  6851. * Class used to store bounding sphere information
  6852. */
  6853. export class BoundingSphere {
  6854. /**
  6855. * Gets the center of the bounding sphere in local space
  6856. */
  6857. readonly center: Vector3;
  6858. /**
  6859. * Radius of the bounding sphere in local space
  6860. */
  6861. radius: number;
  6862. /**
  6863. * Gets the center of the bounding sphere in world space
  6864. */
  6865. readonly centerWorld: Vector3;
  6866. /**
  6867. * Radius of the bounding sphere in world space
  6868. */
  6869. radiusWorld: number;
  6870. /**
  6871. * Gets the minimum vector in local space
  6872. */
  6873. readonly minimum: Vector3;
  6874. /**
  6875. * Gets the maximum vector in local space
  6876. */
  6877. readonly maximum: Vector3;
  6878. private _worldMatrix;
  6879. private static readonly TmpVector3;
  6880. /**
  6881. * Creates a new bounding sphere
  6882. * @param min defines the minimum vector (in local space)
  6883. * @param max defines the maximum vector (in local space)
  6884. * @param worldMatrix defines the new world matrix
  6885. */
  6886. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6887. /**
  6888. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6889. * @param min defines the new minimum vector (in local space)
  6890. * @param max defines the new maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6894. /**
  6895. * Scale the current bounding sphere by applying a scale factor
  6896. * @param factor defines the scale factor to apply
  6897. * @returns the current bounding box
  6898. */
  6899. scale(factor: number): BoundingSphere;
  6900. /**
  6901. * Gets the world matrix of the bounding box
  6902. * @returns a matrix
  6903. */
  6904. getWorldMatrix(): DeepImmutable<Matrix>;
  6905. /** @hidden */
  6906. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6907. /**
  6908. * Tests if the bounding sphere is intersecting the frustum planes
  6909. * @param frustumPlanes defines the frustum planes to test
  6910. * @returns true if there is an intersection
  6911. */
  6912. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6913. /**
  6914. * Tests if the bounding sphere center is in between the frustum planes.
  6915. * Used for optimistic fast inclusion.
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @returns true if the sphere center is in between the frustum planes
  6918. */
  6919. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if a point is inside the bounding sphere
  6922. * @param point defines the point to test
  6923. * @returns true if the point is inside the bounding sphere
  6924. */
  6925. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6926. /**
  6927. * Checks if two sphere intersct
  6928. * @param sphere0 sphere 0
  6929. * @param sphere1 sphere 1
  6930. * @returns true if the speres intersect
  6931. */
  6932. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6933. }
  6934. }
  6935. declare module "babylonjs/Culling/boundingBox" {
  6936. import { DeepImmutable } from "babylonjs/types";
  6937. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6938. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6939. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6940. /**
  6941. * Class used to store bounding box information
  6942. */
  6943. export class BoundingBox implements ICullable {
  6944. /**
  6945. * Gets the 8 vectors representing the bounding box in local space
  6946. */
  6947. readonly vectors: Vector3[];
  6948. /**
  6949. * Gets the center of the bounding box in local space
  6950. */
  6951. readonly center: Vector3;
  6952. /**
  6953. * Gets the center of the bounding box in world space
  6954. */
  6955. readonly centerWorld: Vector3;
  6956. /**
  6957. * Gets the extend size in local space
  6958. */
  6959. readonly extendSize: Vector3;
  6960. /**
  6961. * Gets the extend size in world space
  6962. */
  6963. readonly extendSizeWorld: Vector3;
  6964. /**
  6965. * Gets the OBB (object bounding box) directions
  6966. */
  6967. readonly directions: Vector3[];
  6968. /**
  6969. * Gets the 8 vectors representing the bounding box in world space
  6970. */
  6971. readonly vectorsWorld: Vector3[];
  6972. /**
  6973. * Gets the minimum vector in world space
  6974. */
  6975. readonly minimumWorld: Vector3;
  6976. /**
  6977. * Gets the maximum vector in world space
  6978. */
  6979. readonly maximumWorld: Vector3;
  6980. /**
  6981. * Gets the minimum vector in local space
  6982. */
  6983. readonly minimum: Vector3;
  6984. /**
  6985. * Gets the maximum vector in local space
  6986. */
  6987. readonly maximum: Vector3;
  6988. private _worldMatrix;
  6989. private static readonly TmpVector3;
  6990. /**
  6991. * @hidden
  6992. */
  6993. _tag: number;
  6994. /**
  6995. * Creates a new bounding box
  6996. * @param min defines the minimum vector (in local space)
  6997. * @param max defines the maximum vector (in local space)
  6998. * @param worldMatrix defines the new world matrix
  6999. */
  7000. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7001. /**
  7002. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7003. * @param min defines the new minimum vector (in local space)
  7004. * @param max defines the new maximum vector (in local space)
  7005. * @param worldMatrix defines the new world matrix
  7006. */
  7007. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7008. /**
  7009. * Scale the current bounding box by applying a scale factor
  7010. * @param factor defines the scale factor to apply
  7011. * @returns the current bounding box
  7012. */
  7013. scale(factor: number): BoundingBox;
  7014. /**
  7015. * Gets the world matrix of the bounding box
  7016. * @returns a matrix
  7017. */
  7018. getWorldMatrix(): DeepImmutable<Matrix>;
  7019. /** @hidden */
  7020. _update(world: DeepImmutable<Matrix>): void;
  7021. /**
  7022. * Tests if the bounding box is intersecting the frustum planes
  7023. * @param frustumPlanes defines the frustum planes to test
  7024. * @returns true if there is an intersection
  7025. */
  7026. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7027. /**
  7028. * Tests if the bounding box is entirely inside the frustum planes
  7029. * @param frustumPlanes defines the frustum planes to test
  7030. * @returns true if there is an inclusion
  7031. */
  7032. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7033. /**
  7034. * Tests if a point is inside the bounding box
  7035. * @param point defines the point to test
  7036. * @returns true if the point is inside the bounding box
  7037. */
  7038. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7039. /**
  7040. * Tests if the bounding box intersects with a bounding sphere
  7041. * @param sphere defines the sphere to test
  7042. * @returns true if there is an intersection
  7043. */
  7044. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7045. /**
  7046. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7047. * @param min defines the min vector to use
  7048. * @param max defines the max vector to use
  7049. * @returns true if there is an intersection
  7050. */
  7051. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7052. /**
  7053. * Tests if two bounding boxes are intersections
  7054. * @param box0 defines the first box to test
  7055. * @param box1 defines the second box to test
  7056. * @returns true if there is an intersection
  7057. */
  7058. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7059. /**
  7060. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7061. * @param minPoint defines the minimum vector of the bounding box
  7062. * @param maxPoint defines the maximum vector of the bounding box
  7063. * @param sphereCenter defines the sphere center
  7064. * @param sphereRadius defines the sphere radius
  7065. * @returns true if there is an intersection
  7066. */
  7067. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7068. /**
  7069. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7070. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7071. * @param frustumPlanes defines the frustum planes to test
  7072. * @return true if there is an inclusion
  7073. */
  7074. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7075. /**
  7076. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7077. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7078. * @param frustumPlanes defines the frustum planes to test
  7079. * @return true if there is an intersection
  7080. */
  7081. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7082. }
  7083. }
  7084. declare module "babylonjs/Collisions/collider" {
  7085. import { Nullable, IndicesArray } from "babylonjs/types";
  7086. import { Vector3, Plane } from "babylonjs/Maths/math";
  7087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7088. /** @hidden */
  7089. export class Collider {
  7090. /** Define if a collision was found */
  7091. collisionFound: boolean;
  7092. /**
  7093. * Define last intersection point in local space
  7094. */
  7095. intersectionPoint: Vector3;
  7096. /**
  7097. * Define last collided mesh
  7098. */
  7099. collidedMesh: Nullable<AbstractMesh>;
  7100. private _collisionPoint;
  7101. private _planeIntersectionPoint;
  7102. private _tempVector;
  7103. private _tempVector2;
  7104. private _tempVector3;
  7105. private _tempVector4;
  7106. private _edge;
  7107. private _baseToVertex;
  7108. private _destinationPoint;
  7109. private _slidePlaneNormal;
  7110. private _displacementVector;
  7111. /** @hidden */
  7112. _radius: Vector3;
  7113. /** @hidden */
  7114. _retry: number;
  7115. private _velocity;
  7116. private _basePoint;
  7117. private _epsilon;
  7118. /** @hidden */
  7119. _velocityWorldLength: number;
  7120. /** @hidden */
  7121. _basePointWorld: Vector3;
  7122. private _velocityWorld;
  7123. private _normalizedVelocity;
  7124. /** @hidden */
  7125. _initialVelocity: Vector3;
  7126. /** @hidden */
  7127. _initialPosition: Vector3;
  7128. private _nearestDistance;
  7129. private _collisionMask;
  7130. collisionMask: number;
  7131. /**
  7132. * Gets the plane normal used to compute the sliding response (in local space)
  7133. */
  7134. readonly slidePlaneNormal: Vector3;
  7135. /** @hidden */
  7136. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7137. /** @hidden */
  7138. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7139. /** @hidden */
  7140. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7141. /** @hidden */
  7142. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7143. /** @hidden */
  7144. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7145. /** @hidden */
  7146. _getResponse(pos: Vector3, vel: Vector3): void;
  7147. }
  7148. }
  7149. declare module "babylonjs/Culling/boundingInfo" {
  7150. import { DeepImmutable } from "babylonjs/types";
  7151. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7152. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7153. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7154. import { Collider } from "babylonjs/Collisions/collider";
  7155. /**
  7156. * Interface for cullable objects
  7157. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7158. */
  7159. export interface ICullable {
  7160. /**
  7161. * Checks if the object or part of the object is in the frustum
  7162. * @param frustumPlanes Camera near/planes
  7163. * @returns true if the object is in frustum otherwise false
  7164. */
  7165. isInFrustum(frustumPlanes: Plane[]): boolean;
  7166. /**
  7167. * Checks if a cullable object (mesh...) is in the camera frustum
  7168. * Unlike isInFrustum this cheks the full bounding box
  7169. * @param frustumPlanes Camera near/planes
  7170. * @returns true if the object is in frustum otherwise false
  7171. */
  7172. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7173. }
  7174. /**
  7175. * Info for a bounding data of a mesh
  7176. */
  7177. export class BoundingInfo implements ICullable {
  7178. /**
  7179. * Bounding box for the mesh
  7180. */
  7181. readonly boundingBox: BoundingBox;
  7182. /**
  7183. * Bounding sphere for the mesh
  7184. */
  7185. readonly boundingSphere: BoundingSphere;
  7186. private _isLocked;
  7187. private static readonly TmpVector3;
  7188. /**
  7189. * Constructs bounding info
  7190. * @param minimum min vector of the bounding box/sphere
  7191. * @param maximum max vector of the bounding box/sphere
  7192. * @param worldMatrix defines the new world matrix
  7193. */
  7194. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7195. /**
  7196. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7197. * @param min defines the new minimum vector (in local space)
  7198. * @param max defines the new maximum vector (in local space)
  7199. * @param worldMatrix defines the new world matrix
  7200. */
  7201. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7202. /**
  7203. * min vector of the bounding box/sphere
  7204. */
  7205. readonly minimum: Vector3;
  7206. /**
  7207. * max vector of the bounding box/sphere
  7208. */
  7209. readonly maximum: Vector3;
  7210. /**
  7211. * If the info is locked and won't be updated to avoid perf overhead
  7212. */
  7213. isLocked: boolean;
  7214. /**
  7215. * Updates the bounding sphere and box
  7216. * @param world world matrix to be used to update
  7217. */
  7218. update(world: DeepImmutable<Matrix>): void;
  7219. /**
  7220. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7221. * @param center New center of the bounding info
  7222. * @param extend New extend of the bounding info
  7223. * @returns the current bounding info
  7224. */
  7225. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7226. /**
  7227. * Scale the current bounding info by applying a scale factor
  7228. * @param factor defines the scale factor to apply
  7229. * @returns the current bounding info
  7230. */
  7231. scale(factor: number): BoundingInfo;
  7232. /**
  7233. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7234. * @param frustumPlanes defines the frustum to test
  7235. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7236. * @returns true if the bounding info is in the frustum planes
  7237. */
  7238. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7239. /**
  7240. * Gets the world distance between the min and max points of the bounding box
  7241. */
  7242. readonly diagonalLength: number;
  7243. /**
  7244. * Checks if a cullable object (mesh...) is in the camera frustum
  7245. * Unlike isInFrustum this cheks the full bounding box
  7246. * @param frustumPlanes Camera near/planes
  7247. * @returns true if the object is in frustum otherwise false
  7248. */
  7249. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7250. /** @hidden */
  7251. _checkCollision(collider: Collider): boolean;
  7252. /**
  7253. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7254. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7255. * @param point the point to check intersection with
  7256. * @returns if the point intersects
  7257. */
  7258. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7259. /**
  7260. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7261. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7262. * @param boundingInfo the bounding info to check intersection with
  7263. * @param precise if the intersection should be done using OBB
  7264. * @returns if the bounding info intersects
  7265. */
  7266. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7267. }
  7268. }
  7269. declare module "babylonjs/Misc/smartArray" {
  7270. /**
  7271. * Defines an array and its length.
  7272. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7273. */
  7274. export interface ISmartArrayLike<T> {
  7275. /**
  7276. * The data of the array.
  7277. */
  7278. data: Array<T>;
  7279. /**
  7280. * The active length of the array.
  7281. */
  7282. length: number;
  7283. }
  7284. /**
  7285. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7286. */
  7287. export class SmartArray<T> implements ISmartArrayLike<T> {
  7288. /**
  7289. * The full set of data from the array.
  7290. */
  7291. data: Array<T>;
  7292. /**
  7293. * The active length of the array.
  7294. */
  7295. length: number;
  7296. protected _id: number;
  7297. /**
  7298. * Instantiates a Smart Array.
  7299. * @param capacity defines the default capacity of the array.
  7300. */
  7301. constructor(capacity: number);
  7302. /**
  7303. * Pushes a value at the end of the active data.
  7304. * @param value defines the object to push in the array.
  7305. */
  7306. push(value: T): void;
  7307. /**
  7308. * Iterates over the active data and apply the lambda to them.
  7309. * @param func defines the action to apply on each value.
  7310. */
  7311. forEach(func: (content: T) => void): void;
  7312. /**
  7313. * Sorts the full sets of data.
  7314. * @param compareFn defines the comparison function to apply.
  7315. */
  7316. sort(compareFn: (a: T, b: T) => number): void;
  7317. /**
  7318. * Resets the active data to an empty array.
  7319. */
  7320. reset(): void;
  7321. /**
  7322. * Releases all the data from the array as well as the array.
  7323. */
  7324. dispose(): void;
  7325. /**
  7326. * Concats the active data with a given array.
  7327. * @param array defines the data to concatenate with.
  7328. */
  7329. concat(array: any): void;
  7330. /**
  7331. * Returns the position of a value in the active data.
  7332. * @param value defines the value to find the index for
  7333. * @returns the index if found in the active data otherwise -1
  7334. */
  7335. indexOf(value: T): number;
  7336. /**
  7337. * Returns whether an element is part of the active data.
  7338. * @param value defines the value to look for
  7339. * @returns true if found in the active data otherwise false
  7340. */
  7341. contains(value: T): boolean;
  7342. private static _GlobalId;
  7343. }
  7344. /**
  7345. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7346. * The data in this array can only be present once
  7347. */
  7348. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7349. private _duplicateId;
  7350. /**
  7351. * Pushes a value at the end of the active data.
  7352. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7353. * @param value defines the object to push in the array.
  7354. */
  7355. push(value: T): void;
  7356. /**
  7357. * Pushes a value at the end of the active data.
  7358. * If the data is already present, it won t be added again
  7359. * @param value defines the object to push in the array.
  7360. * @returns true if added false if it was already present
  7361. */
  7362. pushNoDuplicate(value: T): boolean;
  7363. /**
  7364. * Resets the active data to an empty array.
  7365. */
  7366. reset(): void;
  7367. /**
  7368. * Concats the active data with a given array.
  7369. * This ensures no dupplicate will be present in the result.
  7370. * @param array defines the data to concatenate with.
  7371. */
  7372. concatWithNoDuplicate(array: any): void;
  7373. }
  7374. }
  7375. declare module "babylonjs/Materials/multiMaterial" {
  7376. import { Nullable } from "babylonjs/types";
  7377. import { Scene } from "babylonjs/scene";
  7378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7379. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7380. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7381. import { Material } from "babylonjs/Materials/material";
  7382. /**
  7383. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7384. * separate meshes. This can be use to improve performances.
  7385. * @see http://doc.babylonjs.com/how_to/multi_materials
  7386. */
  7387. export class MultiMaterial extends Material {
  7388. private _subMaterials;
  7389. /**
  7390. * Gets or Sets the list of Materials used within the multi material.
  7391. * They need to be ordered according to the submeshes order in the associated mesh
  7392. */
  7393. subMaterials: Nullable<Material>[];
  7394. /**
  7395. * Function used to align with Node.getChildren()
  7396. * @returns the list of Materials used within the multi material
  7397. */
  7398. getChildren(): Nullable<Material>[];
  7399. /**
  7400. * Instantiates a new Multi Material
  7401. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7402. * separate meshes. This can be use to improve performances.
  7403. * @see http://doc.babylonjs.com/how_to/multi_materials
  7404. * @param name Define the name in the scene
  7405. * @param scene Define the scene the material belongs to
  7406. */
  7407. constructor(name: string, scene: Scene);
  7408. private _hookArray;
  7409. /**
  7410. * Get one of the submaterial by its index in the submaterials array
  7411. * @param index The index to look the sub material at
  7412. * @returns The Material if the index has been defined
  7413. */
  7414. getSubMaterial(index: number): Nullable<Material>;
  7415. /**
  7416. * Get the list of active textures for the whole sub materials list.
  7417. * @returns All the textures that will be used during the rendering
  7418. */
  7419. getActiveTextures(): BaseTexture[];
  7420. /**
  7421. * Gets the current class name of the material e.g. "MultiMaterial"
  7422. * Mainly use in serialization.
  7423. * @returns the class name
  7424. */
  7425. getClassName(): string;
  7426. /**
  7427. * Checks if the material is ready to render the requested sub mesh
  7428. * @param mesh Define the mesh the submesh belongs to
  7429. * @param subMesh Define the sub mesh to look readyness for
  7430. * @param useInstances Define whether or not the material is used with instances
  7431. * @returns true if ready, otherwise false
  7432. */
  7433. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7434. /**
  7435. * Clones the current material and its related sub materials
  7436. * @param name Define the name of the newly cloned material
  7437. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7438. * @returns the cloned material
  7439. */
  7440. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7441. /**
  7442. * Serializes the materials into a JSON representation.
  7443. * @returns the JSON representation
  7444. */
  7445. serialize(): any;
  7446. /**
  7447. * Dispose the material and release its associated resources
  7448. * @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)
  7449. * @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)
  7450. * @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)
  7451. */
  7452. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7453. /**
  7454. * Creates a MultiMaterial from parsed MultiMaterial data.
  7455. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7456. * @param scene defines the hosting scene
  7457. * @returns a new MultiMaterial
  7458. */
  7459. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7460. }
  7461. }
  7462. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7463. /**
  7464. * Class used to represent data loading progression
  7465. */
  7466. export class SceneLoaderFlags {
  7467. private static _ForceFullSceneLoadingForIncremental;
  7468. private static _ShowLoadingScreen;
  7469. private static _CleanBoneMatrixWeights;
  7470. private static _loggingLevel;
  7471. /**
  7472. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7473. */
  7474. static ForceFullSceneLoadingForIncremental: boolean;
  7475. /**
  7476. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7477. */
  7478. static ShowLoadingScreen: boolean;
  7479. /**
  7480. * Defines the current logging level (while loading the scene)
  7481. * @ignorenaming
  7482. */
  7483. static loggingLevel: number;
  7484. /**
  7485. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7486. */
  7487. static CleanBoneMatrixWeights: boolean;
  7488. }
  7489. }
  7490. declare module "babylonjs/Meshes/transformNode" {
  7491. import { DeepImmutable } from "babylonjs/types";
  7492. import { Observable } from "babylonjs/Misc/observable";
  7493. import { Nullable } from "babylonjs/types";
  7494. import { Camera } from "babylonjs/Cameras/camera";
  7495. import { Scene } from "babylonjs/scene";
  7496. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7497. import { Node } from "babylonjs/node";
  7498. import { Bone } from "babylonjs/Bones/bone";
  7499. /**
  7500. * 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.
  7501. * @see https://doc.babylonjs.com/how_to/transformnode
  7502. */
  7503. export class TransformNode extends Node {
  7504. /**
  7505. * Object will not rotate to face the camera
  7506. */
  7507. static BILLBOARDMODE_NONE: number;
  7508. /**
  7509. * Object will rotate to face the camera but only on the x axis
  7510. */
  7511. static BILLBOARDMODE_X: number;
  7512. /**
  7513. * Object will rotate to face the camera but only on the y axis
  7514. */
  7515. static BILLBOARDMODE_Y: number;
  7516. /**
  7517. * Object will rotate to face the camera but only on the z axis
  7518. */
  7519. static BILLBOARDMODE_Z: number;
  7520. /**
  7521. * Object will rotate to face the camera
  7522. */
  7523. static BILLBOARDMODE_ALL: number;
  7524. private _forward;
  7525. private _forwardInverted;
  7526. private _up;
  7527. private _right;
  7528. private _rightInverted;
  7529. private _position;
  7530. private _rotation;
  7531. private _rotationQuaternion;
  7532. protected _scaling: Vector3;
  7533. protected _isDirty: boolean;
  7534. private _transformToBoneReferal;
  7535. /**
  7536. * Set the billboard mode. Default is 0.
  7537. *
  7538. * | Value | Type | Description |
  7539. * | --- | --- | --- |
  7540. * | 0 | BILLBOARDMODE_NONE | |
  7541. * | 1 | BILLBOARDMODE_X | |
  7542. * | 2 | BILLBOARDMODE_Y | |
  7543. * | 4 | BILLBOARDMODE_Z | |
  7544. * | 7 | BILLBOARDMODE_ALL | |
  7545. *
  7546. */
  7547. billboardMode: number;
  7548. /**
  7549. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7550. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7551. */
  7552. preserveParentRotationForBillboard: boolean;
  7553. /**
  7554. * 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
  7555. */
  7556. scalingDeterminant: number;
  7557. /**
  7558. * Sets the distance of the object to max, often used by skybox
  7559. */
  7560. infiniteDistance: boolean;
  7561. /**
  7562. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7563. * By default the system will update normals to compensate
  7564. */
  7565. ignoreNonUniformScaling: boolean;
  7566. /** @hidden */
  7567. _poseMatrix: Matrix;
  7568. /** @hidden */
  7569. _localMatrix: Matrix;
  7570. private _absolutePosition;
  7571. private _pivotMatrix;
  7572. private _pivotMatrixInverse;
  7573. protected _postMultiplyPivotMatrix: boolean;
  7574. private _tempMatrix;
  7575. private _tempMatrix2;
  7576. protected _isWorldMatrixFrozen: boolean;
  7577. /** @hidden */
  7578. _indexInSceneTransformNodesArray: number;
  7579. /**
  7580. * An event triggered after the world matrix is updated
  7581. */
  7582. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7583. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7584. /**
  7585. * Gets a string identifying the name of the class
  7586. * @returns "TransformNode" string
  7587. */
  7588. getClassName(): string;
  7589. /**
  7590. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7591. */
  7592. position: Vector3;
  7593. /**
  7594. * 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)).
  7595. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7596. */
  7597. rotation: Vector3;
  7598. /**
  7599. * 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)).
  7600. */
  7601. scaling: Vector3;
  7602. /**
  7603. * 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).
  7604. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7605. */
  7606. rotationQuaternion: Nullable<Quaternion>;
  7607. /**
  7608. * The forward direction of that transform in world space.
  7609. */
  7610. readonly forward: Vector3;
  7611. /**
  7612. * The up direction of that transform in world space.
  7613. */
  7614. readonly up: Vector3;
  7615. /**
  7616. * The right direction of that transform in world space.
  7617. */
  7618. readonly right: Vector3;
  7619. /**
  7620. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7621. * @param matrix the matrix to copy the pose from
  7622. * @returns this TransformNode.
  7623. */
  7624. updatePoseMatrix(matrix: Matrix): TransformNode;
  7625. /**
  7626. * Returns the mesh Pose matrix.
  7627. * @returns the pose matrix
  7628. */
  7629. getPoseMatrix(): Matrix;
  7630. /** @hidden */
  7631. _isSynchronized(): boolean;
  7632. /** @hidden */
  7633. _initCache(): void;
  7634. /**
  7635. * Flag the transform node as dirty (Forcing it to update everything)
  7636. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7637. * @returns this transform node
  7638. */
  7639. markAsDirty(property: string): TransformNode;
  7640. /**
  7641. * Returns the current mesh absolute position.
  7642. * Returns a Vector3.
  7643. */
  7644. readonly absolutePosition: Vector3;
  7645. /**
  7646. * Sets a new matrix to apply before all other transformation
  7647. * @param matrix defines the transform matrix
  7648. * @returns the current TransformNode
  7649. */
  7650. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7651. /**
  7652. * Sets a new pivot matrix to the current node
  7653. * @param matrix defines the new pivot matrix to use
  7654. * @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
  7655. * @returns the current TransformNode
  7656. */
  7657. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7658. /**
  7659. * Returns the mesh pivot matrix.
  7660. * Default : Identity.
  7661. * @returns the matrix
  7662. */
  7663. getPivotMatrix(): Matrix;
  7664. /**
  7665. * Prevents the World matrix to be computed any longer.
  7666. * @returns the TransformNode.
  7667. */
  7668. freezeWorldMatrix(): TransformNode;
  7669. /**
  7670. * Allows back the World matrix computation.
  7671. * @returns the TransformNode.
  7672. */
  7673. unfreezeWorldMatrix(): this;
  7674. /**
  7675. * True if the World matrix has been frozen.
  7676. */
  7677. readonly isWorldMatrixFrozen: boolean;
  7678. /**
  7679. * Retuns the mesh absolute position in the World.
  7680. * @returns a Vector3.
  7681. */
  7682. getAbsolutePosition(): Vector3;
  7683. /**
  7684. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7685. * @param absolutePosition the absolute position to set
  7686. * @returns the TransformNode.
  7687. */
  7688. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7689. /**
  7690. * Sets the mesh position in its local space.
  7691. * @param vector3 the position to set in localspace
  7692. * @returns the TransformNode.
  7693. */
  7694. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7695. /**
  7696. * Returns the mesh position in the local space from the current World matrix values.
  7697. * @returns a new Vector3.
  7698. */
  7699. getPositionExpressedInLocalSpace(): Vector3;
  7700. /**
  7701. * Translates the mesh along the passed Vector3 in its local space.
  7702. * @param vector3 the distance to translate in localspace
  7703. * @returns the TransformNode.
  7704. */
  7705. locallyTranslate(vector3: Vector3): TransformNode;
  7706. private static _lookAtVectorCache;
  7707. /**
  7708. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7709. * @param targetPoint the position (must be in same space as current mesh) to look at
  7710. * @param yawCor optional yaw (y-axis) correction in radians
  7711. * @param pitchCor optional pitch (x-axis) correction in radians
  7712. * @param rollCor optional roll (z-axis) correction in radians
  7713. * @param space the choosen space of the target
  7714. * @returns the TransformNode.
  7715. */
  7716. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7717. /**
  7718. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7719. * This Vector3 is expressed in the World space.
  7720. * @param localAxis axis to rotate
  7721. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7722. */
  7723. getDirection(localAxis: Vector3): Vector3;
  7724. /**
  7725. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7726. * localAxis is expressed in the mesh local space.
  7727. * result is computed in the Wordl space from the mesh World matrix.
  7728. * @param localAxis axis to rotate
  7729. * @param result the resulting transformnode
  7730. * @returns this TransformNode.
  7731. */
  7732. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7733. /**
  7734. * Sets this transform node rotation to the given local axis.
  7735. * @param localAxis the axis in local space
  7736. * @param yawCor optional yaw (y-axis) correction in radians
  7737. * @param pitchCor optional pitch (x-axis) correction in radians
  7738. * @param rollCor optional roll (z-axis) correction in radians
  7739. * @returns this TransformNode
  7740. */
  7741. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7742. /**
  7743. * Sets a new pivot point to the current node
  7744. * @param point defines the new pivot point to use
  7745. * @param space defines if the point is in world or local space (local by default)
  7746. * @returns the current TransformNode
  7747. */
  7748. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7749. /**
  7750. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7751. * @returns the pivot point
  7752. */
  7753. getPivotPoint(): Vector3;
  7754. /**
  7755. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7756. * @param result the vector3 to store the result
  7757. * @returns this TransformNode.
  7758. */
  7759. getPivotPointToRef(result: Vector3): TransformNode;
  7760. /**
  7761. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7762. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7763. */
  7764. getAbsolutePivotPoint(): Vector3;
  7765. /**
  7766. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7767. * @param result vector3 to store the result
  7768. * @returns this TransformNode.
  7769. */
  7770. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7771. /**
  7772. * Defines the passed node as the parent of the current node.
  7773. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7774. * @see https://doc.babylonjs.com/how_to/parenting
  7775. * @param node the node ot set as the parent
  7776. * @returns this TransformNode.
  7777. */
  7778. setParent(node: Nullable<Node>): TransformNode;
  7779. private _nonUniformScaling;
  7780. /**
  7781. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7782. */
  7783. readonly nonUniformScaling: boolean;
  7784. /** @hidden */
  7785. _updateNonUniformScalingState(value: boolean): boolean;
  7786. /**
  7787. * Attach the current TransformNode to another TransformNode associated with a bone
  7788. * @param bone Bone affecting the TransformNode
  7789. * @param affectedTransformNode TransformNode associated with the bone
  7790. * @returns this object
  7791. */
  7792. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7793. /**
  7794. * Detach the transform node if its associated with a bone
  7795. * @returns this object
  7796. */
  7797. detachFromBone(): TransformNode;
  7798. private static _rotationAxisCache;
  7799. /**
  7800. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7801. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7802. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7803. * The passed axis is also normalized.
  7804. * @param axis the axis to rotate around
  7805. * @param amount the amount to rotate in radians
  7806. * @param space Space to rotate in (Default: local)
  7807. * @returns the TransformNode.
  7808. */
  7809. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7810. /**
  7811. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7812. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7813. * The passed axis is also normalized. .
  7814. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7815. * @param point the point to rotate around
  7816. * @param axis the axis to rotate around
  7817. * @param amount the amount to rotate in radians
  7818. * @returns the TransformNode
  7819. */
  7820. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7821. /**
  7822. * Translates the mesh along the axis vector for the passed distance in the given space.
  7823. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7824. * @param axis the axis to translate in
  7825. * @param distance the distance to translate
  7826. * @param space Space to rotate in (Default: local)
  7827. * @returns the TransformNode.
  7828. */
  7829. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7830. /**
  7831. * Adds a rotation step to the mesh current rotation.
  7832. * x, y, z are Euler angles expressed in radians.
  7833. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7834. * This means this rotation is made in the mesh local space only.
  7835. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7836. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7837. * ```javascript
  7838. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7839. * ```
  7840. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7841. * 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.
  7842. * @param x Rotation to add
  7843. * @param y Rotation to add
  7844. * @param z Rotation to add
  7845. * @returns the TransformNode.
  7846. */
  7847. addRotation(x: number, y: number, z: number): TransformNode;
  7848. /**
  7849. * @hidden
  7850. */
  7851. protected _getEffectiveParent(): Nullable<Node>;
  7852. /**
  7853. * Computes the world matrix of the node
  7854. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7855. * @returns the world matrix
  7856. */
  7857. computeWorldMatrix(force?: boolean): Matrix;
  7858. protected _afterComputeWorldMatrix(): void;
  7859. /**
  7860. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7861. * @param func callback function to add
  7862. *
  7863. * @returns the TransformNode.
  7864. */
  7865. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7866. /**
  7867. * Removes a registered callback function.
  7868. * @param func callback function to remove
  7869. * @returns the TransformNode.
  7870. */
  7871. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7872. /**
  7873. * Gets the position of the current mesh in camera space
  7874. * @param camera defines the camera to use
  7875. * @returns a position
  7876. */
  7877. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7878. /**
  7879. * Returns the distance from the mesh to the active camera
  7880. * @param camera defines the camera to use
  7881. * @returns the distance
  7882. */
  7883. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7884. /**
  7885. * Clone the current transform node
  7886. * @param name Name of the new clone
  7887. * @param newParent New parent for the clone
  7888. * @param doNotCloneChildren Do not clone children hierarchy
  7889. * @returns the new transform node
  7890. */
  7891. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7892. /**
  7893. * Serializes the objects information.
  7894. * @param currentSerializationObject defines the object to serialize in
  7895. * @returns the serialized object
  7896. */
  7897. serialize(currentSerializationObject?: any): any;
  7898. /**
  7899. * Returns a new TransformNode object parsed from the source provided.
  7900. * @param parsedTransformNode is the source.
  7901. * @param scene the scne the object belongs to
  7902. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7903. * @returns a new TransformNode object parsed from the source provided.
  7904. */
  7905. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7906. /**
  7907. * Get all child-transformNodes of this node
  7908. * @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
  7909. * @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
  7910. * @returns an array of TransformNode
  7911. */
  7912. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7913. /**
  7914. * Releases resources associated with this transform node.
  7915. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7916. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7917. */
  7918. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7919. }
  7920. }
  7921. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7922. /**
  7923. * Class used to override all child animations of a given target
  7924. */
  7925. export class AnimationPropertiesOverride {
  7926. /**
  7927. * Gets or sets a value indicating if animation blending must be used
  7928. */
  7929. enableBlending: boolean;
  7930. /**
  7931. * Gets or sets the blending speed to use when enableBlending is true
  7932. */
  7933. blendingSpeed: number;
  7934. /**
  7935. * Gets or sets the default loop mode to use
  7936. */
  7937. loopMode: number;
  7938. }
  7939. }
  7940. declare module "babylonjs/Bones/bone" {
  7941. import { Skeleton } from "babylonjs/Bones/skeleton";
  7942. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7943. import { Nullable } from "babylonjs/types";
  7944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7945. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7946. import { Node } from "babylonjs/node";
  7947. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7948. /**
  7949. * Class used to store bone information
  7950. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7951. */
  7952. export class Bone extends Node {
  7953. /**
  7954. * defines the bone name
  7955. */
  7956. name: string;
  7957. private static _tmpVecs;
  7958. private static _tmpQuat;
  7959. private static _tmpMats;
  7960. /**
  7961. * Gets the list of child bones
  7962. */
  7963. children: Bone[];
  7964. /** Gets the animations associated with this bone */
  7965. animations: import("babylonjs/Animations/animation").Animation[];
  7966. /**
  7967. * Gets or sets bone length
  7968. */
  7969. length: number;
  7970. /**
  7971. * @hidden Internal only
  7972. * Set this value to map this bone to a different index in the transform matrices
  7973. * Set this value to -1 to exclude the bone from the transform matrices
  7974. */
  7975. _index: Nullable<number>;
  7976. private _skeleton;
  7977. private _localMatrix;
  7978. private _restPose;
  7979. private _baseMatrix;
  7980. private _absoluteTransform;
  7981. private _invertedAbsoluteTransform;
  7982. private _parent;
  7983. private _scalingDeterminant;
  7984. private _worldTransform;
  7985. private _localScaling;
  7986. private _localRotation;
  7987. private _localPosition;
  7988. private _needToDecompose;
  7989. private _needToCompose;
  7990. /** @hidden */
  7991. _linkedTransformNode: Nullable<TransformNode>;
  7992. /** @hidden */
  7993. /** @hidden */
  7994. _matrix: Matrix;
  7995. /**
  7996. * Create a new bone
  7997. * @param name defines the bone name
  7998. * @param skeleton defines the parent skeleton
  7999. * @param parentBone defines the parent (can be null if the bone is the root)
  8000. * @param localMatrix defines the local matrix
  8001. * @param restPose defines the rest pose matrix
  8002. * @param baseMatrix defines the base matrix
  8003. * @param index defines index of the bone in the hiearchy
  8004. */
  8005. constructor(
  8006. /**
  8007. * defines the bone name
  8008. */
  8009. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8010. /**
  8011. * Gets the current object class name.
  8012. * @return the class name
  8013. */
  8014. getClassName(): string;
  8015. /**
  8016. * Gets the parent skeleton
  8017. * @returns a skeleton
  8018. */
  8019. getSkeleton(): Skeleton;
  8020. /**
  8021. * Gets parent bone
  8022. * @returns a bone or null if the bone is the root of the bone hierarchy
  8023. */
  8024. getParent(): Nullable<Bone>;
  8025. /**
  8026. * Returns an array containing the root bones
  8027. * @returns an array containing the root bones
  8028. */
  8029. getChildren(): Array<Bone>;
  8030. /**
  8031. * Sets the parent bone
  8032. * @param parent defines the parent (can be null if the bone is the root)
  8033. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8034. */
  8035. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8036. /**
  8037. * Gets the local matrix
  8038. * @returns a matrix
  8039. */
  8040. getLocalMatrix(): Matrix;
  8041. /**
  8042. * Gets the base matrix (initial matrix which remains unchanged)
  8043. * @returns a matrix
  8044. */
  8045. getBaseMatrix(): Matrix;
  8046. /**
  8047. * Gets the rest pose matrix
  8048. * @returns a matrix
  8049. */
  8050. getRestPose(): Matrix;
  8051. /**
  8052. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8053. */
  8054. getWorldMatrix(): Matrix;
  8055. /**
  8056. * Sets the local matrix to rest pose matrix
  8057. */
  8058. returnToRest(): void;
  8059. /**
  8060. * Gets the inverse of the absolute transform matrix.
  8061. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8062. * @returns a matrix
  8063. */
  8064. getInvertedAbsoluteTransform(): Matrix;
  8065. /**
  8066. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8067. * @returns a matrix
  8068. */
  8069. getAbsoluteTransform(): Matrix;
  8070. /**
  8071. * Links with the given transform node.
  8072. * The local matrix of this bone is copied from the transform node every frame.
  8073. * @param transformNode defines the transform node to link to
  8074. */
  8075. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8076. /** Gets or sets current position (in local space) */
  8077. position: Vector3;
  8078. /** Gets or sets current rotation (in local space) */
  8079. rotation: Vector3;
  8080. /** Gets or sets current rotation quaternion (in local space) */
  8081. rotationQuaternion: Quaternion;
  8082. /** Gets or sets current scaling (in local space) */
  8083. scaling: Vector3;
  8084. /**
  8085. * Gets the animation properties override
  8086. */
  8087. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8088. private _decompose;
  8089. private _compose;
  8090. /**
  8091. * Update the base and local matrices
  8092. * @param matrix defines the new base or local matrix
  8093. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8094. * @param updateLocalMatrix defines if the local matrix should be updated
  8095. */
  8096. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8097. /** @hidden */
  8098. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8099. /**
  8100. * Flag the bone as dirty (Forcing it to update everything)
  8101. */
  8102. markAsDirty(): void;
  8103. private _markAsDirtyAndCompose;
  8104. private _markAsDirtyAndDecompose;
  8105. /**
  8106. * Translate the bone in local or world space
  8107. * @param vec The amount to translate the bone
  8108. * @param space The space that the translation is in
  8109. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8110. */
  8111. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8112. /**
  8113. * Set the postion of the bone in local or world space
  8114. * @param position The position to set the bone
  8115. * @param space The space that the position is in
  8116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8117. */
  8118. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8119. /**
  8120. * Set the absolute position of the bone (world space)
  8121. * @param position The position to set the bone
  8122. * @param mesh The mesh that this bone is attached to
  8123. */
  8124. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8125. /**
  8126. * Scale the bone on the x, y and z axes (in local space)
  8127. * @param x The amount to scale the bone on the x axis
  8128. * @param y The amount to scale the bone on the y axis
  8129. * @param z The amount to scale the bone on the z axis
  8130. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8131. */
  8132. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8133. /**
  8134. * Set the bone scaling in local space
  8135. * @param scale defines the scaling vector
  8136. */
  8137. setScale(scale: Vector3): void;
  8138. /**
  8139. * Gets the current scaling in local space
  8140. * @returns the current scaling vector
  8141. */
  8142. getScale(): Vector3;
  8143. /**
  8144. * Gets the current scaling in local space and stores it in a target vector
  8145. * @param result defines the target vector
  8146. */
  8147. getScaleToRef(result: Vector3): void;
  8148. /**
  8149. * Set the yaw, pitch, and roll of the bone in local or world space
  8150. * @param yaw The rotation of the bone on the y axis
  8151. * @param pitch The rotation of the bone on the x axis
  8152. * @param roll The rotation of the bone on the z axis
  8153. * @param space The space that the axes of rotation are in
  8154. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8155. */
  8156. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8157. /**
  8158. * Add a rotation to the bone on an axis in local or world space
  8159. * @param axis The axis to rotate the bone on
  8160. * @param amount The amount to rotate the bone
  8161. * @param space The space that the axis is in
  8162. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8163. */
  8164. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8165. /**
  8166. * Set the rotation of the bone to a particular axis angle in local or world space
  8167. * @param axis The axis to rotate the bone on
  8168. * @param angle The angle that the bone should be rotated to
  8169. * @param space The space that the axis is in
  8170. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8171. */
  8172. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8173. /**
  8174. * Set the euler rotation of the bone in local of world space
  8175. * @param rotation The euler rotation that the bone should be set to
  8176. * @param space The space that the rotation is in
  8177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8178. */
  8179. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8180. /**
  8181. * Set the quaternion rotation of the bone in local of world space
  8182. * @param quat The quaternion rotation that the bone should be set to
  8183. * @param space The space that the rotation is in
  8184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8185. */
  8186. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8187. /**
  8188. * Set the rotation matrix of the bone in local of world space
  8189. * @param rotMat The rotation matrix that the bone should be set to
  8190. * @param space The space that the rotation is in
  8191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8192. */
  8193. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8194. private _rotateWithMatrix;
  8195. private _getNegativeRotationToRef;
  8196. /**
  8197. * Get the position of the bone in local or world space
  8198. * @param space The space that the returned position is in
  8199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8200. * @returns The position of the bone
  8201. */
  8202. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8203. /**
  8204. * Copy the position of the bone to a vector3 in local or world space
  8205. * @param space The space that the returned position is in
  8206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8207. * @param result The vector3 to copy the position to
  8208. */
  8209. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8210. /**
  8211. * Get the absolute position of the bone (world space)
  8212. * @param mesh The mesh that this bone is attached to
  8213. * @returns The absolute position of the bone
  8214. */
  8215. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8216. /**
  8217. * Copy the absolute position of the bone (world space) to the result param
  8218. * @param mesh The mesh that this bone is attached to
  8219. * @param result The vector3 to copy the absolute position to
  8220. */
  8221. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8222. /**
  8223. * Compute the absolute transforms of this bone and its children
  8224. */
  8225. computeAbsoluteTransforms(): void;
  8226. /**
  8227. * Get the world direction from an axis that is in the local space of the bone
  8228. * @param localAxis The local direction that is used to compute the world direction
  8229. * @param mesh The mesh that this bone is attached to
  8230. * @returns The world direction
  8231. */
  8232. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8233. /**
  8234. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8235. * @param localAxis The local direction that is used to compute the world direction
  8236. * @param mesh The mesh that this bone is attached to
  8237. * @param result The vector3 that the world direction will be copied to
  8238. */
  8239. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8240. /**
  8241. * Get the euler rotation of the bone in local or world space
  8242. * @param space The space that the rotation should be in
  8243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8244. * @returns The euler rotation
  8245. */
  8246. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8247. /**
  8248. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8249. * @param space The space that the rotation should be in
  8250. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8251. * @param result The vector3 that the rotation should be copied to
  8252. */
  8253. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8254. /**
  8255. * Get the quaternion rotation of the bone in either local or world space
  8256. * @param space The space that the rotation should be in
  8257. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8258. * @returns The quaternion rotation
  8259. */
  8260. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8261. /**
  8262. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8263. * @param space The space that the rotation should be in
  8264. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8265. * @param result The quaternion that the rotation should be copied to
  8266. */
  8267. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8268. /**
  8269. * Get the rotation matrix of the bone in local or world space
  8270. * @param space The space that the rotation should be in
  8271. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8272. * @returns The rotation matrix
  8273. */
  8274. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8275. /**
  8276. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8277. * @param space The space that the rotation should be in
  8278. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8279. * @param result The quaternion that the rotation should be copied to
  8280. */
  8281. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8282. /**
  8283. * Get the world position of a point that is in the local space of the bone
  8284. * @param position The local position
  8285. * @param mesh The mesh that this bone is attached to
  8286. * @returns The world position
  8287. */
  8288. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8289. /**
  8290. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8291. * @param position The local position
  8292. * @param mesh The mesh that this bone is attached to
  8293. * @param result The vector3 that the world position should be copied to
  8294. */
  8295. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8296. /**
  8297. * Get the local position of a point that is in world space
  8298. * @param position The world position
  8299. * @param mesh The mesh that this bone is attached to
  8300. * @returns The local position
  8301. */
  8302. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8303. /**
  8304. * Get the local position of a point that is in world space and copy it to the result param
  8305. * @param position The world position
  8306. * @param mesh The mesh that this bone is attached to
  8307. * @param result The vector3 that the local position should be copied to
  8308. */
  8309. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8310. }
  8311. }
  8312. declare module "babylonjs/Misc/iInspectable" {
  8313. /**
  8314. * Enum that determines the text-wrapping mode to use.
  8315. */
  8316. export enum InspectableType {
  8317. /**
  8318. * Checkbox for booleans
  8319. */
  8320. Checkbox = 0,
  8321. /**
  8322. * Sliders for numbers
  8323. */
  8324. Slider = 1,
  8325. /**
  8326. * Vector3
  8327. */
  8328. Vector3 = 2,
  8329. /**
  8330. * Quaternions
  8331. */
  8332. Quaternion = 3,
  8333. /**
  8334. * Color3
  8335. */
  8336. Color3 = 4
  8337. }
  8338. /**
  8339. * Interface used to define custom inspectable properties.
  8340. * This interface is used by the inspector to display custom property grids
  8341. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8342. */
  8343. export interface IInspectable {
  8344. /**
  8345. * Gets the label to display
  8346. */
  8347. label: string;
  8348. /**
  8349. * Gets the name of the property to edit
  8350. */
  8351. propertyName: string;
  8352. /**
  8353. * Gets the type of the editor to use
  8354. */
  8355. type: InspectableType;
  8356. /**
  8357. * Gets the minimum value of the property when using in "slider" mode
  8358. */
  8359. min?: number;
  8360. /**
  8361. * Gets the maximum value of the property when using in "slider" mode
  8362. */
  8363. max?: number;
  8364. /**
  8365. * Gets the setp to use when using in "slider" mode
  8366. */
  8367. step?: number;
  8368. }
  8369. }
  8370. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8371. import { Nullable } from "babylonjs/types";
  8372. import { Scene } from "babylonjs/scene";
  8373. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8374. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8375. /**
  8376. * Class for creating a cube texture
  8377. */
  8378. export class CubeTexture extends BaseTexture {
  8379. private _delayedOnLoad;
  8380. /**
  8381. * The url of the texture
  8382. */
  8383. url: string;
  8384. /**
  8385. * Gets or sets the center of the bounding box associated with the cube texture.
  8386. * It must define where the camera used to render the texture was set
  8387. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8388. */
  8389. boundingBoxPosition: Vector3;
  8390. private _boundingBoxSize;
  8391. /**
  8392. * Gets or sets the size of the bounding box associated with the cube texture
  8393. * When defined, the cubemap will switch to local mode
  8394. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8395. * @example https://www.babylonjs-playground.com/#RNASML
  8396. */
  8397. /**
  8398. * Returns the bounding box size
  8399. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8400. */
  8401. boundingBoxSize: Vector3;
  8402. protected _rotationY: number;
  8403. /**
  8404. * Sets texture matrix rotation angle around Y axis in radians.
  8405. */
  8406. /**
  8407. * Gets texture matrix rotation angle around Y axis radians.
  8408. */
  8409. rotationY: number;
  8410. /**
  8411. * Are mip maps generated for this texture or not.
  8412. */
  8413. readonly noMipmap: boolean;
  8414. private _noMipmap;
  8415. private _files;
  8416. private _extensions;
  8417. private _textureMatrix;
  8418. private _format;
  8419. private _createPolynomials;
  8420. /** @hidden */
  8421. _prefiltered: boolean;
  8422. /**
  8423. * Creates a cube texture from an array of image urls
  8424. * @param files defines an array of image urls
  8425. * @param scene defines the hosting scene
  8426. * @param noMipmap specifies if mip maps are not used
  8427. * @returns a cube texture
  8428. */
  8429. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8430. /**
  8431. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8432. * @param url defines the url of the prefiltered texture
  8433. * @param scene defines the scene the texture is attached to
  8434. * @param forcedExtension defines the extension of the file if different from the url
  8435. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8436. * @return the prefiltered texture
  8437. */
  8438. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8439. /**
  8440. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8441. * as prefiltered data.
  8442. * @param rootUrl defines the url of the texture or the root name of the six images
  8443. * @param scene defines the scene the texture is attached to
  8444. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8445. * @param noMipmap defines if mipmaps should be created or not
  8446. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8447. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8448. * @param onError defines a callback triggered in case of error during load
  8449. * @param format defines the internal format to use for the texture once loaded
  8450. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8451. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8452. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8453. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8454. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8455. * @return the cube texture
  8456. */
  8457. 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);
  8458. /**
  8459. * Get the current class name of the texture useful for serialization or dynamic coding.
  8460. * @returns "CubeTexture"
  8461. */
  8462. getClassName(): string;
  8463. /**
  8464. * Update the url (and optional buffer) of this texture if url was null during construction.
  8465. * @param url the url of the texture
  8466. * @param forcedExtension defines the extension to use
  8467. * @param onLoad callback called when the texture is loaded (defaults to null)
  8468. */
  8469. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8470. /**
  8471. * Delays loading of the cube texture
  8472. * @param forcedExtension defines the extension to use
  8473. */
  8474. delayLoad(forcedExtension?: string): void;
  8475. /**
  8476. * Returns the reflection texture matrix
  8477. * @returns the reflection texture matrix
  8478. */
  8479. getReflectionTextureMatrix(): Matrix;
  8480. /**
  8481. * Sets the reflection texture matrix
  8482. * @param value Reflection texture matrix
  8483. */
  8484. setReflectionTextureMatrix(value: Matrix): void;
  8485. /**
  8486. * Parses text to create a cube texture
  8487. * @param parsedTexture define the serialized text to read from
  8488. * @param scene defines the hosting scene
  8489. * @param rootUrl defines the root url of the cube texture
  8490. * @returns a cube texture
  8491. */
  8492. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8493. /**
  8494. * Makes a clone, or deep copy, of the cube texture
  8495. * @returns a new cube texture
  8496. */
  8497. clone(): CubeTexture;
  8498. }
  8499. }
  8500. declare module "babylonjs/Shaders/postprocess.vertex" {
  8501. /** @hidden */
  8502. export var postprocessVertexShader: {
  8503. name: string;
  8504. shader: string;
  8505. };
  8506. }
  8507. declare module "babylonjs/Cameras/targetCamera" {
  8508. import { Nullable } from "babylonjs/types";
  8509. import { Camera } from "babylonjs/Cameras/camera";
  8510. import { Scene } from "babylonjs/scene";
  8511. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8512. /**
  8513. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8514. * This is the base of the follow, arc rotate cameras and Free camera
  8515. * @see http://doc.babylonjs.com/features/cameras
  8516. */
  8517. export class TargetCamera extends Camera {
  8518. private static _RigCamTransformMatrix;
  8519. private static _TargetTransformMatrix;
  8520. private static _TargetFocalPoint;
  8521. /**
  8522. * Define the current direction the camera is moving to
  8523. */
  8524. cameraDirection: Vector3;
  8525. /**
  8526. * Define the current rotation the camera is rotating to
  8527. */
  8528. cameraRotation: Vector2;
  8529. /**
  8530. * When set, the up vector of the camera will be updated by the rotation of the camera
  8531. */
  8532. updateUpVectorFromRotation: boolean;
  8533. private _tmpQuaternion;
  8534. /**
  8535. * Define the current rotation of the camera
  8536. */
  8537. rotation: Vector3;
  8538. /**
  8539. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8540. */
  8541. rotationQuaternion: Quaternion;
  8542. /**
  8543. * Define the current speed of the camera
  8544. */
  8545. speed: number;
  8546. /**
  8547. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8548. * around all axis.
  8549. */
  8550. noRotationConstraint: boolean;
  8551. /**
  8552. * Define the current target of the camera as an object or a position.
  8553. */
  8554. lockedTarget: any;
  8555. /** @hidden */
  8556. _currentTarget: Vector3;
  8557. /** @hidden */
  8558. _initialFocalDistance: number;
  8559. /** @hidden */
  8560. _viewMatrix: Matrix;
  8561. /** @hidden */
  8562. _camMatrix: Matrix;
  8563. /** @hidden */
  8564. _cameraTransformMatrix: Matrix;
  8565. /** @hidden */
  8566. _cameraRotationMatrix: Matrix;
  8567. /** @hidden */
  8568. _referencePoint: Vector3;
  8569. /** @hidden */
  8570. _transformedReferencePoint: Vector3;
  8571. protected _globalCurrentTarget: Vector3;
  8572. protected _globalCurrentUpVector: Vector3;
  8573. /** @hidden */
  8574. _reset: () => void;
  8575. private _defaultUp;
  8576. /**
  8577. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8578. * This is the base of the follow, arc rotate cameras and Free camera
  8579. * @see http://doc.babylonjs.com/features/cameras
  8580. * @param name Defines the name of the camera in the scene
  8581. * @param position Defines the start position of the camera in the scene
  8582. * @param scene Defines the scene the camera belongs to
  8583. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8584. */
  8585. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8586. /**
  8587. * Gets the position in front of the camera at a given distance.
  8588. * @param distance The distance from the camera we want the position to be
  8589. * @returns the position
  8590. */
  8591. getFrontPosition(distance: number): Vector3;
  8592. /** @hidden */
  8593. _getLockedTargetPosition(): Nullable<Vector3>;
  8594. private _storedPosition;
  8595. private _storedRotation;
  8596. private _storedRotationQuaternion;
  8597. /**
  8598. * Store current camera state of the camera (fov, position, rotation, etc..)
  8599. * @returns the camera
  8600. */
  8601. storeState(): Camera;
  8602. /**
  8603. * Restored camera state. You must call storeState() first
  8604. * @returns whether it was successful or not
  8605. * @hidden
  8606. */
  8607. _restoreStateValues(): boolean;
  8608. /** @hidden */
  8609. _initCache(): void;
  8610. /** @hidden */
  8611. _updateCache(ignoreParentClass?: boolean): void;
  8612. /** @hidden */
  8613. _isSynchronizedViewMatrix(): boolean;
  8614. /** @hidden */
  8615. _computeLocalCameraSpeed(): number;
  8616. /**
  8617. * Defines the target the camera should look at.
  8618. * This will automatically adapt alpha beta and radius to fit within the new target.
  8619. * @param target Defines the new target as a Vector or a mesh
  8620. */
  8621. setTarget(target: Vector3): void;
  8622. /**
  8623. * Return the current target position of the camera. This value is expressed in local space.
  8624. * @returns the target position
  8625. */
  8626. getTarget(): Vector3;
  8627. /** @hidden */
  8628. _decideIfNeedsToMove(): boolean;
  8629. /** @hidden */
  8630. _updatePosition(): void;
  8631. /** @hidden */
  8632. _checkInputs(): void;
  8633. protected _updateCameraRotationMatrix(): void;
  8634. /**
  8635. * 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)
  8636. * @returns the current camera
  8637. */
  8638. private _rotateUpVectorWithCameraRotationMatrix;
  8639. private _cachedRotationZ;
  8640. private _cachedQuaternionRotationZ;
  8641. /** @hidden */
  8642. _getViewMatrix(): Matrix;
  8643. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8644. /**
  8645. * @hidden
  8646. */
  8647. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8648. /**
  8649. * @hidden
  8650. */
  8651. _updateRigCameras(): void;
  8652. private _getRigCamPositionAndTarget;
  8653. /**
  8654. * Gets the current object class name.
  8655. * @return the class name
  8656. */
  8657. getClassName(): string;
  8658. }
  8659. }
  8660. declare module "babylonjs/Cameras/cameraInputsManager" {
  8661. import { Nullable } from "babylonjs/types";
  8662. import { Camera } from "babylonjs/Cameras/camera";
  8663. /**
  8664. * @ignore
  8665. * This is a list of all the different input types that are available in the application.
  8666. * Fo instance: ArcRotateCameraGamepadInput...
  8667. */
  8668. export var CameraInputTypes: {};
  8669. /**
  8670. * This is the contract to implement in order to create a new input class.
  8671. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8672. */
  8673. export interface ICameraInput<TCamera extends Camera> {
  8674. /**
  8675. * Defines the camera the input is attached to.
  8676. */
  8677. camera: Nullable<TCamera>;
  8678. /**
  8679. * Gets the class name of the current intput.
  8680. * @returns the class name
  8681. */
  8682. getClassName(): string;
  8683. /**
  8684. * Get the friendly name associated with the input class.
  8685. * @returns the input friendly name
  8686. */
  8687. getSimpleName(): string;
  8688. /**
  8689. * Attach the input controls to a specific dom element to get the input from.
  8690. * @param element Defines the element the controls should be listened from
  8691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8692. */
  8693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8694. /**
  8695. * Detach the current controls from the specified dom element.
  8696. * @param element Defines the element to stop listening the inputs from
  8697. */
  8698. detachControl(element: Nullable<HTMLElement>): void;
  8699. /**
  8700. * Update the current camera state depending on the inputs that have been used this frame.
  8701. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8702. */
  8703. checkInputs?: () => void;
  8704. }
  8705. /**
  8706. * Represents a map of input types to input instance or input index to input instance.
  8707. */
  8708. export interface CameraInputsMap<TCamera extends Camera> {
  8709. /**
  8710. * Accessor to the input by input type.
  8711. */
  8712. [name: string]: ICameraInput<TCamera>;
  8713. /**
  8714. * Accessor to the input by input index.
  8715. */
  8716. [idx: number]: ICameraInput<TCamera>;
  8717. }
  8718. /**
  8719. * This represents the input manager used within a camera.
  8720. * It helps dealing with all the different kind of input attached to a camera.
  8721. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8722. */
  8723. export class CameraInputsManager<TCamera extends Camera> {
  8724. /**
  8725. * Defines the list of inputs attahed to the camera.
  8726. */
  8727. attached: CameraInputsMap<TCamera>;
  8728. /**
  8729. * Defines the dom element the camera is collecting inputs from.
  8730. * This is null if the controls have not been attached.
  8731. */
  8732. attachedElement: Nullable<HTMLElement>;
  8733. /**
  8734. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8735. */
  8736. noPreventDefault: boolean;
  8737. /**
  8738. * Defined the camera the input manager belongs to.
  8739. */
  8740. camera: TCamera;
  8741. /**
  8742. * Update the current camera state depending on the inputs that have been used this frame.
  8743. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8744. */
  8745. checkInputs: () => void;
  8746. /**
  8747. * Instantiate a new Camera Input Manager.
  8748. * @param camera Defines the camera the input manager blongs to
  8749. */
  8750. constructor(camera: TCamera);
  8751. /**
  8752. * Add an input method to a camera
  8753. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8754. * @param input camera input method
  8755. */
  8756. add(input: ICameraInput<TCamera>): void;
  8757. /**
  8758. * Remove a specific input method from a camera
  8759. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8760. * @param inputToRemove camera input method
  8761. */
  8762. remove(inputToRemove: ICameraInput<TCamera>): void;
  8763. /**
  8764. * Remove a specific input type from a camera
  8765. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8766. * @param inputType the type of the input to remove
  8767. */
  8768. removeByType(inputType: string): void;
  8769. private _addCheckInputs;
  8770. /**
  8771. * Attach the input controls to the currently attached dom element to listen the events from.
  8772. * @param input Defines the input to attach
  8773. */
  8774. attachInput(input: ICameraInput<TCamera>): void;
  8775. /**
  8776. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8777. * @param element Defines the dom element to collect the events from
  8778. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8779. */
  8780. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8781. /**
  8782. * Detach the current manager inputs controls from a specific dom element.
  8783. * @param element Defines the dom element to collect the events from
  8784. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8785. */
  8786. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8787. /**
  8788. * Rebuild the dynamic inputCheck function from the current list of
  8789. * defined inputs in the manager.
  8790. */
  8791. rebuildInputCheck(): void;
  8792. /**
  8793. * Remove all attached input methods from a camera
  8794. */
  8795. clear(): void;
  8796. /**
  8797. * Serialize the current input manager attached to a camera.
  8798. * This ensures than once parsed,
  8799. * the input associated to the camera will be identical to the current ones
  8800. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8801. */
  8802. serialize(serializedCamera: any): void;
  8803. /**
  8804. * Parses an input manager serialized JSON to restore the previous list of inputs
  8805. * and states associated to a camera.
  8806. * @param parsedCamera Defines the JSON to parse
  8807. */
  8808. parse(parsedCamera: any): void;
  8809. }
  8810. }
  8811. declare module "babylonjs/Events/keyboardEvents" {
  8812. /**
  8813. * Gather the list of keyboard event types as constants.
  8814. */
  8815. export class KeyboardEventTypes {
  8816. /**
  8817. * The keydown event is fired when a key becomes active (pressed).
  8818. */
  8819. static readonly KEYDOWN: number;
  8820. /**
  8821. * The keyup event is fired when a key has been released.
  8822. */
  8823. static readonly KEYUP: number;
  8824. }
  8825. /**
  8826. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8827. */
  8828. export class KeyboardInfo {
  8829. /**
  8830. * Defines the type of event (KeyboardEventTypes)
  8831. */
  8832. type: number;
  8833. /**
  8834. * Defines the related dom event
  8835. */
  8836. event: KeyboardEvent;
  8837. /**
  8838. * Instantiates a new keyboard info.
  8839. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8840. * @param type Defines the type of event (KeyboardEventTypes)
  8841. * @param event Defines the related dom event
  8842. */
  8843. constructor(
  8844. /**
  8845. * Defines the type of event (KeyboardEventTypes)
  8846. */
  8847. type: number,
  8848. /**
  8849. * Defines the related dom event
  8850. */
  8851. event: KeyboardEvent);
  8852. }
  8853. /**
  8854. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8855. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8856. */
  8857. export class KeyboardInfoPre extends KeyboardInfo {
  8858. /**
  8859. * Defines the type of event (KeyboardEventTypes)
  8860. */
  8861. type: number;
  8862. /**
  8863. * Defines the related dom event
  8864. */
  8865. event: KeyboardEvent;
  8866. /**
  8867. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8868. */
  8869. skipOnPointerObservable: boolean;
  8870. /**
  8871. * Instantiates a new keyboard pre info.
  8872. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8873. * @param type Defines the type of event (KeyboardEventTypes)
  8874. * @param event Defines the related dom event
  8875. */
  8876. constructor(
  8877. /**
  8878. * Defines the type of event (KeyboardEventTypes)
  8879. */
  8880. type: number,
  8881. /**
  8882. * Defines the related dom event
  8883. */
  8884. event: KeyboardEvent);
  8885. }
  8886. }
  8887. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8888. import { Nullable } from "babylonjs/types";
  8889. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8890. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8891. /**
  8892. * Manage the keyboard inputs to control the movement of a free camera.
  8893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8894. */
  8895. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8896. /**
  8897. * Defines the camera the input is attached to.
  8898. */
  8899. camera: FreeCamera;
  8900. /**
  8901. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8902. */
  8903. keysUp: number[];
  8904. /**
  8905. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8906. */
  8907. keysDown: number[];
  8908. /**
  8909. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8910. */
  8911. keysLeft: number[];
  8912. /**
  8913. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8914. */
  8915. keysRight: number[];
  8916. private _keys;
  8917. private _onCanvasBlurObserver;
  8918. private _onKeyboardObserver;
  8919. private _engine;
  8920. private _scene;
  8921. /**
  8922. * Attach the input controls to a specific dom element to get the input from.
  8923. * @param element Defines the element the controls should be listened from
  8924. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8925. */
  8926. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8927. /**
  8928. * Detach the current controls from the specified dom element.
  8929. * @param element Defines the element to stop listening the inputs from
  8930. */
  8931. detachControl(element: Nullable<HTMLElement>): void;
  8932. /**
  8933. * Update the current camera state depending on the inputs that have been used this frame.
  8934. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8935. */
  8936. checkInputs(): void;
  8937. /**
  8938. * Gets the class name of the current intput.
  8939. * @returns the class name
  8940. */
  8941. getClassName(): string;
  8942. /** @hidden */
  8943. _onLostFocus(): void;
  8944. /**
  8945. * Get the friendly name associated with the input class.
  8946. * @returns the input friendly name
  8947. */
  8948. getSimpleName(): string;
  8949. }
  8950. }
  8951. declare module "babylonjs/Lights/shadowLight" {
  8952. import { Camera } from "babylonjs/Cameras/camera";
  8953. import { Scene } from "babylonjs/scene";
  8954. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8956. import { Light } from "babylonjs/Lights/light";
  8957. /**
  8958. * Interface describing all the common properties and methods a shadow light needs to implement.
  8959. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8960. * as well as binding the different shadow properties to the effects.
  8961. */
  8962. export interface IShadowLight extends Light {
  8963. /**
  8964. * The light id in the scene (used in scene.findLighById for instance)
  8965. */
  8966. id: string;
  8967. /**
  8968. * The position the shdow will be casted from.
  8969. */
  8970. position: Vector3;
  8971. /**
  8972. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8973. */
  8974. direction: Vector3;
  8975. /**
  8976. * The transformed position. Position of the light in world space taking parenting in account.
  8977. */
  8978. transformedPosition: Vector3;
  8979. /**
  8980. * The transformed direction. Direction of the light in world space taking parenting in account.
  8981. */
  8982. transformedDirection: Vector3;
  8983. /**
  8984. * The friendly name of the light in the scene.
  8985. */
  8986. name: string;
  8987. /**
  8988. * Defines the shadow projection clipping minimum z value.
  8989. */
  8990. shadowMinZ: number;
  8991. /**
  8992. * Defines the shadow projection clipping maximum z value.
  8993. */
  8994. shadowMaxZ: number;
  8995. /**
  8996. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8997. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8998. */
  8999. computeTransformedInformation(): boolean;
  9000. /**
  9001. * Gets the scene the light belongs to.
  9002. * @returns The scene
  9003. */
  9004. getScene(): Scene;
  9005. /**
  9006. * Callback defining a custom Projection Matrix Builder.
  9007. * This can be used to override the default projection matrix computation.
  9008. */
  9009. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9010. /**
  9011. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9012. * @param matrix The materix to updated with the projection information
  9013. * @param viewMatrix The transform matrix of the light
  9014. * @param renderList The list of mesh to render in the map
  9015. * @returns The current light
  9016. */
  9017. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9018. /**
  9019. * Gets the current depth scale used in ESM.
  9020. * @returns The scale
  9021. */
  9022. getDepthScale(): number;
  9023. /**
  9024. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9025. * @returns true if a cube texture needs to be use
  9026. */
  9027. needCube(): boolean;
  9028. /**
  9029. * Detects if the projection matrix requires to be recomputed this frame.
  9030. * @returns true if it requires to be recomputed otherwise, false.
  9031. */
  9032. needProjectionMatrixCompute(): boolean;
  9033. /**
  9034. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9035. */
  9036. forceProjectionMatrixCompute(): void;
  9037. /**
  9038. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9039. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9040. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9041. */
  9042. getShadowDirection(faceIndex?: number): Vector3;
  9043. /**
  9044. * Gets the minZ used for shadow according to both the scene and the light.
  9045. * @param activeCamera The camera we are returning the min for
  9046. * @returns the depth min z
  9047. */
  9048. getDepthMinZ(activeCamera: Camera): number;
  9049. /**
  9050. * Gets the maxZ used for shadow according to both the scene and the light.
  9051. * @param activeCamera The camera we are returning the max for
  9052. * @returns the depth max z
  9053. */
  9054. getDepthMaxZ(activeCamera: Camera): number;
  9055. }
  9056. /**
  9057. * Base implementation IShadowLight
  9058. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9059. */
  9060. export abstract class ShadowLight extends Light implements IShadowLight {
  9061. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9062. protected _position: Vector3;
  9063. protected _setPosition(value: Vector3): void;
  9064. /**
  9065. * Sets the position the shadow will be casted from. Also use as the light position for both
  9066. * point and spot lights.
  9067. */
  9068. /**
  9069. * Sets the position the shadow will be casted from. Also use as the light position for both
  9070. * point and spot lights.
  9071. */
  9072. position: Vector3;
  9073. protected _direction: Vector3;
  9074. protected _setDirection(value: Vector3): void;
  9075. /**
  9076. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9077. * Also use as the light direction on spot and directional lights.
  9078. */
  9079. /**
  9080. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9081. * Also use as the light direction on spot and directional lights.
  9082. */
  9083. direction: Vector3;
  9084. private _shadowMinZ;
  9085. /**
  9086. * Gets the shadow projection clipping minimum z value.
  9087. */
  9088. /**
  9089. * Sets the shadow projection clipping minimum z value.
  9090. */
  9091. shadowMinZ: number;
  9092. private _shadowMaxZ;
  9093. /**
  9094. * Sets the shadow projection clipping maximum z value.
  9095. */
  9096. /**
  9097. * Gets the shadow projection clipping maximum z value.
  9098. */
  9099. shadowMaxZ: number;
  9100. /**
  9101. * Callback defining a custom Projection Matrix Builder.
  9102. * This can be used to override the default projection matrix computation.
  9103. */
  9104. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9105. /**
  9106. * The transformed position. Position of the light in world space taking parenting in account.
  9107. */
  9108. transformedPosition: Vector3;
  9109. /**
  9110. * The transformed direction. Direction of the light in world space taking parenting in account.
  9111. */
  9112. transformedDirection: Vector3;
  9113. private _needProjectionMatrixCompute;
  9114. /**
  9115. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9116. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9117. */
  9118. computeTransformedInformation(): boolean;
  9119. /**
  9120. * Return the depth scale used for the shadow map.
  9121. * @returns the depth scale.
  9122. */
  9123. getDepthScale(): number;
  9124. /**
  9125. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9126. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9127. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9128. */
  9129. getShadowDirection(faceIndex?: number): Vector3;
  9130. /**
  9131. * Returns the ShadowLight absolute position in the World.
  9132. * @returns the position vector in world space
  9133. */
  9134. getAbsolutePosition(): Vector3;
  9135. /**
  9136. * Sets the ShadowLight direction toward the passed target.
  9137. * @param target The point to target in local space
  9138. * @returns the updated ShadowLight direction
  9139. */
  9140. setDirectionToTarget(target: Vector3): Vector3;
  9141. /**
  9142. * Returns the light rotation in euler definition.
  9143. * @returns the x y z rotation in local space.
  9144. */
  9145. getRotation(): Vector3;
  9146. /**
  9147. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9148. * @returns true if a cube texture needs to be use
  9149. */
  9150. needCube(): boolean;
  9151. /**
  9152. * Detects if the projection matrix requires to be recomputed this frame.
  9153. * @returns true if it requires to be recomputed otherwise, false.
  9154. */
  9155. needProjectionMatrixCompute(): boolean;
  9156. /**
  9157. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9158. */
  9159. forceProjectionMatrixCompute(): void;
  9160. /** @hidden */
  9161. _initCache(): void;
  9162. /** @hidden */
  9163. _isSynchronized(): boolean;
  9164. /**
  9165. * Computes the world matrix of the node
  9166. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9167. * @returns the world matrix
  9168. */
  9169. computeWorldMatrix(force?: boolean): Matrix;
  9170. /**
  9171. * Gets the minZ used for shadow according to both the scene and the light.
  9172. * @param activeCamera The camera we are returning the min for
  9173. * @returns the depth min z
  9174. */
  9175. getDepthMinZ(activeCamera: Camera): number;
  9176. /**
  9177. * Gets the maxZ used for shadow according to both the scene and the light.
  9178. * @param activeCamera The camera we are returning the max for
  9179. * @returns the depth max z
  9180. */
  9181. getDepthMaxZ(activeCamera: Camera): number;
  9182. /**
  9183. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9184. * @param matrix The materix to updated with the projection information
  9185. * @param viewMatrix The transform matrix of the light
  9186. * @param renderList The list of mesh to render in the map
  9187. * @returns The current light
  9188. */
  9189. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9190. }
  9191. }
  9192. declare module "babylonjs/Materials/materialHelper" {
  9193. import { Nullable } from "babylonjs/types";
  9194. import { Scene } from "babylonjs/scene";
  9195. import { Engine } from "babylonjs/Engines/engine";
  9196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9197. import { Light } from "babylonjs/Lights/light";
  9198. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9199. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9201. /**
  9202. * "Static Class" containing the most commonly used helper while dealing with material for
  9203. * rendering purpose.
  9204. *
  9205. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9206. *
  9207. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9208. */
  9209. export class MaterialHelper {
  9210. /**
  9211. * Bind the current view position to an effect.
  9212. * @param effect The effect to be bound
  9213. * @param scene The scene the eyes position is used from
  9214. */
  9215. static BindEyePosition(effect: Effect, scene: Scene): void;
  9216. /**
  9217. * Helps preparing the defines values about the UVs in used in the effect.
  9218. * UVs are shared as much as we can accross channels in the shaders.
  9219. * @param texture The texture we are preparing the UVs for
  9220. * @param defines The defines to update
  9221. * @param key The channel key "diffuse", "specular"... used in the shader
  9222. */
  9223. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9224. /**
  9225. * Binds a texture matrix value to its corrsponding uniform
  9226. * @param texture The texture to bind the matrix for
  9227. * @param uniformBuffer The uniform buffer receivin the data
  9228. * @param key The channel key "diffuse", "specular"... used in the shader
  9229. */
  9230. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9231. /**
  9232. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9233. * @param mesh defines the current mesh
  9234. * @param scene defines the current scene
  9235. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9236. * @param pointsCloud defines if point cloud rendering has to be turned on
  9237. * @param fogEnabled defines if fog has to be turned on
  9238. * @param alphaTest defines if alpha testing has to be turned on
  9239. * @param defines defines the current list of defines
  9240. */
  9241. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9242. /**
  9243. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9244. * @param scene defines the current scene
  9245. * @param engine defines the current engine
  9246. * @param defines specifies the list of active defines
  9247. * @param useInstances defines if instances have to be turned on
  9248. * @param useClipPlane defines if clip plane have to be turned on
  9249. */
  9250. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9251. /**
  9252. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9253. * @param mesh The mesh containing the geometry data we will draw
  9254. * @param defines The defines to update
  9255. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9256. * @param useBones Precise whether bones should be used or not (override mesh info)
  9257. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9258. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9259. * @returns false if defines are considered not dirty and have not been checked
  9260. */
  9261. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9262. /**
  9263. * Prepares the defines related to multiview
  9264. * @param scene The scene we are intending to draw
  9265. * @param defines The defines to update
  9266. */
  9267. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9268. /**
  9269. * Prepares the defines related to the light information passed in parameter
  9270. * @param scene The scene we are intending to draw
  9271. * @param mesh The mesh the effect is compiling for
  9272. * @param defines The defines to update
  9273. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9274. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9275. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9276. * @returns true if normals will be required for the rest of the effect
  9277. */
  9278. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9279. /**
  9280. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9281. * that won t be acctive due to defines being turned off.
  9282. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9283. * @param samplersList The samplers list
  9284. * @param defines The defines helping in the list generation
  9285. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9286. */
  9287. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9288. /**
  9289. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9290. * @param defines The defines to update while falling back
  9291. * @param fallbacks The authorized effect fallbacks
  9292. * @param maxSimultaneousLights The maximum number of lights allowed
  9293. * @param rank the current rank of the Effect
  9294. * @returns The newly affected rank
  9295. */
  9296. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9297. /**
  9298. * Prepares the list of attributes required for morph targets according to the effect defines.
  9299. * @param attribs The current list of supported attribs
  9300. * @param mesh The mesh to prepare the morph targets attributes for
  9301. * @param defines The current Defines of the effect
  9302. */
  9303. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9304. /**
  9305. * Prepares the list of attributes required for bones according to the effect defines.
  9306. * @param attribs The current list of supported attribs
  9307. * @param mesh The mesh to prepare the bones attributes for
  9308. * @param defines The current Defines of the effect
  9309. * @param fallbacks The current efffect fallback strategy
  9310. */
  9311. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9312. /**
  9313. * Prepares the list of attributes required for instances according to the effect defines.
  9314. * @param attribs The current list of supported attribs
  9315. * @param defines The current Defines of the effect
  9316. */
  9317. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9318. /**
  9319. * Binds the light shadow information to the effect for the given mesh.
  9320. * @param light The light containing the generator
  9321. * @param scene The scene the lights belongs to
  9322. * @param mesh The mesh we are binding the information to render
  9323. * @param lightIndex The light index in the effect used to render the mesh
  9324. * @param effect The effect we are binding the data to
  9325. */
  9326. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9327. /**
  9328. * Binds the light information to the effect.
  9329. * @param light The light containing the generator
  9330. * @param effect The effect we are binding the data to
  9331. * @param lightIndex The light index in the effect used to render
  9332. */
  9333. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9334. /**
  9335. * Binds the lights information from the scene to the effect for the given mesh.
  9336. * @param scene The scene the lights belongs to
  9337. * @param mesh The mesh we are binding the information to render
  9338. * @param effect The effect we are binding the data to
  9339. * @param defines The generated defines for the effect
  9340. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9341. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9342. */
  9343. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9344. private static _tempFogColor;
  9345. /**
  9346. * Binds the fog information from the scene to the effect for the given mesh.
  9347. * @param scene The scene the lights belongs to
  9348. * @param mesh The mesh we are binding the information to render
  9349. * @param effect The effect we are binding the data to
  9350. * @param linearSpace Defines if the fog effect is applied in linear space
  9351. */
  9352. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9353. /**
  9354. * Binds the bones information from the mesh to the effect.
  9355. * @param mesh The mesh we are binding the information to render
  9356. * @param effect The effect we are binding the data to
  9357. */
  9358. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9359. /**
  9360. * Binds the morph targets information from the mesh to the effect.
  9361. * @param abstractMesh The mesh we are binding the information to render
  9362. * @param effect The effect we are binding the data to
  9363. */
  9364. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9365. /**
  9366. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9367. * @param defines The generated defines used in the effect
  9368. * @param effect The effect we are binding the data to
  9369. * @param scene The scene we are willing to render with logarithmic scale for
  9370. */
  9371. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9372. /**
  9373. * Binds the clip plane information from the scene to the effect.
  9374. * @param scene The scene the clip plane information are extracted from
  9375. * @param effect The effect we are binding the data to
  9376. */
  9377. static BindClipPlane(effect: Effect, scene: Scene): void;
  9378. }
  9379. }
  9380. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9381. /** @hidden */
  9382. export var kernelBlurVaryingDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9388. /** @hidden */
  9389. export var kernelBlurFragment: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9395. /** @hidden */
  9396. export var kernelBlurFragment2: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9402. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9403. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9404. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9405. /** @hidden */
  9406. export var kernelBlurPixelShader: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9412. /** @hidden */
  9413. export var kernelBlurVertex: {
  9414. name: string;
  9415. shader: string;
  9416. };
  9417. }
  9418. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9419. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9420. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9421. /** @hidden */
  9422. export var kernelBlurVertexShader: {
  9423. name: string;
  9424. shader: string;
  9425. };
  9426. }
  9427. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9428. import { Vector2 } from "babylonjs/Maths/math";
  9429. import { Nullable } from "babylonjs/types";
  9430. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9431. import { Camera } from "babylonjs/Cameras/camera";
  9432. import { Effect } from "babylonjs/Materials/effect";
  9433. import { Engine } from "babylonjs/Engines/engine";
  9434. import "babylonjs/Shaders/kernelBlur.fragment";
  9435. import "babylonjs/Shaders/kernelBlur.vertex";
  9436. /**
  9437. * The Blur Post Process which blurs an image based on a kernel and direction.
  9438. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9439. */
  9440. export class BlurPostProcess extends PostProcess {
  9441. /** The direction in which to blur the image. */
  9442. direction: Vector2;
  9443. private blockCompilation;
  9444. protected _kernel: number;
  9445. protected _idealKernel: number;
  9446. protected _packedFloat: boolean;
  9447. private _staticDefines;
  9448. /**
  9449. * Sets the length in pixels of the blur sample region
  9450. */
  9451. /**
  9452. * Gets the length in pixels of the blur sample region
  9453. */
  9454. kernel: number;
  9455. /**
  9456. * Sets wether or not the blur needs to unpack/repack floats
  9457. */
  9458. /**
  9459. * Gets wether or not the blur is unpacking/repacking floats
  9460. */
  9461. packedFloat: boolean;
  9462. /**
  9463. * Creates a new instance BlurPostProcess
  9464. * @param name The name of the effect.
  9465. * @param direction The direction in which to blur the image.
  9466. * @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.
  9467. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9468. * @param camera The camera to apply the render pass to.
  9469. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9470. * @param engine The engine which the post process will be applied. (default: current engine)
  9471. * @param reusable If the post process can be reused on the same frame. (default: false)
  9472. * @param textureType Type of textures used when performing the post process. (default: 0)
  9473. * @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)
  9474. */
  9475. constructor(name: string,
  9476. /** The direction in which to blur the image. */
  9477. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9478. /**
  9479. * Updates the effect with the current post process compile time values and recompiles the shader.
  9480. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9481. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9482. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9483. * @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
  9484. * @param onCompiled Called when the shader has been compiled.
  9485. * @param onError Called if there is an error when compiling a shader.
  9486. */
  9487. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9488. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9489. /**
  9490. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9491. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9492. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9493. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9494. * The gaps between physical kernels are compensated for in the weighting of the samples
  9495. * @param idealKernel Ideal blur kernel.
  9496. * @return Nearest best kernel.
  9497. */
  9498. protected _nearestBestKernel(idealKernel: number): number;
  9499. /**
  9500. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9501. * @param x The point on the Gaussian distribution to sample.
  9502. * @return the value of the Gaussian function at x.
  9503. */
  9504. protected _gaussianWeight(x: number): number;
  9505. /**
  9506. * Generates a string that can be used as a floating point number in GLSL.
  9507. * @param x Value to print.
  9508. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9509. * @return GLSL float string.
  9510. */
  9511. protected _glslFloat(x: number, decimalFigures?: number): string;
  9512. }
  9513. }
  9514. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9515. /** @hidden */
  9516. export var shadowMapPixelShader: {
  9517. name: string;
  9518. shader: string;
  9519. };
  9520. }
  9521. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9522. /** @hidden */
  9523. export var bonesDeclaration: {
  9524. name: string;
  9525. shader: string;
  9526. };
  9527. }
  9528. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9529. /** @hidden */
  9530. export var morphTargetsVertexGlobalDeclaration: {
  9531. name: string;
  9532. shader: string;
  9533. };
  9534. }
  9535. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9536. /** @hidden */
  9537. export var morphTargetsVertexDeclaration: {
  9538. name: string;
  9539. shader: string;
  9540. };
  9541. }
  9542. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9543. /** @hidden */
  9544. export var instancesDeclaration: {
  9545. name: string;
  9546. shader: string;
  9547. };
  9548. }
  9549. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9550. /** @hidden */
  9551. export var helperFunctions: {
  9552. name: string;
  9553. shader: string;
  9554. };
  9555. }
  9556. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9557. /** @hidden */
  9558. export var morphTargetsVertex: {
  9559. name: string;
  9560. shader: string;
  9561. };
  9562. }
  9563. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9564. /** @hidden */
  9565. export var instancesVertex: {
  9566. name: string;
  9567. shader: string;
  9568. };
  9569. }
  9570. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9571. /** @hidden */
  9572. export var bonesVertex: {
  9573. name: string;
  9574. shader: string;
  9575. };
  9576. }
  9577. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9578. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9579. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9580. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9581. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9582. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9583. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9584. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9585. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9586. /** @hidden */
  9587. export var shadowMapVertexShader: {
  9588. name: string;
  9589. shader: string;
  9590. };
  9591. }
  9592. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9593. /** @hidden */
  9594. export var depthBoxBlurPixelShader: {
  9595. name: string;
  9596. shader: string;
  9597. };
  9598. }
  9599. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9600. import { Nullable } from "babylonjs/types";
  9601. import { Scene } from "babylonjs/scene";
  9602. import { Matrix } from "babylonjs/Maths/math";
  9603. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9605. import { Mesh } from "babylonjs/Meshes/mesh";
  9606. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9607. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9608. import { Effect } from "babylonjs/Materials/effect";
  9609. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9610. import "babylonjs/Shaders/shadowMap.fragment";
  9611. import "babylonjs/Shaders/shadowMap.vertex";
  9612. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9613. import { Observable } from "babylonjs/Misc/observable";
  9614. /**
  9615. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9616. */
  9617. export interface ICustomShaderOptions {
  9618. /**
  9619. * Gets or sets the custom shader name to use
  9620. */
  9621. shaderName: string;
  9622. /**
  9623. * The list of attribute names used in the shader
  9624. */
  9625. attributes?: string[];
  9626. /**
  9627. * The list of unifrom names used in the shader
  9628. */
  9629. uniforms?: string[];
  9630. /**
  9631. * The list of sampler names used in the shader
  9632. */
  9633. samplers?: string[];
  9634. /**
  9635. * The list of defines used in the shader
  9636. */
  9637. defines?: string[];
  9638. }
  9639. /**
  9640. * Interface to implement to create a shadow generator compatible with BJS.
  9641. */
  9642. export interface IShadowGenerator {
  9643. /**
  9644. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9645. * @returns The render target texture if present otherwise, null
  9646. */
  9647. getShadowMap(): Nullable<RenderTargetTexture>;
  9648. /**
  9649. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9650. * @returns The render target texture if the shadow map is present otherwise, null
  9651. */
  9652. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9653. /**
  9654. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9655. * @param subMesh The submesh we want to render in the shadow map
  9656. * @param useInstances Defines wether will draw in the map using instances
  9657. * @returns true if ready otherwise, false
  9658. */
  9659. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9660. /**
  9661. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9662. * @param defines Defines of the material we want to update
  9663. * @param lightIndex Index of the light in the enabled light list of the material
  9664. */
  9665. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9666. /**
  9667. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9668. * defined in the generator but impacting the effect).
  9669. * It implies the unifroms available on the materials are the standard BJS ones.
  9670. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9671. * @param effect The effect we are binfing the information for
  9672. */
  9673. bindShadowLight(lightIndex: string, effect: Effect): void;
  9674. /**
  9675. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9676. * (eq to shadow prjection matrix * light transform matrix)
  9677. * @returns The transform matrix used to create the shadow map
  9678. */
  9679. getTransformMatrix(): Matrix;
  9680. /**
  9681. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9682. * Cube and 2D textures for instance.
  9683. */
  9684. recreateShadowMap(): void;
  9685. /**
  9686. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9687. * @param onCompiled Callback triggered at the and of the effects compilation
  9688. * @param options Sets of optional options forcing the compilation with different modes
  9689. */
  9690. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9691. useInstances: boolean;
  9692. }>): void;
  9693. /**
  9694. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9695. * @param options Sets of optional options forcing the compilation with different modes
  9696. * @returns A promise that resolves when the compilation completes
  9697. */
  9698. forceCompilationAsync(options?: Partial<{
  9699. useInstances: boolean;
  9700. }>): Promise<void>;
  9701. /**
  9702. * Serializes the shadow generator setup to a json object.
  9703. * @returns The serialized JSON object
  9704. */
  9705. serialize(): any;
  9706. /**
  9707. * Disposes the Shadow map and related Textures and effects.
  9708. */
  9709. dispose(): void;
  9710. }
  9711. /**
  9712. * Default implementation IShadowGenerator.
  9713. * This is the main object responsible of generating shadows in the framework.
  9714. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9715. */
  9716. export class ShadowGenerator implements IShadowGenerator {
  9717. /**
  9718. * Shadow generator mode None: no filtering applied.
  9719. */
  9720. static readonly FILTER_NONE: number;
  9721. /**
  9722. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9723. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9724. */
  9725. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9726. /**
  9727. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9728. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9729. */
  9730. static readonly FILTER_POISSONSAMPLING: number;
  9731. /**
  9732. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9733. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9734. */
  9735. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9736. /**
  9737. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9738. * edge artifacts on steep falloff.
  9739. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9740. */
  9741. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9742. /**
  9743. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9744. * edge artifacts on steep falloff.
  9745. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9746. */
  9747. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9748. /**
  9749. * Shadow generator mode PCF: Percentage Closer Filtering
  9750. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9751. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9752. */
  9753. static readonly FILTER_PCF: number;
  9754. /**
  9755. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9756. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9757. * Contact Hardening
  9758. */
  9759. static readonly FILTER_PCSS: number;
  9760. /**
  9761. * Reserved for PCF and PCSS
  9762. * Highest Quality.
  9763. *
  9764. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9765. *
  9766. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9767. */
  9768. static readonly QUALITY_HIGH: number;
  9769. /**
  9770. * Reserved for PCF and PCSS
  9771. * Good tradeoff for quality/perf cross devices
  9772. *
  9773. * Execute PCF on a 3*3 kernel.
  9774. *
  9775. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9776. */
  9777. static readonly QUALITY_MEDIUM: number;
  9778. /**
  9779. * Reserved for PCF and PCSS
  9780. * The lowest quality but the fastest.
  9781. *
  9782. * Execute PCF on a 1*1 kernel.
  9783. *
  9784. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9785. */
  9786. static readonly QUALITY_LOW: number;
  9787. /** Gets or sets the custom shader name to use */
  9788. customShaderOptions: ICustomShaderOptions;
  9789. /**
  9790. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9791. */
  9792. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9793. /**
  9794. * Observable triggered before a mesh is rendered in the shadow map.
  9795. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9796. */
  9797. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9798. private _bias;
  9799. /**
  9800. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9801. */
  9802. /**
  9803. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9804. */
  9805. bias: number;
  9806. private _normalBias;
  9807. /**
  9808. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9809. */
  9810. /**
  9811. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9812. */
  9813. normalBias: number;
  9814. private _blurBoxOffset;
  9815. /**
  9816. * Gets the blur box offset: offset applied during the blur pass.
  9817. * Only useful if useKernelBlur = false
  9818. */
  9819. /**
  9820. * Sets the blur box offset: offset applied during the blur pass.
  9821. * Only useful if useKernelBlur = false
  9822. */
  9823. blurBoxOffset: number;
  9824. private _blurScale;
  9825. /**
  9826. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9827. * 2 means half of the size.
  9828. */
  9829. /**
  9830. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9831. * 2 means half of the size.
  9832. */
  9833. blurScale: number;
  9834. private _blurKernel;
  9835. /**
  9836. * Gets the blur kernel: kernel size of the blur pass.
  9837. * Only useful if useKernelBlur = true
  9838. */
  9839. /**
  9840. * Sets the blur kernel: kernel size of the blur pass.
  9841. * Only useful if useKernelBlur = true
  9842. */
  9843. blurKernel: number;
  9844. private _useKernelBlur;
  9845. /**
  9846. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9847. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9848. */
  9849. /**
  9850. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9851. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9852. */
  9853. useKernelBlur: boolean;
  9854. private _depthScale;
  9855. /**
  9856. * Gets the depth scale used in ESM mode.
  9857. */
  9858. /**
  9859. * Sets the depth scale used in ESM mode.
  9860. * This can override the scale stored on the light.
  9861. */
  9862. depthScale: number;
  9863. private _filter;
  9864. /**
  9865. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9866. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9867. */
  9868. /**
  9869. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9870. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9871. */
  9872. filter: number;
  9873. /**
  9874. * Gets if the current filter is set to Poisson Sampling.
  9875. */
  9876. /**
  9877. * Sets the current filter to Poisson Sampling.
  9878. */
  9879. usePoissonSampling: boolean;
  9880. /**
  9881. * Gets if the current filter is set to ESM.
  9882. */
  9883. /**
  9884. * Sets the current filter is to ESM.
  9885. */
  9886. useExponentialShadowMap: boolean;
  9887. /**
  9888. * Gets if the current filter is set to filtered ESM.
  9889. */
  9890. /**
  9891. * Gets if the current filter is set to filtered ESM.
  9892. */
  9893. useBlurExponentialShadowMap: boolean;
  9894. /**
  9895. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9896. * exponential to prevent steep falloff artifacts).
  9897. */
  9898. /**
  9899. * Sets the current filter to "close ESM" (using the inverse of the
  9900. * exponential to prevent steep falloff artifacts).
  9901. */
  9902. useCloseExponentialShadowMap: boolean;
  9903. /**
  9904. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9905. * exponential to prevent steep falloff artifacts).
  9906. */
  9907. /**
  9908. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9909. * exponential to prevent steep falloff artifacts).
  9910. */
  9911. useBlurCloseExponentialShadowMap: boolean;
  9912. /**
  9913. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9914. */
  9915. /**
  9916. * Sets the current filter to "PCF" (percentage closer filtering).
  9917. */
  9918. usePercentageCloserFiltering: boolean;
  9919. private _filteringQuality;
  9920. /**
  9921. * Gets the PCF or PCSS Quality.
  9922. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9923. */
  9924. /**
  9925. * Sets the PCF or PCSS Quality.
  9926. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9927. */
  9928. filteringQuality: number;
  9929. /**
  9930. * Gets if the current filter is set to "PCSS" (contact hardening).
  9931. */
  9932. /**
  9933. * Sets the current filter to "PCSS" (contact hardening).
  9934. */
  9935. useContactHardeningShadow: boolean;
  9936. private _contactHardeningLightSizeUVRatio;
  9937. /**
  9938. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9939. * Using a ratio helps keeping shape stability independently of the map size.
  9940. *
  9941. * It does not account for the light projection as it was having too much
  9942. * instability during the light setup or during light position changes.
  9943. *
  9944. * Only valid if useContactHardeningShadow is true.
  9945. */
  9946. /**
  9947. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9948. * Using a ratio helps keeping shape stability independently of the map size.
  9949. *
  9950. * It does not account for the light projection as it was having too much
  9951. * instability during the light setup or during light position changes.
  9952. *
  9953. * Only valid if useContactHardeningShadow is true.
  9954. */
  9955. contactHardeningLightSizeUVRatio: number;
  9956. private _darkness;
  9957. /**
  9958. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9959. * 0 means strongest and 1 would means no shadow.
  9960. * @returns the darkness.
  9961. */
  9962. getDarkness(): number;
  9963. /**
  9964. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9965. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9966. * @returns the shadow generator allowing fluent coding.
  9967. */
  9968. setDarkness(darkness: number): ShadowGenerator;
  9969. private _transparencyShadow;
  9970. /**
  9971. * Sets the ability to have transparent shadow (boolean).
  9972. * @param transparent True if transparent else False
  9973. * @returns the shadow generator allowing fluent coding
  9974. */
  9975. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9976. private _shadowMap;
  9977. private _shadowMap2;
  9978. /**
  9979. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9980. * @returns The render target texture if present otherwise, null
  9981. */
  9982. getShadowMap(): Nullable<RenderTargetTexture>;
  9983. /**
  9984. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9985. * @returns The render target texture if the shadow map is present otherwise, null
  9986. */
  9987. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9988. /**
  9989. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9990. * @param mesh Mesh to add
  9991. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9992. * @returns the Shadow Generator itself
  9993. */
  9994. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9995. /**
  9996. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9997. * @param mesh Mesh to remove
  9998. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9999. * @returns the Shadow Generator itself
  10000. */
  10001. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10002. /**
  10003. * Controls the extent to which the shadows fade out at the edge of the frustum
  10004. * Used only by directionals and spots
  10005. */
  10006. frustumEdgeFalloff: number;
  10007. private _light;
  10008. /**
  10009. * Returns the associated light object.
  10010. * @returns the light generating the shadow
  10011. */
  10012. getLight(): IShadowLight;
  10013. /**
  10014. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10015. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10016. * It might on the other hand introduce peter panning.
  10017. */
  10018. forceBackFacesOnly: boolean;
  10019. private _scene;
  10020. private _lightDirection;
  10021. private _effect;
  10022. private _viewMatrix;
  10023. private _projectionMatrix;
  10024. private _transformMatrix;
  10025. private _cachedPosition;
  10026. private _cachedDirection;
  10027. private _cachedDefines;
  10028. private _currentRenderID;
  10029. private _boxBlurPostprocess;
  10030. private _kernelBlurXPostprocess;
  10031. private _kernelBlurYPostprocess;
  10032. private _blurPostProcesses;
  10033. private _mapSize;
  10034. private _currentFaceIndex;
  10035. private _currentFaceIndexCache;
  10036. private _textureType;
  10037. private _defaultTextureMatrix;
  10038. /** @hidden */
  10039. static _SceneComponentInitialization: (scene: Scene) => void;
  10040. /**
  10041. * Creates a ShadowGenerator object.
  10042. * A ShadowGenerator is the required tool to use the shadows.
  10043. * Each light casting shadows needs to use its own ShadowGenerator.
  10044. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10045. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10046. * @param light The light object generating the shadows.
  10047. * @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.
  10048. */
  10049. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10050. private _initializeGenerator;
  10051. private _initializeShadowMap;
  10052. private _initializeBlurRTTAndPostProcesses;
  10053. private _renderForShadowMap;
  10054. private _renderSubMeshForShadowMap;
  10055. private _applyFilterValues;
  10056. /**
  10057. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10058. * @param onCompiled Callback triggered at the and of the effects compilation
  10059. * @param options Sets of optional options forcing the compilation with different modes
  10060. */
  10061. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10062. useInstances: boolean;
  10063. }>): void;
  10064. /**
  10065. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10066. * @param options Sets of optional options forcing the compilation with different modes
  10067. * @returns A promise that resolves when the compilation completes
  10068. */
  10069. forceCompilationAsync(options?: Partial<{
  10070. useInstances: boolean;
  10071. }>): Promise<void>;
  10072. /**
  10073. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10074. * @param subMesh The submesh we want to render in the shadow map
  10075. * @param useInstances Defines wether will draw in the map using instances
  10076. * @returns true if ready otherwise, false
  10077. */
  10078. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10079. /**
  10080. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10081. * @param defines Defines of the material we want to update
  10082. * @param lightIndex Index of the light in the enabled light list of the material
  10083. */
  10084. prepareDefines(defines: any, lightIndex: number): void;
  10085. /**
  10086. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10087. * defined in the generator but impacting the effect).
  10088. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10089. * @param effect The effect we are binfing the information for
  10090. */
  10091. bindShadowLight(lightIndex: string, effect: Effect): void;
  10092. /**
  10093. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10094. * (eq to shadow prjection matrix * light transform matrix)
  10095. * @returns The transform matrix used to create the shadow map
  10096. */
  10097. getTransformMatrix(): Matrix;
  10098. /**
  10099. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10100. * Cube and 2D textures for instance.
  10101. */
  10102. recreateShadowMap(): void;
  10103. private _disposeBlurPostProcesses;
  10104. private _disposeRTTandPostProcesses;
  10105. /**
  10106. * Disposes the ShadowGenerator.
  10107. * Returns nothing.
  10108. */
  10109. dispose(): void;
  10110. /**
  10111. * Serializes the shadow generator setup to a json object.
  10112. * @returns The serialized JSON object
  10113. */
  10114. serialize(): any;
  10115. /**
  10116. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10117. * @param parsedShadowGenerator The JSON object to parse
  10118. * @param scene The scene to create the shadow map for
  10119. * @returns The parsed shadow generator
  10120. */
  10121. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10122. }
  10123. }
  10124. declare module "babylonjs/Lights/light" {
  10125. import { Nullable } from "babylonjs/types";
  10126. import { Scene } from "babylonjs/scene";
  10127. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10128. import { Node } from "babylonjs/node";
  10129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10130. import { Effect } from "babylonjs/Materials/effect";
  10131. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10132. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10133. /**
  10134. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10135. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10136. * 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.
  10137. */
  10138. export abstract class Light extends Node {
  10139. /**
  10140. * Falloff Default: light is falling off following the material specification:
  10141. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10142. */
  10143. static readonly FALLOFF_DEFAULT: number;
  10144. /**
  10145. * Falloff Physical: light is falling off following the inverse squared distance law.
  10146. */
  10147. static readonly FALLOFF_PHYSICAL: number;
  10148. /**
  10149. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10150. * to enhance interoperability with other engines.
  10151. */
  10152. static readonly FALLOFF_GLTF: number;
  10153. /**
  10154. * Falloff Standard: light is falling off like in the standard material
  10155. * to enhance interoperability with other materials.
  10156. */
  10157. static readonly FALLOFF_STANDARD: number;
  10158. /**
  10159. * If every light affecting the material is in this lightmapMode,
  10160. * material.lightmapTexture adds or multiplies
  10161. * (depends on material.useLightmapAsShadowmap)
  10162. * after every other light calculations.
  10163. */
  10164. static readonly LIGHTMAP_DEFAULT: number;
  10165. /**
  10166. * material.lightmapTexture as only diffuse lighting from this light
  10167. * adds only specular lighting from this light
  10168. * adds dynamic shadows
  10169. */
  10170. static readonly LIGHTMAP_SPECULAR: number;
  10171. /**
  10172. * material.lightmapTexture as only lighting
  10173. * no light calculation from this light
  10174. * only adds dynamic shadows from this light
  10175. */
  10176. static readonly LIGHTMAP_SHADOWSONLY: number;
  10177. /**
  10178. * Each light type uses the default quantity according to its type:
  10179. * point/spot lights use luminous intensity
  10180. * directional lights use illuminance
  10181. */
  10182. static readonly INTENSITYMODE_AUTOMATIC: number;
  10183. /**
  10184. * lumen (lm)
  10185. */
  10186. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10187. /**
  10188. * candela (lm/sr)
  10189. */
  10190. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10191. /**
  10192. * lux (lm/m^2)
  10193. */
  10194. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10195. /**
  10196. * nit (cd/m^2)
  10197. */
  10198. static readonly INTENSITYMODE_LUMINANCE: number;
  10199. /**
  10200. * Light type const id of the point light.
  10201. */
  10202. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10203. /**
  10204. * Light type const id of the directional light.
  10205. */
  10206. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10207. /**
  10208. * Light type const id of the spot light.
  10209. */
  10210. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10211. /**
  10212. * Light type const id of the hemispheric light.
  10213. */
  10214. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10215. /**
  10216. * Diffuse gives the basic color to an object.
  10217. */
  10218. diffuse: Color3;
  10219. /**
  10220. * Specular produces a highlight color on an object.
  10221. * Note: This is note affecting PBR materials.
  10222. */
  10223. specular: Color3;
  10224. /**
  10225. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10226. * falling off base on range or angle.
  10227. * This can be set to any values in Light.FALLOFF_x.
  10228. *
  10229. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10230. * other types of materials.
  10231. */
  10232. falloffType: number;
  10233. /**
  10234. * Strength of the light.
  10235. * Note: By default it is define in the framework own unit.
  10236. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10237. */
  10238. intensity: number;
  10239. private _range;
  10240. protected _inverseSquaredRange: number;
  10241. /**
  10242. * Defines how far from the source the light is impacting in scene units.
  10243. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10244. */
  10245. /**
  10246. * Defines how far from the source the light is impacting in scene units.
  10247. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10248. */
  10249. range: number;
  10250. /**
  10251. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10252. * of light.
  10253. */
  10254. private _photometricScale;
  10255. private _intensityMode;
  10256. /**
  10257. * Gets the photometric scale used to interpret the intensity.
  10258. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10259. */
  10260. /**
  10261. * Sets the photometric scale used to interpret the intensity.
  10262. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10263. */
  10264. intensityMode: number;
  10265. private _radius;
  10266. /**
  10267. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10268. */
  10269. /**
  10270. * sets the light radius used by PBR Materials to simulate soft area lights.
  10271. */
  10272. radius: number;
  10273. private _renderPriority;
  10274. /**
  10275. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10276. * exceeding the number allowed of the materials.
  10277. */
  10278. renderPriority: number;
  10279. private _shadowEnabled;
  10280. /**
  10281. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10282. * the current shadow generator.
  10283. */
  10284. /**
  10285. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10286. * the current shadow generator.
  10287. */
  10288. shadowEnabled: boolean;
  10289. private _includedOnlyMeshes;
  10290. /**
  10291. * Gets the only meshes impacted by this light.
  10292. */
  10293. /**
  10294. * Sets the only meshes impacted by this light.
  10295. */
  10296. includedOnlyMeshes: AbstractMesh[];
  10297. private _excludedMeshes;
  10298. /**
  10299. * Gets the meshes not impacted by this light.
  10300. */
  10301. /**
  10302. * Sets the meshes not impacted by this light.
  10303. */
  10304. excludedMeshes: AbstractMesh[];
  10305. private _excludeWithLayerMask;
  10306. /**
  10307. * Gets the layer id use to find what meshes are not impacted by the light.
  10308. * Inactive if 0
  10309. */
  10310. /**
  10311. * Sets the layer id use to find what meshes are not impacted by the light.
  10312. * Inactive if 0
  10313. */
  10314. excludeWithLayerMask: number;
  10315. private _includeOnlyWithLayerMask;
  10316. /**
  10317. * Gets the layer id use to find what meshes are impacted by the light.
  10318. * Inactive if 0
  10319. */
  10320. /**
  10321. * Sets the layer id use to find what meshes are impacted by the light.
  10322. * Inactive if 0
  10323. */
  10324. includeOnlyWithLayerMask: number;
  10325. private _lightmapMode;
  10326. /**
  10327. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10328. */
  10329. /**
  10330. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10331. */
  10332. lightmapMode: number;
  10333. /**
  10334. * Shadow generator associted to the light.
  10335. * @hidden Internal use only.
  10336. */
  10337. _shadowGenerator: Nullable<IShadowGenerator>;
  10338. /**
  10339. * @hidden Internal use only.
  10340. */
  10341. _excludedMeshesIds: string[];
  10342. /**
  10343. * @hidden Internal use only.
  10344. */
  10345. _includedOnlyMeshesIds: string[];
  10346. /**
  10347. * The current light unifom buffer.
  10348. * @hidden Internal use only.
  10349. */
  10350. _uniformBuffer: UniformBuffer;
  10351. /**
  10352. * Creates a Light object in the scene.
  10353. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10354. * @param name The firendly name of the light
  10355. * @param scene The scene the light belongs too
  10356. */
  10357. constructor(name: string, scene: Scene);
  10358. protected abstract _buildUniformLayout(): void;
  10359. /**
  10360. * Sets the passed Effect "effect" with the Light information.
  10361. * @param effect The effect to update
  10362. * @param lightIndex The index of the light in the effect to update
  10363. * @returns The light
  10364. */
  10365. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10366. /**
  10367. * Returns the string "Light".
  10368. * @returns the class name
  10369. */
  10370. getClassName(): string;
  10371. /** @hidden */
  10372. readonly _isLight: boolean;
  10373. /**
  10374. * Converts the light information to a readable string for debug purpose.
  10375. * @param fullDetails Supports for multiple levels of logging within scene loading
  10376. * @returns the human readable light info
  10377. */
  10378. toString(fullDetails?: boolean): string;
  10379. /** @hidden */
  10380. protected _syncParentEnabledState(): void;
  10381. /**
  10382. * Set the enabled state of this node.
  10383. * @param value - the new enabled state
  10384. */
  10385. setEnabled(value: boolean): void;
  10386. /**
  10387. * Returns the Light associated shadow generator if any.
  10388. * @return the associated shadow generator.
  10389. */
  10390. getShadowGenerator(): Nullable<IShadowGenerator>;
  10391. /**
  10392. * Returns a Vector3, the absolute light position in the World.
  10393. * @returns the world space position of the light
  10394. */
  10395. getAbsolutePosition(): Vector3;
  10396. /**
  10397. * Specifies if the light will affect the passed mesh.
  10398. * @param mesh The mesh to test against the light
  10399. * @return true the mesh is affected otherwise, false.
  10400. */
  10401. canAffectMesh(mesh: AbstractMesh): boolean;
  10402. /**
  10403. * Sort function to order lights for rendering.
  10404. * @param a First Light object to compare to second.
  10405. * @param b Second Light object to compare first.
  10406. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10407. */
  10408. static CompareLightsPriority(a: Light, b: Light): number;
  10409. /**
  10410. * Releases resources associated with this node.
  10411. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10412. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10413. */
  10414. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10415. /**
  10416. * Returns the light type ID (integer).
  10417. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10418. */
  10419. getTypeID(): number;
  10420. /**
  10421. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10422. * @returns the scaled intensity in intensity mode unit
  10423. */
  10424. getScaledIntensity(): number;
  10425. /**
  10426. * Returns a new Light object, named "name", from the current one.
  10427. * @param name The name of the cloned light
  10428. * @returns the new created light
  10429. */
  10430. clone(name: string): Nullable<Light>;
  10431. /**
  10432. * Serializes the current light into a Serialization object.
  10433. * @returns the serialized object.
  10434. */
  10435. serialize(): any;
  10436. /**
  10437. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10438. * This new light is named "name" and added to the passed scene.
  10439. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10440. * @param name The friendly name of the light
  10441. * @param scene The scene the new light will belong to
  10442. * @returns the constructor function
  10443. */
  10444. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10445. /**
  10446. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10447. * @param parsedLight The JSON representation of the light
  10448. * @param scene The scene to create the parsed light in
  10449. * @returns the created light after parsing
  10450. */
  10451. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10452. private _hookArrayForExcluded;
  10453. private _hookArrayForIncludedOnly;
  10454. private _resyncMeshes;
  10455. /**
  10456. * Forces the meshes to update their light related information in their rendering used effects
  10457. * @hidden Internal Use Only
  10458. */
  10459. _markMeshesAsLightDirty(): void;
  10460. /**
  10461. * Recomputes the cached photometric scale if needed.
  10462. */
  10463. private _computePhotometricScale;
  10464. /**
  10465. * Returns the Photometric Scale according to the light type and intensity mode.
  10466. */
  10467. private _getPhotometricScale;
  10468. /**
  10469. * Reorder the light in the scene according to their defined priority.
  10470. * @hidden Internal Use Only
  10471. */
  10472. _reorderLightsInScene(): void;
  10473. /**
  10474. * Prepares the list of defines specific to the light type.
  10475. * @param defines the list of defines
  10476. * @param lightIndex defines the index of the light for the effect
  10477. */
  10478. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10479. }
  10480. }
  10481. declare module "babylonjs/Actions/action" {
  10482. import { Observable } from "babylonjs/Misc/observable";
  10483. import { Condition } from "babylonjs/Actions/condition";
  10484. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10485. import { ActionManager } from "babylonjs/Actions/actionManager";
  10486. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10487. /**
  10488. * Interface used to define Action
  10489. */
  10490. export interface IAction {
  10491. /**
  10492. * Trigger for the action
  10493. */
  10494. trigger: number;
  10495. /** Options of the trigger */
  10496. triggerOptions: any;
  10497. /**
  10498. * Gets the trigger parameters
  10499. * @returns the trigger parameters
  10500. */
  10501. getTriggerParameter(): any;
  10502. /**
  10503. * Internal only - executes current action event
  10504. * @hidden
  10505. */
  10506. _executeCurrent(evt?: ActionEvent): void;
  10507. /**
  10508. * Serialize placeholder for child classes
  10509. * @param parent of child
  10510. * @returns the serialized object
  10511. */
  10512. serialize(parent: any): any;
  10513. /**
  10514. * Internal only
  10515. * @hidden
  10516. */
  10517. _prepare(): void;
  10518. /**
  10519. * Internal only - manager for action
  10520. * @hidden
  10521. */
  10522. _actionManager: AbstractActionManager;
  10523. }
  10524. /**
  10525. * The action to be carried out following a trigger
  10526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10527. */
  10528. export class Action implements IAction {
  10529. /** the trigger, with or without parameters, for the action */
  10530. triggerOptions: any;
  10531. /**
  10532. * Trigger for the action
  10533. */
  10534. trigger: number;
  10535. /**
  10536. * Internal only - manager for action
  10537. * @hidden
  10538. */
  10539. _actionManager: ActionManager;
  10540. private _nextActiveAction;
  10541. private _child;
  10542. private _condition?;
  10543. private _triggerParameter;
  10544. /**
  10545. * An event triggered prior to action being executed.
  10546. */
  10547. onBeforeExecuteObservable: Observable<Action>;
  10548. /**
  10549. * Creates a new Action
  10550. * @param triggerOptions the trigger, with or without parameters, for the action
  10551. * @param condition an optional determinant of action
  10552. */
  10553. constructor(
  10554. /** the trigger, with or without parameters, for the action */
  10555. triggerOptions: any, condition?: Condition);
  10556. /**
  10557. * Internal only
  10558. * @hidden
  10559. */
  10560. _prepare(): void;
  10561. /**
  10562. * Gets the trigger parameters
  10563. * @returns the trigger parameters
  10564. */
  10565. getTriggerParameter(): any;
  10566. /**
  10567. * Internal only - executes current action event
  10568. * @hidden
  10569. */
  10570. _executeCurrent(evt?: ActionEvent): void;
  10571. /**
  10572. * Execute placeholder for child classes
  10573. * @param evt optional action event
  10574. */
  10575. execute(evt?: ActionEvent): void;
  10576. /**
  10577. * Skips to next active action
  10578. */
  10579. skipToNextActiveAction(): void;
  10580. /**
  10581. * Adds action to chain of actions, may be a DoNothingAction
  10582. * @param action defines the next action to execute
  10583. * @returns The action passed in
  10584. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10585. */
  10586. then(action: Action): Action;
  10587. /**
  10588. * Internal only
  10589. * @hidden
  10590. */
  10591. _getProperty(propertyPath: string): string;
  10592. /**
  10593. * Internal only
  10594. * @hidden
  10595. */
  10596. _getEffectiveTarget(target: any, propertyPath: string): any;
  10597. /**
  10598. * Serialize placeholder for child classes
  10599. * @param parent of child
  10600. * @returns the serialized object
  10601. */
  10602. serialize(parent: any): any;
  10603. /**
  10604. * Internal only called by serialize
  10605. * @hidden
  10606. */
  10607. protected _serialize(serializedAction: any, parent?: any): any;
  10608. /**
  10609. * Internal only
  10610. * @hidden
  10611. */
  10612. static _SerializeValueAsString: (value: any) => string;
  10613. /**
  10614. * Internal only
  10615. * @hidden
  10616. */
  10617. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10618. name: string;
  10619. targetType: string;
  10620. value: string;
  10621. };
  10622. }
  10623. }
  10624. declare module "babylonjs/Actions/condition" {
  10625. import { ActionManager } from "babylonjs/Actions/actionManager";
  10626. /**
  10627. * A Condition applied to an Action
  10628. */
  10629. export class Condition {
  10630. /**
  10631. * Internal only - manager for action
  10632. * @hidden
  10633. */
  10634. _actionManager: ActionManager;
  10635. /**
  10636. * Internal only
  10637. * @hidden
  10638. */
  10639. _evaluationId: number;
  10640. /**
  10641. * Internal only
  10642. * @hidden
  10643. */
  10644. _currentResult: boolean;
  10645. /**
  10646. * Creates a new Condition
  10647. * @param actionManager the manager of the action the condition is applied to
  10648. */
  10649. constructor(actionManager: ActionManager);
  10650. /**
  10651. * Check if the current condition is valid
  10652. * @returns a boolean
  10653. */
  10654. isValid(): boolean;
  10655. /**
  10656. * Internal only
  10657. * @hidden
  10658. */
  10659. _getProperty(propertyPath: string): string;
  10660. /**
  10661. * Internal only
  10662. * @hidden
  10663. */
  10664. _getEffectiveTarget(target: any, propertyPath: string): any;
  10665. /**
  10666. * Serialize placeholder for child classes
  10667. * @returns the serialized object
  10668. */
  10669. serialize(): any;
  10670. /**
  10671. * Internal only
  10672. * @hidden
  10673. */
  10674. protected _serialize(serializedCondition: any): any;
  10675. }
  10676. /**
  10677. * Defines specific conditional operators as extensions of Condition
  10678. */
  10679. export class ValueCondition extends Condition {
  10680. /** path to specify the property of the target the conditional operator uses */
  10681. propertyPath: string;
  10682. /** the value compared by the conditional operator against the current value of the property */
  10683. value: any;
  10684. /** the conditional operator, default ValueCondition.IsEqual */
  10685. operator: number;
  10686. /**
  10687. * Internal only
  10688. * @hidden
  10689. */
  10690. private static _IsEqual;
  10691. /**
  10692. * Internal only
  10693. * @hidden
  10694. */
  10695. private static _IsDifferent;
  10696. /**
  10697. * Internal only
  10698. * @hidden
  10699. */
  10700. private static _IsGreater;
  10701. /**
  10702. * Internal only
  10703. * @hidden
  10704. */
  10705. private static _IsLesser;
  10706. /**
  10707. * returns the number for IsEqual
  10708. */
  10709. static readonly IsEqual: number;
  10710. /**
  10711. * Returns the number for IsDifferent
  10712. */
  10713. static readonly IsDifferent: number;
  10714. /**
  10715. * Returns the number for IsGreater
  10716. */
  10717. static readonly IsGreater: number;
  10718. /**
  10719. * Returns the number for IsLesser
  10720. */
  10721. static readonly IsLesser: number;
  10722. /**
  10723. * Internal only The action manager for the condition
  10724. * @hidden
  10725. */
  10726. _actionManager: ActionManager;
  10727. /**
  10728. * Internal only
  10729. * @hidden
  10730. */
  10731. private _target;
  10732. /**
  10733. * Internal only
  10734. * @hidden
  10735. */
  10736. private _effectiveTarget;
  10737. /**
  10738. * Internal only
  10739. * @hidden
  10740. */
  10741. private _property;
  10742. /**
  10743. * Creates a new ValueCondition
  10744. * @param actionManager manager for the action the condition applies to
  10745. * @param target for the action
  10746. * @param propertyPath path to specify the property of the target the conditional operator uses
  10747. * @param value the value compared by the conditional operator against the current value of the property
  10748. * @param operator the conditional operator, default ValueCondition.IsEqual
  10749. */
  10750. constructor(actionManager: ActionManager, target: any,
  10751. /** path to specify the property of the target the conditional operator uses */
  10752. propertyPath: string,
  10753. /** the value compared by the conditional operator against the current value of the property */
  10754. value: any,
  10755. /** the conditional operator, default ValueCondition.IsEqual */
  10756. operator?: number);
  10757. /**
  10758. * Compares the given value with the property value for the specified conditional operator
  10759. * @returns the result of the comparison
  10760. */
  10761. isValid(): boolean;
  10762. /**
  10763. * Serialize the ValueCondition into a JSON compatible object
  10764. * @returns serialization object
  10765. */
  10766. serialize(): any;
  10767. /**
  10768. * Gets the name of the conditional operator for the ValueCondition
  10769. * @param operator the conditional operator
  10770. * @returns the name
  10771. */
  10772. static GetOperatorName(operator: number): string;
  10773. }
  10774. /**
  10775. * Defines a predicate condition as an extension of Condition
  10776. */
  10777. export class PredicateCondition extends Condition {
  10778. /** defines the predicate function used to validate the condition */
  10779. predicate: () => boolean;
  10780. /**
  10781. * Internal only - manager for action
  10782. * @hidden
  10783. */
  10784. _actionManager: ActionManager;
  10785. /**
  10786. * Creates a new PredicateCondition
  10787. * @param actionManager manager for the action the condition applies to
  10788. * @param predicate defines the predicate function used to validate the condition
  10789. */
  10790. constructor(actionManager: ActionManager,
  10791. /** defines the predicate function used to validate the condition */
  10792. predicate: () => boolean);
  10793. /**
  10794. * @returns the validity of the predicate condition
  10795. */
  10796. isValid(): boolean;
  10797. }
  10798. /**
  10799. * Defines a state condition as an extension of Condition
  10800. */
  10801. export class StateCondition extends Condition {
  10802. /** Value to compare with target state */
  10803. value: string;
  10804. /**
  10805. * Internal only - manager for action
  10806. * @hidden
  10807. */
  10808. _actionManager: ActionManager;
  10809. /**
  10810. * Internal only
  10811. * @hidden
  10812. */
  10813. private _target;
  10814. /**
  10815. * Creates a new StateCondition
  10816. * @param actionManager manager for the action the condition applies to
  10817. * @param target of the condition
  10818. * @param value to compare with target state
  10819. */
  10820. constructor(actionManager: ActionManager, target: any,
  10821. /** Value to compare with target state */
  10822. value: string);
  10823. /**
  10824. * Gets a boolean indicating if the current condition is met
  10825. * @returns the validity of the state
  10826. */
  10827. isValid(): boolean;
  10828. /**
  10829. * Serialize the StateCondition into a JSON compatible object
  10830. * @returns serialization object
  10831. */
  10832. serialize(): any;
  10833. }
  10834. }
  10835. declare module "babylonjs/Actions/directActions" {
  10836. import { Action } from "babylonjs/Actions/action";
  10837. import { Condition } from "babylonjs/Actions/condition";
  10838. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10839. /**
  10840. * This defines an action responsible to toggle a boolean once triggered.
  10841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10842. */
  10843. export class SwitchBooleanAction extends Action {
  10844. /**
  10845. * The path to the boolean property in the target object
  10846. */
  10847. propertyPath: string;
  10848. private _target;
  10849. private _effectiveTarget;
  10850. private _property;
  10851. /**
  10852. * Instantiate the action
  10853. * @param triggerOptions defines the trigger options
  10854. * @param target defines the object containing the boolean
  10855. * @param propertyPath defines the path to the boolean property in the target object
  10856. * @param condition defines the trigger related conditions
  10857. */
  10858. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10859. /** @hidden */
  10860. _prepare(): void;
  10861. /**
  10862. * Execute the action toggle the boolean value.
  10863. */
  10864. execute(): void;
  10865. /**
  10866. * Serializes the actions and its related information.
  10867. * @param parent defines the object to serialize in
  10868. * @returns the serialized object
  10869. */
  10870. serialize(parent: any): any;
  10871. }
  10872. /**
  10873. * This defines an action responsible to set a the state field of the target
  10874. * to a desired value once triggered.
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10876. */
  10877. export class SetStateAction extends Action {
  10878. /**
  10879. * The value to store in the state field.
  10880. */
  10881. value: string;
  10882. private _target;
  10883. /**
  10884. * Instantiate the action
  10885. * @param triggerOptions defines the trigger options
  10886. * @param target defines the object containing the state property
  10887. * @param value defines the value to store in the state field
  10888. * @param condition defines the trigger related conditions
  10889. */
  10890. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10891. /**
  10892. * Execute the action and store the value on the target state property.
  10893. */
  10894. execute(): void;
  10895. /**
  10896. * Serializes the actions and its related information.
  10897. * @param parent defines the object to serialize in
  10898. * @returns the serialized object
  10899. */
  10900. serialize(parent: any): any;
  10901. }
  10902. /**
  10903. * This defines an action responsible to set a property of the target
  10904. * to a desired value once triggered.
  10905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10906. */
  10907. export class SetValueAction extends Action {
  10908. /**
  10909. * The path of the property to set in the target.
  10910. */
  10911. propertyPath: string;
  10912. /**
  10913. * The value to set in the property
  10914. */
  10915. value: any;
  10916. private _target;
  10917. private _effectiveTarget;
  10918. private _property;
  10919. /**
  10920. * Instantiate the action
  10921. * @param triggerOptions defines the trigger options
  10922. * @param target defines the object containing the property
  10923. * @param propertyPath defines the path of the property to set in the target
  10924. * @param value defines the value to set in the property
  10925. * @param condition defines the trigger related conditions
  10926. */
  10927. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10928. /** @hidden */
  10929. _prepare(): void;
  10930. /**
  10931. * Execute the action and set the targetted property to the desired value.
  10932. */
  10933. execute(): void;
  10934. /**
  10935. * Serializes the actions and its related information.
  10936. * @param parent defines the object to serialize in
  10937. * @returns the serialized object
  10938. */
  10939. serialize(parent: any): any;
  10940. }
  10941. /**
  10942. * This defines an action responsible to increment the target value
  10943. * to a desired value once triggered.
  10944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10945. */
  10946. export class IncrementValueAction extends Action {
  10947. /**
  10948. * The path of the property to increment in the target.
  10949. */
  10950. propertyPath: string;
  10951. /**
  10952. * The value we should increment the property by.
  10953. */
  10954. value: any;
  10955. private _target;
  10956. private _effectiveTarget;
  10957. private _property;
  10958. /**
  10959. * Instantiate the action
  10960. * @param triggerOptions defines the trigger options
  10961. * @param target defines the object containing the property
  10962. * @param propertyPath defines the path of the property to increment in the target
  10963. * @param value defines the value value we should increment the property by
  10964. * @param condition defines the trigger related conditions
  10965. */
  10966. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10967. /** @hidden */
  10968. _prepare(): void;
  10969. /**
  10970. * Execute the action and increment the target of the value amount.
  10971. */
  10972. execute(): void;
  10973. /**
  10974. * Serializes the actions and its related information.
  10975. * @param parent defines the object to serialize in
  10976. * @returns the serialized object
  10977. */
  10978. serialize(parent: any): any;
  10979. }
  10980. /**
  10981. * This defines an action responsible to start an animation once triggered.
  10982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10983. */
  10984. export class PlayAnimationAction extends Action {
  10985. /**
  10986. * Where the animation should start (animation frame)
  10987. */
  10988. from: number;
  10989. /**
  10990. * Where the animation should stop (animation frame)
  10991. */
  10992. to: number;
  10993. /**
  10994. * Define if the animation should loop or stop after the first play.
  10995. */
  10996. loop?: boolean;
  10997. private _target;
  10998. /**
  10999. * Instantiate the action
  11000. * @param triggerOptions defines the trigger options
  11001. * @param target defines the target animation or animation name
  11002. * @param from defines from where the animation should start (animation frame)
  11003. * @param end defines where the animation should stop (animation frame)
  11004. * @param loop defines if the animation should loop or stop after the first play
  11005. * @param condition defines the trigger related conditions
  11006. */
  11007. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11008. /** @hidden */
  11009. _prepare(): void;
  11010. /**
  11011. * Execute the action and play the animation.
  11012. */
  11013. execute(): void;
  11014. /**
  11015. * Serializes the actions and its related information.
  11016. * @param parent defines the object to serialize in
  11017. * @returns the serialized object
  11018. */
  11019. serialize(parent: any): any;
  11020. }
  11021. /**
  11022. * This defines an action responsible to stop an animation once triggered.
  11023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11024. */
  11025. export class StopAnimationAction extends Action {
  11026. private _target;
  11027. /**
  11028. * Instantiate the action
  11029. * @param triggerOptions defines the trigger options
  11030. * @param target defines the target animation or animation name
  11031. * @param condition defines the trigger related conditions
  11032. */
  11033. constructor(triggerOptions: any, target: any, condition?: Condition);
  11034. /** @hidden */
  11035. _prepare(): void;
  11036. /**
  11037. * Execute the action and stop the animation.
  11038. */
  11039. execute(): void;
  11040. /**
  11041. * Serializes the actions and its related information.
  11042. * @param parent defines the object to serialize in
  11043. * @returns the serialized object
  11044. */
  11045. serialize(parent: any): any;
  11046. }
  11047. /**
  11048. * This defines an action responsible that does nothing once triggered.
  11049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11050. */
  11051. export class DoNothingAction extends Action {
  11052. /**
  11053. * Instantiate the action
  11054. * @param triggerOptions defines the trigger options
  11055. * @param condition defines the trigger related conditions
  11056. */
  11057. constructor(triggerOptions?: any, condition?: Condition);
  11058. /**
  11059. * Execute the action and do nothing.
  11060. */
  11061. execute(): void;
  11062. /**
  11063. * Serializes the actions and its related information.
  11064. * @param parent defines the object to serialize in
  11065. * @returns the serialized object
  11066. */
  11067. serialize(parent: any): any;
  11068. }
  11069. /**
  11070. * This defines an action responsible to trigger several actions once triggered.
  11071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11072. */
  11073. export class CombineAction extends Action {
  11074. /**
  11075. * The list of aggregated animations to run.
  11076. */
  11077. children: Action[];
  11078. /**
  11079. * Instantiate the action
  11080. * @param triggerOptions defines the trigger options
  11081. * @param children defines the list of aggregated animations to run
  11082. * @param condition defines the trigger related conditions
  11083. */
  11084. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11085. /** @hidden */
  11086. _prepare(): void;
  11087. /**
  11088. * Execute the action and executes all the aggregated actions.
  11089. */
  11090. execute(evt: ActionEvent): void;
  11091. /**
  11092. * Serializes the actions and its related information.
  11093. * @param parent defines the object to serialize in
  11094. * @returns the serialized object
  11095. */
  11096. serialize(parent: any): any;
  11097. }
  11098. /**
  11099. * This defines an action responsible to run code (external event) once triggered.
  11100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11101. */
  11102. export class ExecuteCodeAction extends Action {
  11103. /**
  11104. * The callback function to run.
  11105. */
  11106. func: (evt: ActionEvent) => void;
  11107. /**
  11108. * Instantiate the action
  11109. * @param triggerOptions defines the trigger options
  11110. * @param func defines the callback function to run
  11111. * @param condition defines the trigger related conditions
  11112. */
  11113. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11114. /**
  11115. * Execute the action and run the attached code.
  11116. */
  11117. execute(evt: ActionEvent): void;
  11118. }
  11119. /**
  11120. * This defines an action responsible to set the parent property of the target once triggered.
  11121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11122. */
  11123. export class SetParentAction extends Action {
  11124. private _parent;
  11125. private _target;
  11126. /**
  11127. * Instantiate the action
  11128. * @param triggerOptions defines the trigger options
  11129. * @param target defines the target containing the parent property
  11130. * @param parent defines from where the animation should start (animation frame)
  11131. * @param condition defines the trigger related conditions
  11132. */
  11133. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11134. /** @hidden */
  11135. _prepare(): void;
  11136. /**
  11137. * Execute the action and set the parent property.
  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. declare module "babylonjs/Actions/actionManager" {
  11149. import { Nullable } from "babylonjs/types";
  11150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11151. import { Scene } from "babylonjs/scene";
  11152. import { IAction } from "babylonjs/Actions/action";
  11153. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11154. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11155. /**
  11156. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11157. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11159. */
  11160. export class ActionManager extends AbstractActionManager {
  11161. /**
  11162. * Nothing
  11163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11164. */
  11165. static readonly NothingTrigger: number;
  11166. /**
  11167. * On pick
  11168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11169. */
  11170. static readonly OnPickTrigger: number;
  11171. /**
  11172. * On left pick
  11173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11174. */
  11175. static readonly OnLeftPickTrigger: number;
  11176. /**
  11177. * On right pick
  11178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11179. */
  11180. static readonly OnRightPickTrigger: number;
  11181. /**
  11182. * On center pick
  11183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11184. */
  11185. static readonly OnCenterPickTrigger: number;
  11186. /**
  11187. * On pick down
  11188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11189. */
  11190. static readonly OnPickDownTrigger: number;
  11191. /**
  11192. * On double pick
  11193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11194. */
  11195. static readonly OnDoublePickTrigger: number;
  11196. /**
  11197. * On pick up
  11198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11199. */
  11200. static readonly OnPickUpTrigger: number;
  11201. /**
  11202. * On pick out.
  11203. * This trigger will only be raised if you also declared a OnPickDown
  11204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11205. */
  11206. static readonly OnPickOutTrigger: number;
  11207. /**
  11208. * On long press
  11209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11210. */
  11211. static readonly OnLongPressTrigger: number;
  11212. /**
  11213. * On pointer over
  11214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11215. */
  11216. static readonly OnPointerOverTrigger: number;
  11217. /**
  11218. * On pointer out
  11219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11220. */
  11221. static readonly OnPointerOutTrigger: number;
  11222. /**
  11223. * On every frame
  11224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11225. */
  11226. static readonly OnEveryFrameTrigger: number;
  11227. /**
  11228. * On intersection enter
  11229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11230. */
  11231. static readonly OnIntersectionEnterTrigger: number;
  11232. /**
  11233. * On intersection exit
  11234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11235. */
  11236. static readonly OnIntersectionExitTrigger: number;
  11237. /**
  11238. * On key down
  11239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11240. */
  11241. static readonly OnKeyDownTrigger: number;
  11242. /**
  11243. * On key up
  11244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11245. */
  11246. static readonly OnKeyUpTrigger: number;
  11247. private _scene;
  11248. /**
  11249. * Creates a new action manager
  11250. * @param scene defines the hosting scene
  11251. */
  11252. constructor(scene: Scene);
  11253. /**
  11254. * Releases all associated resources
  11255. */
  11256. dispose(): void;
  11257. /**
  11258. * Gets hosting scene
  11259. * @returns the hosting scene
  11260. */
  11261. getScene(): Scene;
  11262. /**
  11263. * Does this action manager handles actions of any of the given triggers
  11264. * @param triggers defines the triggers to be tested
  11265. * @return a boolean indicating whether one (or more) of the triggers is handled
  11266. */
  11267. hasSpecificTriggers(triggers: number[]): boolean;
  11268. /**
  11269. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11270. * speed.
  11271. * @param triggerA defines the trigger to be tested
  11272. * @param triggerB defines the trigger to be tested
  11273. * @return a boolean indicating whether one (or more) of the triggers is handled
  11274. */
  11275. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11276. /**
  11277. * Does this action manager handles actions of a given trigger
  11278. * @param trigger defines the trigger to be tested
  11279. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11280. * @return whether the trigger is handled
  11281. */
  11282. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11283. /**
  11284. * Does this action manager has pointer triggers
  11285. */
  11286. readonly hasPointerTriggers: boolean;
  11287. /**
  11288. * Does this action manager has pick triggers
  11289. */
  11290. readonly hasPickTriggers: boolean;
  11291. /**
  11292. * Registers an action to this action manager
  11293. * @param action defines the action to be registered
  11294. * @return the action amended (prepared) after registration
  11295. */
  11296. registerAction(action: IAction): Nullable<IAction>;
  11297. /**
  11298. * Unregisters an action to this action manager
  11299. * @param action defines the action to be unregistered
  11300. * @return a boolean indicating whether the action has been unregistered
  11301. */
  11302. unregisterAction(action: IAction): Boolean;
  11303. /**
  11304. * Process a specific trigger
  11305. * @param trigger defines the trigger to process
  11306. * @param evt defines the event details to be processed
  11307. */
  11308. processTrigger(trigger: number, evt?: IActionEvent): void;
  11309. /** @hidden */
  11310. _getEffectiveTarget(target: any, propertyPath: string): any;
  11311. /** @hidden */
  11312. _getProperty(propertyPath: string): string;
  11313. /**
  11314. * Serialize this manager to a JSON object
  11315. * @param name defines the property name to store this manager
  11316. * @returns a JSON representation of this manager
  11317. */
  11318. serialize(name: string): any;
  11319. /**
  11320. * Creates a new ActionManager from a JSON data
  11321. * @param parsedActions defines the JSON data to read from
  11322. * @param object defines the hosting mesh
  11323. * @param scene defines the hosting scene
  11324. */
  11325. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11326. /**
  11327. * Get a trigger name by index
  11328. * @param trigger defines the trigger index
  11329. * @returns a trigger name
  11330. */
  11331. static GetTriggerName(trigger: number): string;
  11332. }
  11333. }
  11334. declare module "babylonjs/Culling/ray" {
  11335. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11336. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11338. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11339. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11340. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11341. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11342. /**
  11343. * Class representing a ray with position and direction
  11344. */
  11345. export class Ray {
  11346. /** origin point */
  11347. origin: Vector3;
  11348. /** direction */
  11349. direction: Vector3;
  11350. /** length of the ray */
  11351. length: number;
  11352. private static readonly TmpVector3;
  11353. private _tmpRay;
  11354. /**
  11355. * Creates a new ray
  11356. * @param origin origin point
  11357. * @param direction direction
  11358. * @param length length of the ray
  11359. */
  11360. constructor(
  11361. /** origin point */
  11362. origin: Vector3,
  11363. /** direction */
  11364. direction: Vector3,
  11365. /** length of the ray */
  11366. length?: number);
  11367. /**
  11368. * Checks if the ray intersects a box
  11369. * @param minimum bound of the box
  11370. * @param maximum bound of the box
  11371. * @param intersectionTreshold extra extend to be added to the box in all direction
  11372. * @returns if the box was hit
  11373. */
  11374. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11375. /**
  11376. * Checks if the ray intersects a box
  11377. * @param box the bounding box to check
  11378. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11379. * @returns if the box was hit
  11380. */
  11381. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11382. /**
  11383. * If the ray hits a sphere
  11384. * @param sphere the bounding sphere to check
  11385. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11386. * @returns true if it hits the sphere
  11387. */
  11388. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11389. /**
  11390. * If the ray hits a triange
  11391. * @param vertex0 triangle vertex
  11392. * @param vertex1 triangle vertex
  11393. * @param vertex2 triangle vertex
  11394. * @returns intersection information if hit
  11395. */
  11396. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11397. /**
  11398. * Checks if ray intersects a plane
  11399. * @param plane the plane to check
  11400. * @returns the distance away it was hit
  11401. */
  11402. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11403. /**
  11404. * Checks if ray intersects a mesh
  11405. * @param mesh the mesh to check
  11406. * @param fastCheck if only the bounding box should checked
  11407. * @returns picking info of the intersecton
  11408. */
  11409. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11410. /**
  11411. * Checks if ray intersects a mesh
  11412. * @param meshes the meshes to check
  11413. * @param fastCheck if only the bounding box should checked
  11414. * @param results array to store result in
  11415. * @returns Array of picking infos
  11416. */
  11417. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11418. private _comparePickingInfo;
  11419. private static smallnum;
  11420. private static rayl;
  11421. /**
  11422. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11423. * @param sega the first point of the segment to test the intersection against
  11424. * @param segb the second point of the segment to test the intersection against
  11425. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11426. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11427. */
  11428. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11429. /**
  11430. * Update the ray from viewport position
  11431. * @param x position
  11432. * @param y y position
  11433. * @param viewportWidth viewport width
  11434. * @param viewportHeight viewport height
  11435. * @param world world matrix
  11436. * @param view view matrix
  11437. * @param projection projection matrix
  11438. * @returns this ray updated
  11439. */
  11440. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11441. /**
  11442. * Creates a ray with origin and direction of 0,0,0
  11443. * @returns the new ray
  11444. */
  11445. static Zero(): Ray;
  11446. /**
  11447. * Creates a new ray from screen space and viewport
  11448. * @param x position
  11449. * @param y y position
  11450. * @param viewportWidth viewport width
  11451. * @param viewportHeight viewport height
  11452. * @param world world matrix
  11453. * @param view view matrix
  11454. * @param projection projection matrix
  11455. * @returns new ray
  11456. */
  11457. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11458. /**
  11459. * 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
  11460. * transformed to the given world matrix.
  11461. * @param origin The origin point
  11462. * @param end The end point
  11463. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11464. * @returns the new ray
  11465. */
  11466. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11467. /**
  11468. * Transforms a ray by a matrix
  11469. * @param ray ray to transform
  11470. * @param matrix matrix to apply
  11471. * @returns the resulting new ray
  11472. */
  11473. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11474. /**
  11475. * Transforms a ray by a matrix
  11476. * @param ray ray to transform
  11477. * @param matrix matrix to apply
  11478. * @param result ray to store result in
  11479. */
  11480. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11481. /**
  11482. * Unproject a ray from screen space to object space
  11483. * @param sourceX defines the screen space x coordinate to use
  11484. * @param sourceY defines the screen space y coordinate to use
  11485. * @param viewportWidth defines the current width of the viewport
  11486. * @param viewportHeight defines the current height of the viewport
  11487. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11488. * @param view defines the view matrix to use
  11489. * @param projection defines the projection matrix to use
  11490. */
  11491. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11492. }
  11493. /**
  11494. * Type used to define predicate used to select faces when a mesh intersection is detected
  11495. */
  11496. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11497. module "babylonjs/scene" {
  11498. interface Scene {
  11499. /** @hidden */
  11500. _tempPickingRay: Nullable<Ray>;
  11501. /** @hidden */
  11502. _cachedRayForTransform: Ray;
  11503. /** @hidden */
  11504. _pickWithRayInverseMatrix: Matrix;
  11505. /** @hidden */
  11506. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11507. /** @hidden */
  11508. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11509. }
  11510. }
  11511. }
  11512. declare module "babylonjs/sceneComponent" {
  11513. import { Scene } from "babylonjs/scene";
  11514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11515. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11516. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11517. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11518. import { Nullable } from "babylonjs/types";
  11519. import { Camera } from "babylonjs/Cameras/camera";
  11520. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11521. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11522. import { AbstractScene } from "babylonjs/abstractScene";
  11523. /**
  11524. * Groups all the scene component constants in one place to ease maintenance.
  11525. * @hidden
  11526. */
  11527. export class SceneComponentConstants {
  11528. static readonly NAME_EFFECTLAYER: string;
  11529. static readonly NAME_LAYER: string;
  11530. static readonly NAME_LENSFLARESYSTEM: string;
  11531. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11532. static readonly NAME_PARTICLESYSTEM: string;
  11533. static readonly NAME_GAMEPAD: string;
  11534. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11535. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11536. static readonly NAME_DEPTHRENDERER: string;
  11537. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11538. static readonly NAME_SPRITE: string;
  11539. static readonly NAME_OUTLINERENDERER: string;
  11540. static readonly NAME_PROCEDURALTEXTURE: string;
  11541. static readonly NAME_SHADOWGENERATOR: string;
  11542. static readonly NAME_OCTREE: string;
  11543. static readonly NAME_PHYSICSENGINE: string;
  11544. static readonly NAME_AUDIO: string;
  11545. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11546. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11547. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11548. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11549. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11550. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11551. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11552. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11553. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11554. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11555. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11556. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11557. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11558. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11559. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11560. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11561. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11562. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11563. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11564. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11565. static readonly STEP_AFTERRENDER_AUDIO: number;
  11566. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11567. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11568. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11569. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11570. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11571. static readonly STEP_POINTERMOVE_SPRITE: number;
  11572. static readonly STEP_POINTERDOWN_SPRITE: number;
  11573. static readonly STEP_POINTERUP_SPRITE: number;
  11574. }
  11575. /**
  11576. * This represents a scene component.
  11577. *
  11578. * This is used to decouple the dependency the scene is having on the different workloads like
  11579. * layers, post processes...
  11580. */
  11581. export interface ISceneComponent {
  11582. /**
  11583. * The name of the component. Each component must have a unique name.
  11584. */
  11585. name: string;
  11586. /**
  11587. * The scene the component belongs to.
  11588. */
  11589. scene: Scene;
  11590. /**
  11591. * Register the component to one instance of a scene.
  11592. */
  11593. register(): void;
  11594. /**
  11595. * Rebuilds the elements related to this component in case of
  11596. * context lost for instance.
  11597. */
  11598. rebuild(): void;
  11599. /**
  11600. * Disposes the component and the associated ressources.
  11601. */
  11602. dispose(): void;
  11603. }
  11604. /**
  11605. * This represents a SERIALIZABLE scene component.
  11606. *
  11607. * This extends Scene Component to add Serialization methods on top.
  11608. */
  11609. export interface ISceneSerializableComponent extends ISceneComponent {
  11610. /**
  11611. * Adds all the element from the container to the scene
  11612. * @param container the container holding the elements
  11613. */
  11614. addFromContainer(container: AbstractScene): void;
  11615. /**
  11616. * Removes all the elements in the container from the scene
  11617. * @param container contains the elements to remove
  11618. * @param dispose if the removed element should be disposed (default: false)
  11619. */
  11620. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11621. /**
  11622. * Serializes the component data to the specified json object
  11623. * @param serializationObject The object to serialize to
  11624. */
  11625. serialize(serializationObject: any): void;
  11626. }
  11627. /**
  11628. * Strong typing of a Mesh related stage step action
  11629. */
  11630. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11631. /**
  11632. * Strong typing of a Evaluate Sub Mesh related stage step action
  11633. */
  11634. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11635. /**
  11636. * Strong typing of a Active Mesh related stage step action
  11637. */
  11638. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11639. /**
  11640. * Strong typing of a Camera related stage step action
  11641. */
  11642. export type CameraStageAction = (camera: Camera) => void;
  11643. /**
  11644. * Strong typing of a Render Target related stage step action
  11645. */
  11646. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11647. /**
  11648. * Strong typing of a RenderingGroup related stage step action
  11649. */
  11650. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11651. /**
  11652. * Strong typing of a Mesh Render related stage step action
  11653. */
  11654. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11655. /**
  11656. * Strong typing of a simple stage step action
  11657. */
  11658. export type SimpleStageAction = () => void;
  11659. /**
  11660. * Strong typing of a render target action.
  11661. */
  11662. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11663. /**
  11664. * Strong typing of a pointer move action.
  11665. */
  11666. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11667. /**
  11668. * Strong typing of a pointer up/down action.
  11669. */
  11670. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11671. /**
  11672. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11673. * @hidden
  11674. */
  11675. export class Stage<T extends Function> extends Array<{
  11676. index: number;
  11677. component: ISceneComponent;
  11678. action: T;
  11679. }> {
  11680. /**
  11681. * Hide ctor from the rest of the world.
  11682. * @param items The items to add.
  11683. */
  11684. private constructor();
  11685. /**
  11686. * Creates a new Stage.
  11687. * @returns A new instance of a Stage
  11688. */
  11689. static Create<T extends Function>(): Stage<T>;
  11690. /**
  11691. * Registers a step in an ordered way in the targeted stage.
  11692. * @param index Defines the position to register the step in
  11693. * @param component Defines the component attached to the step
  11694. * @param action Defines the action to launch during the step
  11695. */
  11696. registerStep(index: number, component: ISceneComponent, action: T): void;
  11697. /**
  11698. * Clears all the steps from the stage.
  11699. */
  11700. clear(): void;
  11701. }
  11702. }
  11703. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11704. import { Nullable } from "babylonjs/types";
  11705. import { Observable } from "babylonjs/Misc/observable";
  11706. import { Scene } from "babylonjs/scene";
  11707. import { Sprite } from "babylonjs/Sprites/sprite";
  11708. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11709. import { Ray } from "babylonjs/Culling/ray";
  11710. import { Camera } from "babylonjs/Cameras/camera";
  11711. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11712. import { ISceneComponent } from "babylonjs/sceneComponent";
  11713. module "babylonjs/scene" {
  11714. interface Scene {
  11715. /** @hidden */
  11716. _pointerOverSprite: Nullable<Sprite>;
  11717. /** @hidden */
  11718. _pickedDownSprite: Nullable<Sprite>;
  11719. /** @hidden */
  11720. _tempSpritePickingRay: Nullable<Ray>;
  11721. /**
  11722. * All of the sprite managers added to this scene
  11723. * @see http://doc.babylonjs.com/babylon101/sprites
  11724. */
  11725. spriteManagers: Array<ISpriteManager>;
  11726. /**
  11727. * An event triggered when sprites rendering is about to start
  11728. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11729. */
  11730. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11731. /**
  11732. * An event triggered when sprites rendering is done
  11733. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11734. */
  11735. onAfterSpritesRenderingObservable: Observable<Scene>;
  11736. /** @hidden */
  11737. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11738. /** Launch a ray to try to pick a sprite in the scene
  11739. * @param x position on screen
  11740. * @param y position on screen
  11741. * @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
  11742. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11743. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11744. * @returns a PickingInfo
  11745. */
  11746. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11747. /** Use the given ray to pick a sprite in the scene
  11748. * @param ray The ray (in world space) to use to pick meshes
  11749. * @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
  11750. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11751. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11752. * @returns a PickingInfo
  11753. */
  11754. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11755. /**
  11756. * Force the sprite under the pointer
  11757. * @param sprite defines the sprite to use
  11758. */
  11759. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11760. /**
  11761. * Gets the sprite under the pointer
  11762. * @returns a Sprite or null if no sprite is under the pointer
  11763. */
  11764. getPointerOverSprite(): Nullable<Sprite>;
  11765. }
  11766. }
  11767. /**
  11768. * Defines the sprite scene component responsible to manage sprites
  11769. * in a given scene.
  11770. */
  11771. export class SpriteSceneComponent implements ISceneComponent {
  11772. /**
  11773. * The component name helpfull to identify the component in the list of scene components.
  11774. */
  11775. readonly name: string;
  11776. /**
  11777. * The scene the component belongs to.
  11778. */
  11779. scene: Scene;
  11780. /** @hidden */
  11781. private _spritePredicate;
  11782. /**
  11783. * Creates a new instance of the component for the given scene
  11784. * @param scene Defines the scene to register the component in
  11785. */
  11786. constructor(scene: Scene);
  11787. /**
  11788. * Registers the component in a given scene
  11789. */
  11790. register(): void;
  11791. /**
  11792. * Rebuilds the elements related to this component in case of
  11793. * context lost for instance.
  11794. */
  11795. rebuild(): void;
  11796. /**
  11797. * Disposes the component and the associated ressources.
  11798. */
  11799. dispose(): void;
  11800. private _pickSpriteButKeepRay;
  11801. private _pointerMove;
  11802. private _pointerDown;
  11803. private _pointerUp;
  11804. }
  11805. }
  11806. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11807. /** @hidden */
  11808. export var fogFragmentDeclaration: {
  11809. name: string;
  11810. shader: string;
  11811. };
  11812. }
  11813. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11814. /** @hidden */
  11815. export var fogFragment: {
  11816. name: string;
  11817. shader: string;
  11818. };
  11819. }
  11820. declare module "babylonjs/Shaders/sprites.fragment" {
  11821. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11822. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11823. /** @hidden */
  11824. export var spritesPixelShader: {
  11825. name: string;
  11826. shader: string;
  11827. };
  11828. }
  11829. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11830. /** @hidden */
  11831. export var fogVertexDeclaration: {
  11832. name: string;
  11833. shader: string;
  11834. };
  11835. }
  11836. declare module "babylonjs/Shaders/sprites.vertex" {
  11837. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11838. /** @hidden */
  11839. export var spritesVertexShader: {
  11840. name: string;
  11841. shader: string;
  11842. };
  11843. }
  11844. declare module "babylonjs/Sprites/spriteManager" {
  11845. import { IDisposable, Scene } from "babylonjs/scene";
  11846. import { Nullable } from "babylonjs/types";
  11847. import { Observable } from "babylonjs/Misc/observable";
  11848. import { Sprite } from "babylonjs/Sprites/sprite";
  11849. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11850. import { Camera } from "babylonjs/Cameras/camera";
  11851. import { Texture } from "babylonjs/Materials/Textures/texture";
  11852. import "babylonjs/Shaders/sprites.fragment";
  11853. import "babylonjs/Shaders/sprites.vertex";
  11854. import { Ray } from "babylonjs/Culling/ray";
  11855. /**
  11856. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11857. */
  11858. export interface ISpriteManager extends IDisposable {
  11859. /**
  11860. * Restricts the camera to viewing objects with the same layerMask.
  11861. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11862. */
  11863. layerMask: number;
  11864. /**
  11865. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11866. */
  11867. isPickable: boolean;
  11868. /**
  11869. * Specifies the rendering group id for this mesh (0 by default)
  11870. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11871. */
  11872. renderingGroupId: number;
  11873. /**
  11874. * Defines the list of sprites managed by the manager.
  11875. */
  11876. sprites: Array<Sprite>;
  11877. /**
  11878. * Tests the intersection of a sprite with a specific ray.
  11879. * @param ray The ray we are sending to test the collision
  11880. * @param camera The camera space we are sending rays in
  11881. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11882. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11883. * @returns picking info or null.
  11884. */
  11885. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11886. /**
  11887. * Renders the list of sprites on screen.
  11888. */
  11889. render(): void;
  11890. }
  11891. /**
  11892. * Class used to manage multiple sprites on the same spritesheet
  11893. * @see http://doc.babylonjs.com/babylon101/sprites
  11894. */
  11895. export class SpriteManager implements ISpriteManager {
  11896. /** defines the manager's name */
  11897. name: string;
  11898. /** Gets the list of sprites */
  11899. sprites: Sprite[];
  11900. /** Gets or sets the rendering group id (0 by default) */
  11901. renderingGroupId: number;
  11902. /** Gets or sets camera layer mask */
  11903. layerMask: number;
  11904. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11905. fogEnabled: boolean;
  11906. /** Gets or sets a boolean indicating if the sprites are pickable */
  11907. isPickable: boolean;
  11908. /** Defines the default width of a cell in the spritesheet */
  11909. cellWidth: number;
  11910. /** Defines the default height of a cell in the spritesheet */
  11911. cellHeight: number;
  11912. /**
  11913. * An event triggered when the manager is disposed.
  11914. */
  11915. onDisposeObservable: Observable<SpriteManager>;
  11916. private _onDisposeObserver;
  11917. /**
  11918. * Callback called when the manager is disposed
  11919. */
  11920. onDispose: () => void;
  11921. private _capacity;
  11922. private _spriteTexture;
  11923. private _epsilon;
  11924. private _scene;
  11925. private _vertexData;
  11926. private _buffer;
  11927. private _vertexBuffers;
  11928. private _indexBuffer;
  11929. private _effectBase;
  11930. private _effectFog;
  11931. /**
  11932. * Gets or sets the spritesheet texture
  11933. */
  11934. texture: Texture;
  11935. /**
  11936. * Creates a new sprite manager
  11937. * @param name defines the manager's name
  11938. * @param imgUrl defines the sprite sheet url
  11939. * @param capacity defines the maximum allowed number of sprites
  11940. * @param cellSize defines the size of a sprite cell
  11941. * @param scene defines the hosting scene
  11942. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11943. * @param samplingMode defines the smapling mode to use with spritesheet
  11944. */
  11945. constructor(
  11946. /** defines the manager's name */
  11947. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11948. private _appendSpriteVertex;
  11949. /**
  11950. * Intersects the sprites with a ray
  11951. * @param ray defines the ray to intersect with
  11952. * @param camera defines the current active camera
  11953. * @param predicate defines a predicate used to select candidate sprites
  11954. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11955. * @returns null if no hit or a PickingInfo
  11956. */
  11957. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11958. /**
  11959. * Render all child sprites
  11960. */
  11961. render(): void;
  11962. /**
  11963. * Release associated resources
  11964. */
  11965. dispose(): void;
  11966. }
  11967. }
  11968. declare module "babylonjs/Sprites/sprite" {
  11969. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11970. import { Nullable } from "babylonjs/types";
  11971. import { ActionManager } from "babylonjs/Actions/actionManager";
  11972. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11973. /**
  11974. * Class used to represent a sprite
  11975. * @see http://doc.babylonjs.com/babylon101/sprites
  11976. */
  11977. export class Sprite {
  11978. /** defines the name */
  11979. name: string;
  11980. /** Gets or sets the current world position */
  11981. position: Vector3;
  11982. /** Gets or sets the main color */
  11983. color: Color4;
  11984. /** Gets or sets the width */
  11985. width: number;
  11986. /** Gets or sets the height */
  11987. height: number;
  11988. /** Gets or sets rotation angle */
  11989. angle: number;
  11990. /** Gets or sets the cell index in the sprite sheet */
  11991. cellIndex: number;
  11992. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11993. invertU: number;
  11994. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11995. invertV: number;
  11996. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11997. disposeWhenFinishedAnimating: boolean;
  11998. /** Gets the list of attached animations */
  11999. animations: Animation[];
  12000. /** Gets or sets a boolean indicating if the sprite can be picked */
  12001. isPickable: boolean;
  12002. /**
  12003. * Gets or sets the associated action manager
  12004. */
  12005. actionManager: Nullable<ActionManager>;
  12006. private _animationStarted;
  12007. private _loopAnimation;
  12008. private _fromIndex;
  12009. private _toIndex;
  12010. private _delay;
  12011. private _direction;
  12012. private _manager;
  12013. private _time;
  12014. private _onAnimationEnd;
  12015. /**
  12016. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12017. */
  12018. isVisible: boolean;
  12019. /**
  12020. * Gets or sets the sprite size
  12021. */
  12022. size: number;
  12023. /**
  12024. * Creates a new Sprite
  12025. * @param name defines the name
  12026. * @param manager defines the manager
  12027. */
  12028. constructor(
  12029. /** defines the name */
  12030. name: string, manager: ISpriteManager);
  12031. /**
  12032. * Starts an animation
  12033. * @param from defines the initial key
  12034. * @param to defines the end key
  12035. * @param loop defines if the animation must loop
  12036. * @param delay defines the start delay (in ms)
  12037. * @param onAnimationEnd defines a callback to call when animation ends
  12038. */
  12039. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12040. /** Stops current animation (if any) */
  12041. stopAnimation(): void;
  12042. /** @hidden */
  12043. _animate(deltaTime: number): void;
  12044. /** Release associated resources */
  12045. dispose(): void;
  12046. }
  12047. }
  12048. declare module "babylonjs/Collisions/pickingInfo" {
  12049. import { Nullable } from "babylonjs/types";
  12050. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12052. import { Sprite } from "babylonjs/Sprites/sprite";
  12053. import { Ray } from "babylonjs/Culling/ray";
  12054. /**
  12055. * Information about the result of picking within a scene
  12056. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12057. */
  12058. export class PickingInfo {
  12059. /** @hidden */
  12060. _pickingUnavailable: boolean;
  12061. /**
  12062. * If the pick collided with an object
  12063. */
  12064. hit: boolean;
  12065. /**
  12066. * Distance away where the pick collided
  12067. */
  12068. distance: number;
  12069. /**
  12070. * The location of pick collision
  12071. */
  12072. pickedPoint: Nullable<Vector3>;
  12073. /**
  12074. * The mesh corresponding the the pick collision
  12075. */
  12076. pickedMesh: Nullable<AbstractMesh>;
  12077. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12078. bu: number;
  12079. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12080. bv: number;
  12081. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12082. faceId: number;
  12083. /** Id of the the submesh that was picked */
  12084. subMeshId: number;
  12085. /** If a sprite was picked, this will be the sprite the pick collided with */
  12086. pickedSprite: Nullable<Sprite>;
  12087. /**
  12088. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12089. */
  12090. originMesh: Nullable<AbstractMesh>;
  12091. /**
  12092. * The ray that was used to perform the picking.
  12093. */
  12094. ray: Nullable<Ray>;
  12095. /**
  12096. * Gets the normal correspodning to the face the pick collided with
  12097. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12098. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12099. * @returns The normal correspodning to the face the pick collided with
  12100. */
  12101. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12102. /**
  12103. * Gets the texture coordinates of where the pick occured
  12104. * @returns the vector containing the coordnates of the texture
  12105. */
  12106. getTextureCoordinates(): Nullable<Vector2>;
  12107. }
  12108. }
  12109. declare module "babylonjs/Events/pointerEvents" {
  12110. import { Nullable } from "babylonjs/types";
  12111. import { Vector2 } from "babylonjs/Maths/math";
  12112. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12113. import { Ray } from "babylonjs/Culling/ray";
  12114. /**
  12115. * Gather the list of pointer event types as constants.
  12116. */
  12117. export class PointerEventTypes {
  12118. /**
  12119. * 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.
  12120. */
  12121. static readonly POINTERDOWN: number;
  12122. /**
  12123. * The pointerup event is fired when a pointer is no longer active.
  12124. */
  12125. static readonly POINTERUP: number;
  12126. /**
  12127. * The pointermove event is fired when a pointer changes coordinates.
  12128. */
  12129. static readonly POINTERMOVE: number;
  12130. /**
  12131. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12132. */
  12133. static readonly POINTERWHEEL: number;
  12134. /**
  12135. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12136. */
  12137. static readonly POINTERPICK: number;
  12138. /**
  12139. * The pointertap event is fired when a the object has been touched and released without drag.
  12140. */
  12141. static readonly POINTERTAP: number;
  12142. /**
  12143. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12144. */
  12145. static readonly POINTERDOUBLETAP: number;
  12146. }
  12147. /**
  12148. * Base class of pointer info types.
  12149. */
  12150. export class PointerInfoBase {
  12151. /**
  12152. * Defines the type of event (PointerEventTypes)
  12153. */
  12154. type: number;
  12155. /**
  12156. * Defines the related dom event
  12157. */
  12158. event: PointerEvent | MouseWheelEvent;
  12159. /**
  12160. * Instantiates the base class of pointers info.
  12161. * @param type Defines the type of event (PointerEventTypes)
  12162. * @param event Defines the related dom event
  12163. */
  12164. constructor(
  12165. /**
  12166. * Defines the type of event (PointerEventTypes)
  12167. */
  12168. type: number,
  12169. /**
  12170. * Defines the related dom event
  12171. */
  12172. event: PointerEvent | MouseWheelEvent);
  12173. }
  12174. /**
  12175. * This class is used to store pointer related info for the onPrePointerObservable event.
  12176. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12177. */
  12178. export class PointerInfoPre extends PointerInfoBase {
  12179. /**
  12180. * Ray from a pointer if availible (eg. 6dof controller)
  12181. */
  12182. ray: Nullable<Ray>;
  12183. /**
  12184. * Defines the local position of the pointer on the canvas.
  12185. */
  12186. localPosition: Vector2;
  12187. /**
  12188. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12189. */
  12190. skipOnPointerObservable: boolean;
  12191. /**
  12192. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12193. * @param type Defines the type of event (PointerEventTypes)
  12194. * @param event Defines the related dom event
  12195. * @param localX Defines the local x coordinates of the pointer when the event occured
  12196. * @param localY Defines the local y coordinates of the pointer when the event occured
  12197. */
  12198. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12199. }
  12200. /**
  12201. * This type contains all the data related to a pointer event in Babylon.js.
  12202. * 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.
  12203. */
  12204. export class PointerInfo extends PointerInfoBase {
  12205. /**
  12206. * Defines the picking info associated to the info (if any)\
  12207. */
  12208. pickInfo: Nullable<PickingInfo>;
  12209. /**
  12210. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12211. * @param type Defines the type of event (PointerEventTypes)
  12212. * @param event Defines the related dom event
  12213. * @param pickInfo Defines the picking info associated to the info (if any)\
  12214. */
  12215. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12216. /**
  12217. * Defines the picking info associated to the info (if any)\
  12218. */
  12219. pickInfo: Nullable<PickingInfo>);
  12220. }
  12221. /**
  12222. * Data relating to a touch event on the screen.
  12223. */
  12224. export interface PointerTouch {
  12225. /**
  12226. * X coordinate of touch.
  12227. */
  12228. x: number;
  12229. /**
  12230. * Y coordinate of touch.
  12231. */
  12232. y: number;
  12233. /**
  12234. * Id of touch. Unique for each finger.
  12235. */
  12236. pointerId: number;
  12237. /**
  12238. * Event type passed from DOM.
  12239. */
  12240. type: any;
  12241. }
  12242. }
  12243. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12244. import { Observable } from "babylonjs/Misc/observable";
  12245. import { Nullable } from "babylonjs/types";
  12246. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12247. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12248. /**
  12249. * Manage the mouse inputs to control the movement of a free camera.
  12250. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12251. */
  12252. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12253. /**
  12254. * Define if touch is enabled in the mouse input
  12255. */
  12256. touchEnabled: boolean;
  12257. /**
  12258. * Defines the camera the input is attached to.
  12259. */
  12260. camera: FreeCamera;
  12261. /**
  12262. * Defines the buttons associated with the input to handle camera move.
  12263. */
  12264. buttons: number[];
  12265. /**
  12266. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12267. */
  12268. angularSensibility: number;
  12269. private _pointerInput;
  12270. private _onMouseMove;
  12271. private _observer;
  12272. private previousPosition;
  12273. /**
  12274. * Observable for when a pointer move event occurs containing the move offset
  12275. */
  12276. onPointerMovedObservable: Observable<{
  12277. offsetX: number;
  12278. offsetY: number;
  12279. }>;
  12280. /**
  12281. * @hidden
  12282. * If the camera should be rotated automatically based on pointer movement
  12283. */
  12284. _allowCameraRotation: boolean;
  12285. /**
  12286. * Manage the mouse inputs to control the movement of a free camera.
  12287. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12288. * @param touchEnabled Defines if touch is enabled or not
  12289. */
  12290. constructor(
  12291. /**
  12292. * Define if touch is enabled in the mouse input
  12293. */
  12294. touchEnabled?: boolean);
  12295. /**
  12296. * Attach the input controls to a specific dom element to get the input from.
  12297. * @param element Defines the element the controls should be listened from
  12298. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12299. */
  12300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12301. /**
  12302. * Called on JS contextmenu event.
  12303. * Override this method to provide functionality.
  12304. */
  12305. protected onContextMenu(evt: PointerEvent): void;
  12306. /**
  12307. * Detach the current controls from the specified dom element.
  12308. * @param element Defines the element to stop listening the inputs from
  12309. */
  12310. detachControl(element: Nullable<HTMLElement>): void;
  12311. /**
  12312. * Gets the class name of the current intput.
  12313. * @returns the class name
  12314. */
  12315. getClassName(): string;
  12316. /**
  12317. * Get the friendly name associated with the input class.
  12318. * @returns the input friendly name
  12319. */
  12320. getSimpleName(): string;
  12321. }
  12322. }
  12323. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12324. import { Nullable } from "babylonjs/types";
  12325. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12326. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12327. /**
  12328. * Manage the touch inputs to control the movement of a free camera.
  12329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12330. */
  12331. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12332. /**
  12333. * Defines the camera the input is attached to.
  12334. */
  12335. camera: FreeCamera;
  12336. /**
  12337. * Defines the touch sensibility for rotation.
  12338. * The higher the faster.
  12339. */
  12340. touchAngularSensibility: number;
  12341. /**
  12342. * Defines the touch sensibility for move.
  12343. * The higher the faster.
  12344. */
  12345. touchMoveSensibility: number;
  12346. private _offsetX;
  12347. private _offsetY;
  12348. private _pointerPressed;
  12349. private _pointerInput;
  12350. private _observer;
  12351. private _onLostFocus;
  12352. /**
  12353. * Attach the input controls to a specific dom element to get the input from.
  12354. * @param element Defines the element the controls should be listened from
  12355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12356. */
  12357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12358. /**
  12359. * Detach the current controls from the specified dom element.
  12360. * @param element Defines the element to stop listening the inputs from
  12361. */
  12362. detachControl(element: Nullable<HTMLElement>): void;
  12363. /**
  12364. * Update the current camera state depending on the inputs that have been used this frame.
  12365. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12366. */
  12367. checkInputs(): void;
  12368. /**
  12369. * Gets the class name of the current intput.
  12370. * @returns the class name
  12371. */
  12372. getClassName(): string;
  12373. /**
  12374. * Get the friendly name associated with the input class.
  12375. * @returns the input friendly name
  12376. */
  12377. getSimpleName(): string;
  12378. }
  12379. }
  12380. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12381. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12382. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12383. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12384. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12385. import { Nullable } from "babylonjs/types";
  12386. /**
  12387. * Default Inputs manager for the FreeCamera.
  12388. * It groups all the default supported inputs for ease of use.
  12389. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12390. */
  12391. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12392. /**
  12393. * @hidden
  12394. */
  12395. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12396. /**
  12397. * @hidden
  12398. */
  12399. _mouseInput: Nullable<FreeCameraMouseInput>;
  12400. /**
  12401. * Instantiates a new FreeCameraInputsManager.
  12402. * @param camera Defines the camera the inputs belong to
  12403. */
  12404. constructor(camera: FreeCamera);
  12405. /**
  12406. * Add keyboard input support to the input manager.
  12407. * @returns the current input manager
  12408. */
  12409. addKeyboard(): FreeCameraInputsManager;
  12410. /**
  12411. * Add mouse input support to the input manager.
  12412. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12413. * @returns the current input manager
  12414. */
  12415. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12416. /**
  12417. * Removes the mouse input support from the manager
  12418. * @returns the current input manager
  12419. */
  12420. removeMouse(): FreeCameraInputsManager;
  12421. /**
  12422. * Add touch input support to the input manager.
  12423. * @returns the current input manager
  12424. */
  12425. addTouch(): FreeCameraInputsManager;
  12426. }
  12427. }
  12428. declare module "babylonjs/Cameras/freeCamera" {
  12429. import { Vector3 } from "babylonjs/Maths/math";
  12430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12431. import { Scene } from "babylonjs/scene";
  12432. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12433. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12434. /**
  12435. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12436. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12437. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12438. */
  12439. export class FreeCamera extends TargetCamera {
  12440. /**
  12441. * Define the collision ellipsoid of the camera.
  12442. * This is helpful to simulate a camera body like the player body around the camera
  12443. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12444. */
  12445. ellipsoid: Vector3;
  12446. /**
  12447. * Define an offset for the position of the ellipsoid around the camera.
  12448. * This can be helpful to determine the center of the body near the gravity center of the body
  12449. * instead of its head.
  12450. */
  12451. ellipsoidOffset: Vector3;
  12452. /**
  12453. * Enable or disable collisions of the camera with the rest of the scene objects.
  12454. */
  12455. checkCollisions: boolean;
  12456. /**
  12457. * Enable or disable gravity on the camera.
  12458. */
  12459. applyGravity: boolean;
  12460. /**
  12461. * Define the input manager associated to the camera.
  12462. */
  12463. inputs: FreeCameraInputsManager;
  12464. /**
  12465. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12466. * Higher values reduce sensitivity.
  12467. */
  12468. /**
  12469. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12470. * Higher values reduce sensitivity.
  12471. */
  12472. angularSensibility: number;
  12473. /**
  12474. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12475. */
  12476. keysUp: number[];
  12477. /**
  12478. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12479. */
  12480. keysDown: number[];
  12481. /**
  12482. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12483. */
  12484. keysLeft: number[];
  12485. /**
  12486. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12487. */
  12488. keysRight: number[];
  12489. /**
  12490. * Event raised when the camera collide with a mesh in the scene.
  12491. */
  12492. onCollide: (collidedMesh: AbstractMesh) => void;
  12493. private _collider;
  12494. private _needMoveForGravity;
  12495. private _oldPosition;
  12496. private _diffPosition;
  12497. private _newPosition;
  12498. /** @hidden */
  12499. _localDirection: Vector3;
  12500. /** @hidden */
  12501. _transformedDirection: Vector3;
  12502. /**
  12503. * Instantiates a Free Camera.
  12504. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12505. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12506. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12507. * @param name Define the name of the camera in the scene
  12508. * @param position Define the start position of the camera in the scene
  12509. * @param scene Define the scene the camera belongs to
  12510. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12511. */
  12512. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12513. /**
  12514. * Attached controls to the current camera.
  12515. * @param element Defines the element the controls should be listened from
  12516. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12517. */
  12518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12519. /**
  12520. * Detach the current controls from the camera.
  12521. * The camera will stop reacting to inputs.
  12522. * @param element Defines the element to stop listening the inputs from
  12523. */
  12524. detachControl(element: HTMLElement): void;
  12525. private _collisionMask;
  12526. /**
  12527. * Define a collision mask to limit the list of object the camera can collide with
  12528. */
  12529. collisionMask: number;
  12530. /** @hidden */
  12531. _collideWithWorld(displacement: Vector3): void;
  12532. private _onCollisionPositionChange;
  12533. /** @hidden */
  12534. _checkInputs(): void;
  12535. /** @hidden */
  12536. _decideIfNeedsToMove(): boolean;
  12537. /** @hidden */
  12538. _updatePosition(): void;
  12539. /**
  12540. * Destroy the camera and release the current resources hold by it.
  12541. */
  12542. dispose(): void;
  12543. /**
  12544. * Gets the current object class name.
  12545. * @return the class name
  12546. */
  12547. getClassName(): string;
  12548. }
  12549. }
  12550. declare module "babylonjs/Gamepads/gamepad" {
  12551. import { Observable } from "babylonjs/Misc/observable";
  12552. /**
  12553. * Represents a gamepad control stick position
  12554. */
  12555. export class StickValues {
  12556. /**
  12557. * The x component of the control stick
  12558. */
  12559. x: number;
  12560. /**
  12561. * The y component of the control stick
  12562. */
  12563. y: number;
  12564. /**
  12565. * Initializes the gamepad x and y control stick values
  12566. * @param x The x component of the gamepad control stick value
  12567. * @param y The y component of the gamepad control stick value
  12568. */
  12569. constructor(
  12570. /**
  12571. * The x component of the control stick
  12572. */
  12573. x: number,
  12574. /**
  12575. * The y component of the control stick
  12576. */
  12577. y: number);
  12578. }
  12579. /**
  12580. * An interface which manages callbacks for gamepad button changes
  12581. */
  12582. export interface GamepadButtonChanges {
  12583. /**
  12584. * Called when a gamepad has been changed
  12585. */
  12586. changed: boolean;
  12587. /**
  12588. * Called when a gamepad press event has been triggered
  12589. */
  12590. pressChanged: boolean;
  12591. /**
  12592. * Called when a touch event has been triggered
  12593. */
  12594. touchChanged: boolean;
  12595. /**
  12596. * Called when a value has changed
  12597. */
  12598. valueChanged: boolean;
  12599. }
  12600. /**
  12601. * Represents a gamepad
  12602. */
  12603. export class Gamepad {
  12604. /**
  12605. * The id of the gamepad
  12606. */
  12607. id: string;
  12608. /**
  12609. * The index of the gamepad
  12610. */
  12611. index: number;
  12612. /**
  12613. * The browser gamepad
  12614. */
  12615. browserGamepad: any;
  12616. /**
  12617. * Specifies what type of gamepad this represents
  12618. */
  12619. type: number;
  12620. private _leftStick;
  12621. private _rightStick;
  12622. /** @hidden */
  12623. _isConnected: boolean;
  12624. private _leftStickAxisX;
  12625. private _leftStickAxisY;
  12626. private _rightStickAxisX;
  12627. private _rightStickAxisY;
  12628. /**
  12629. * Triggered when the left control stick has been changed
  12630. */
  12631. private _onleftstickchanged;
  12632. /**
  12633. * Triggered when the right control stick has been changed
  12634. */
  12635. private _onrightstickchanged;
  12636. /**
  12637. * Represents a gamepad controller
  12638. */
  12639. static GAMEPAD: number;
  12640. /**
  12641. * Represents a generic controller
  12642. */
  12643. static GENERIC: number;
  12644. /**
  12645. * Represents an XBox controller
  12646. */
  12647. static XBOX: number;
  12648. /**
  12649. * Represents a pose-enabled controller
  12650. */
  12651. static POSE_ENABLED: number;
  12652. /**
  12653. * Specifies whether the left control stick should be Y-inverted
  12654. */
  12655. protected _invertLeftStickY: boolean;
  12656. /**
  12657. * Specifies if the gamepad has been connected
  12658. */
  12659. readonly isConnected: boolean;
  12660. /**
  12661. * Initializes the gamepad
  12662. * @param id The id of the gamepad
  12663. * @param index The index of the gamepad
  12664. * @param browserGamepad The browser gamepad
  12665. * @param leftStickX The x component of the left joystick
  12666. * @param leftStickY The y component of the left joystick
  12667. * @param rightStickX The x component of the right joystick
  12668. * @param rightStickY The y component of the right joystick
  12669. */
  12670. constructor(
  12671. /**
  12672. * The id of the gamepad
  12673. */
  12674. id: string,
  12675. /**
  12676. * The index of the gamepad
  12677. */
  12678. index: number,
  12679. /**
  12680. * The browser gamepad
  12681. */
  12682. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12683. /**
  12684. * Callback triggered when the left joystick has changed
  12685. * @param callback
  12686. */
  12687. onleftstickchanged(callback: (values: StickValues) => void): void;
  12688. /**
  12689. * Callback triggered when the right joystick has changed
  12690. * @param callback
  12691. */
  12692. onrightstickchanged(callback: (values: StickValues) => void): void;
  12693. /**
  12694. * Gets the left joystick
  12695. */
  12696. /**
  12697. * Sets the left joystick values
  12698. */
  12699. leftStick: StickValues;
  12700. /**
  12701. * Gets the right joystick
  12702. */
  12703. /**
  12704. * Sets the right joystick value
  12705. */
  12706. rightStick: StickValues;
  12707. /**
  12708. * Updates the gamepad joystick positions
  12709. */
  12710. update(): void;
  12711. /**
  12712. * Disposes the gamepad
  12713. */
  12714. dispose(): void;
  12715. }
  12716. /**
  12717. * Represents a generic gamepad
  12718. */
  12719. export class GenericPad extends Gamepad {
  12720. private _buttons;
  12721. private _onbuttondown;
  12722. private _onbuttonup;
  12723. /**
  12724. * Observable triggered when a button has been pressed
  12725. */
  12726. onButtonDownObservable: Observable<number>;
  12727. /**
  12728. * Observable triggered when a button has been released
  12729. */
  12730. onButtonUpObservable: Observable<number>;
  12731. /**
  12732. * Callback triggered when a button has been pressed
  12733. * @param callback Called when a button has been pressed
  12734. */
  12735. onbuttondown(callback: (buttonPressed: number) => void): void;
  12736. /**
  12737. * Callback triggered when a button has been released
  12738. * @param callback Called when a button has been released
  12739. */
  12740. onbuttonup(callback: (buttonReleased: number) => void): void;
  12741. /**
  12742. * Initializes the generic gamepad
  12743. * @param id The id of the generic gamepad
  12744. * @param index The index of the generic gamepad
  12745. * @param browserGamepad The browser gamepad
  12746. */
  12747. constructor(id: string, index: number, browserGamepad: any);
  12748. private _setButtonValue;
  12749. /**
  12750. * Updates the generic gamepad
  12751. */
  12752. update(): void;
  12753. /**
  12754. * Disposes the generic gamepad
  12755. */
  12756. dispose(): void;
  12757. }
  12758. }
  12759. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12760. import { Observable } from "babylonjs/Misc/observable";
  12761. import { Nullable } from "babylonjs/types";
  12762. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12763. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12765. import { Ray } from "babylonjs/Culling/ray";
  12766. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12767. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12768. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12769. /**
  12770. * Defines the types of pose enabled controllers that are supported
  12771. */
  12772. export enum PoseEnabledControllerType {
  12773. /**
  12774. * HTC Vive
  12775. */
  12776. VIVE = 0,
  12777. /**
  12778. * Oculus Rift
  12779. */
  12780. OCULUS = 1,
  12781. /**
  12782. * Windows mixed reality
  12783. */
  12784. WINDOWS = 2,
  12785. /**
  12786. * Samsung gear VR
  12787. */
  12788. GEAR_VR = 3,
  12789. /**
  12790. * Google Daydream
  12791. */
  12792. DAYDREAM = 4,
  12793. /**
  12794. * Generic
  12795. */
  12796. GENERIC = 5
  12797. }
  12798. /**
  12799. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12800. */
  12801. export interface MutableGamepadButton {
  12802. /**
  12803. * Value of the button/trigger
  12804. */
  12805. value: number;
  12806. /**
  12807. * If the button/trigger is currently touched
  12808. */
  12809. touched: boolean;
  12810. /**
  12811. * If the button/trigger is currently pressed
  12812. */
  12813. pressed: boolean;
  12814. }
  12815. /**
  12816. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12817. * @hidden
  12818. */
  12819. export interface ExtendedGamepadButton extends GamepadButton {
  12820. /**
  12821. * If the button/trigger is currently pressed
  12822. */
  12823. readonly pressed: boolean;
  12824. /**
  12825. * If the button/trigger is currently touched
  12826. */
  12827. readonly touched: boolean;
  12828. /**
  12829. * Value of the button/trigger
  12830. */
  12831. readonly value: number;
  12832. }
  12833. /** @hidden */
  12834. export interface _GamePadFactory {
  12835. /**
  12836. * Returns wether or not the current gamepad can be created for this type of controller.
  12837. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12838. * @returns true if it can be created, otherwise false
  12839. */
  12840. canCreate(gamepadInfo: any): boolean;
  12841. /**
  12842. * Creates a new instance of the Gamepad.
  12843. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12844. * @returns the new gamepad instance
  12845. */
  12846. create(gamepadInfo: any): Gamepad;
  12847. }
  12848. /**
  12849. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12850. */
  12851. export class PoseEnabledControllerHelper {
  12852. /** @hidden */
  12853. static _ControllerFactories: _GamePadFactory[];
  12854. /** @hidden */
  12855. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12856. /**
  12857. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12858. * @param vrGamepad the gamepad to initialized
  12859. * @returns a vr controller of the type the gamepad identified as
  12860. */
  12861. static InitiateController(vrGamepad: any): Gamepad;
  12862. }
  12863. /**
  12864. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12865. */
  12866. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12867. private _deviceRoomPosition;
  12868. private _deviceRoomRotationQuaternion;
  12869. /**
  12870. * The device position in babylon space
  12871. */
  12872. devicePosition: Vector3;
  12873. /**
  12874. * The device rotation in babylon space
  12875. */
  12876. deviceRotationQuaternion: Quaternion;
  12877. /**
  12878. * The scale factor of the device in babylon space
  12879. */
  12880. deviceScaleFactor: number;
  12881. /**
  12882. * (Likely devicePosition should be used instead) The device position in its room space
  12883. */
  12884. position: Vector3;
  12885. /**
  12886. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12887. */
  12888. rotationQuaternion: Quaternion;
  12889. /**
  12890. * The type of controller (Eg. Windows mixed reality)
  12891. */
  12892. controllerType: PoseEnabledControllerType;
  12893. protected _calculatedPosition: Vector3;
  12894. private _calculatedRotation;
  12895. /**
  12896. * The raw pose from the device
  12897. */
  12898. rawPose: DevicePose;
  12899. private _trackPosition;
  12900. private _maxRotationDistFromHeadset;
  12901. private _draggedRoomRotation;
  12902. /**
  12903. * @hidden
  12904. */
  12905. _disableTrackPosition(fixedPosition: Vector3): void;
  12906. /**
  12907. * Internal, the mesh attached to the controller
  12908. * @hidden
  12909. */
  12910. _mesh: Nullable<AbstractMesh>;
  12911. private _poseControlledCamera;
  12912. private _leftHandSystemQuaternion;
  12913. /**
  12914. * Internal, matrix used to convert room space to babylon space
  12915. * @hidden
  12916. */
  12917. _deviceToWorld: Matrix;
  12918. /**
  12919. * Node to be used when casting a ray from the controller
  12920. * @hidden
  12921. */
  12922. _pointingPoseNode: Nullable<TransformNode>;
  12923. /**
  12924. * Name of the child mesh that can be used to cast a ray from the controller
  12925. */
  12926. static readonly POINTING_POSE: string;
  12927. /**
  12928. * Creates a new PoseEnabledController from a gamepad
  12929. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12930. */
  12931. constructor(browserGamepad: any);
  12932. private _workingMatrix;
  12933. /**
  12934. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12935. */
  12936. update(): void;
  12937. /**
  12938. * Updates only the pose device and mesh without doing any button event checking
  12939. */
  12940. protected _updatePoseAndMesh(): void;
  12941. /**
  12942. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12943. * @param poseData raw pose fromthe device
  12944. */
  12945. updateFromDevice(poseData: DevicePose): void;
  12946. /**
  12947. * @hidden
  12948. */
  12949. _meshAttachedObservable: Observable<AbstractMesh>;
  12950. /**
  12951. * Attaches a mesh to the controller
  12952. * @param mesh the mesh to be attached
  12953. */
  12954. attachToMesh(mesh: AbstractMesh): void;
  12955. /**
  12956. * Attaches the controllers mesh to a camera
  12957. * @param camera the camera the mesh should be attached to
  12958. */
  12959. attachToPoseControlledCamera(camera: TargetCamera): void;
  12960. /**
  12961. * Disposes of the controller
  12962. */
  12963. dispose(): void;
  12964. /**
  12965. * The mesh that is attached to the controller
  12966. */
  12967. readonly mesh: Nullable<AbstractMesh>;
  12968. /**
  12969. * Gets the ray of the controller in the direction the controller is pointing
  12970. * @param length the length the resulting ray should be
  12971. * @returns a ray in the direction the controller is pointing
  12972. */
  12973. getForwardRay(length?: number): Ray;
  12974. }
  12975. }
  12976. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12977. import { Observable } from "babylonjs/Misc/observable";
  12978. import { Scene } from "babylonjs/scene";
  12979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12980. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12981. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12982. /**
  12983. * Defines the WebVRController object that represents controllers tracked in 3D space
  12984. */
  12985. export abstract class WebVRController extends PoseEnabledController {
  12986. /**
  12987. * Internal, the default controller model for the controller
  12988. */
  12989. protected _defaultModel: AbstractMesh;
  12990. /**
  12991. * Fired when the trigger state has changed
  12992. */
  12993. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12994. /**
  12995. * Fired when the main button state has changed
  12996. */
  12997. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12998. /**
  12999. * Fired when the secondary button state has changed
  13000. */
  13001. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13002. /**
  13003. * Fired when the pad state has changed
  13004. */
  13005. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13006. /**
  13007. * Fired when controllers stick values have changed
  13008. */
  13009. onPadValuesChangedObservable: Observable<StickValues>;
  13010. /**
  13011. * Array of button availible on the controller
  13012. */
  13013. protected _buttons: Array<MutableGamepadButton>;
  13014. private _onButtonStateChange;
  13015. /**
  13016. * Fired when a controller button's state has changed
  13017. * @param callback the callback containing the button that was modified
  13018. */
  13019. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13020. /**
  13021. * X and Y axis corrisponding to the controllers joystick
  13022. */
  13023. pad: StickValues;
  13024. /**
  13025. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13026. */
  13027. hand: string;
  13028. /**
  13029. * The default controller model for the controller
  13030. */
  13031. readonly defaultModel: AbstractMesh;
  13032. /**
  13033. * Creates a new WebVRController from a gamepad
  13034. * @param vrGamepad the gamepad that the WebVRController should be created from
  13035. */
  13036. constructor(vrGamepad: any);
  13037. /**
  13038. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13039. */
  13040. update(): void;
  13041. /**
  13042. * Function to be called when a button is modified
  13043. */
  13044. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13045. /**
  13046. * Loads a mesh and attaches it to the controller
  13047. * @param scene the scene the mesh should be added to
  13048. * @param meshLoaded callback for when the mesh has been loaded
  13049. */
  13050. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13051. private _setButtonValue;
  13052. private _changes;
  13053. private _checkChanges;
  13054. /**
  13055. * Disposes of th webVRCOntroller
  13056. */
  13057. dispose(): void;
  13058. }
  13059. }
  13060. declare module "babylonjs/Lights/hemisphericLight" {
  13061. import { Nullable } from "babylonjs/types";
  13062. import { Scene } from "babylonjs/scene";
  13063. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13064. import { Effect } from "babylonjs/Materials/effect";
  13065. import { Light } from "babylonjs/Lights/light";
  13066. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13067. /**
  13068. * The HemisphericLight simulates the ambient environment light,
  13069. * so the passed direction is the light reflection direction, not the incoming direction.
  13070. */
  13071. export class HemisphericLight extends Light {
  13072. /**
  13073. * The groundColor is the light in the opposite direction to the one specified during creation.
  13074. * 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.
  13075. */
  13076. groundColor: Color3;
  13077. /**
  13078. * The light reflection direction, not the incoming direction.
  13079. */
  13080. direction: Vector3;
  13081. /**
  13082. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13083. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13084. * The HemisphericLight can't cast shadows.
  13085. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13086. * @param name The friendly name of the light
  13087. * @param direction The direction of the light reflection
  13088. * @param scene The scene the light belongs to
  13089. */
  13090. constructor(name: string, direction: Vector3, scene: Scene);
  13091. protected _buildUniformLayout(): void;
  13092. /**
  13093. * Returns the string "HemisphericLight".
  13094. * @return The class name
  13095. */
  13096. getClassName(): string;
  13097. /**
  13098. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13099. * Returns the updated direction.
  13100. * @param target The target the direction should point to
  13101. * @return The computed direction
  13102. */
  13103. setDirectionToTarget(target: Vector3): Vector3;
  13104. /**
  13105. * Returns the shadow generator associated to the light.
  13106. * @returns Always null for hemispheric lights because it does not support shadows.
  13107. */
  13108. getShadowGenerator(): Nullable<IShadowGenerator>;
  13109. /**
  13110. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13111. * @param effect The effect to update
  13112. * @param lightIndex The index of the light in the effect to update
  13113. * @returns The hemispheric light
  13114. */
  13115. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13116. /**
  13117. * Computes the world matrix of the node
  13118. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13119. * @param useWasUpdatedFlag defines a reserved property
  13120. * @returns the world matrix
  13121. */
  13122. computeWorldMatrix(): Matrix;
  13123. /**
  13124. * Returns the integer 3.
  13125. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13126. */
  13127. getTypeID(): number;
  13128. /**
  13129. * Prepares the list of defines specific to the light type.
  13130. * @param defines the list of defines
  13131. * @param lightIndex defines the index of the light for the effect
  13132. */
  13133. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13134. }
  13135. }
  13136. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13137. /** @hidden */
  13138. export var vrMultiviewToSingleviewPixelShader: {
  13139. name: string;
  13140. shader: string;
  13141. };
  13142. }
  13143. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13144. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13145. import { Scene } from "babylonjs/scene";
  13146. /**
  13147. * Renders to multiple views with a single draw call
  13148. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13149. */
  13150. export class MultiviewRenderTarget extends RenderTargetTexture {
  13151. /**
  13152. * Creates a multiview render target
  13153. * @param scene scene used with the render target
  13154. * @param size the size of the render target (used for each view)
  13155. */
  13156. constructor(scene: Scene, size?: number | {
  13157. width: number;
  13158. height: number;
  13159. } | {
  13160. ratio: number;
  13161. });
  13162. /**
  13163. * @hidden
  13164. * @param faceIndex the face index, if its a cube texture
  13165. */
  13166. _bindFrameBuffer(faceIndex?: number): void;
  13167. /**
  13168. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13169. * @returns the view count
  13170. */
  13171. getViewCount(): number;
  13172. }
  13173. }
  13174. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13175. import { Camera } from "babylonjs/Cameras/camera";
  13176. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13177. import { Nullable } from "babylonjs/types";
  13178. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13179. import { Matrix } from "babylonjs/Maths/math";
  13180. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13181. module "babylonjs/Engines/engine" {
  13182. interface Engine {
  13183. /**
  13184. * Creates a new multiview render target
  13185. * @param width defines the width of the texture
  13186. * @param height defines the height of the texture
  13187. * @returns the created multiview texture
  13188. */
  13189. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13190. /**
  13191. * Binds a multiview framebuffer to be drawn to
  13192. * @param multiviewTexture texture to bind
  13193. */
  13194. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13195. }
  13196. }
  13197. module "babylonjs/Cameras/camera" {
  13198. interface Camera {
  13199. /**
  13200. * @hidden
  13201. * 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)
  13202. */
  13203. _useMultiviewToSingleView: boolean;
  13204. /**
  13205. * @hidden
  13206. * 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)
  13207. */
  13208. _multiviewTexture: Nullable<RenderTargetTexture>;
  13209. /**
  13210. * @hidden
  13211. * ensures the multiview texture of the camera exists and has the specified width/height
  13212. * @param width height to set on the multiview texture
  13213. * @param height width to set on the multiview texture
  13214. */
  13215. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13216. }
  13217. }
  13218. module "babylonjs/scene" {
  13219. interface Scene {
  13220. /** @hidden */
  13221. _transformMatrixR: Matrix;
  13222. /** @hidden */
  13223. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13224. /** @hidden */
  13225. _createMultiviewUbo(): void;
  13226. /** @hidden */
  13227. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13228. /** @hidden */
  13229. _renderMultiviewToSingleView(camera: Camera): void;
  13230. }
  13231. }
  13232. }
  13233. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13234. import { Camera } from "babylonjs/Cameras/camera";
  13235. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13236. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13237. import "babylonjs/Engines/Extensions/engine.multiview";
  13238. /**
  13239. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13240. * This will not be used for webXR as it supports displaying texture arrays directly
  13241. */
  13242. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13243. /**
  13244. * Initializes a VRMultiviewToSingleview
  13245. * @param name name of the post process
  13246. * @param camera camera to be applied to
  13247. * @param scaleFactor scaling factor to the size of the output texture
  13248. */
  13249. constructor(name: string, camera: Camera, scaleFactor: number);
  13250. }
  13251. }
  13252. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13253. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13254. import { Nullable } from "babylonjs/types";
  13255. import { Observable } from "babylonjs/Misc/observable";
  13256. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13257. import { Scene } from "babylonjs/scene";
  13258. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13259. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13260. import { Node } from "babylonjs/node";
  13261. import { Ray } from "babylonjs/Culling/ray";
  13262. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13263. /**
  13264. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13265. * IMPORTANT!! The data is right-hand data.
  13266. * @export
  13267. * @interface DevicePose
  13268. */
  13269. export interface DevicePose {
  13270. /**
  13271. * The position of the device, values in array are [x,y,z].
  13272. */
  13273. readonly position: Nullable<Float32Array>;
  13274. /**
  13275. * The linearVelocity of the device, values in array are [x,y,z].
  13276. */
  13277. readonly linearVelocity: Nullable<Float32Array>;
  13278. /**
  13279. * The linearAcceleration of the device, values in array are [x,y,z].
  13280. */
  13281. readonly linearAcceleration: Nullable<Float32Array>;
  13282. /**
  13283. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13284. */
  13285. readonly orientation: Nullable<Float32Array>;
  13286. /**
  13287. * The angularVelocity of the device, values in array are [x,y,z].
  13288. */
  13289. readonly angularVelocity: Nullable<Float32Array>;
  13290. /**
  13291. * The angularAcceleration of the device, values in array are [x,y,z].
  13292. */
  13293. readonly angularAcceleration: Nullable<Float32Array>;
  13294. }
  13295. /**
  13296. * Interface representing a pose controlled object in Babylon.
  13297. * A pose controlled object has both regular pose values as well as pose values
  13298. * from an external device such as a VR head mounted display
  13299. */
  13300. export interface PoseControlled {
  13301. /**
  13302. * The position of the object in babylon space.
  13303. */
  13304. position: Vector3;
  13305. /**
  13306. * The rotation quaternion of the object in babylon space.
  13307. */
  13308. rotationQuaternion: Quaternion;
  13309. /**
  13310. * The position of the device in babylon space.
  13311. */
  13312. devicePosition?: Vector3;
  13313. /**
  13314. * The rotation quaternion of the device in babylon space.
  13315. */
  13316. deviceRotationQuaternion: Quaternion;
  13317. /**
  13318. * The raw pose coming from the device.
  13319. */
  13320. rawPose: Nullable<DevicePose>;
  13321. /**
  13322. * The scale of the device to be used when translating from device space to babylon space.
  13323. */
  13324. deviceScaleFactor: number;
  13325. /**
  13326. * Updates the poseControlled values based on the input device pose.
  13327. * @param poseData the pose data to update the object with
  13328. */
  13329. updateFromDevice(poseData: DevicePose): void;
  13330. }
  13331. /**
  13332. * Set of options to customize the webVRCamera
  13333. */
  13334. export interface WebVROptions {
  13335. /**
  13336. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13337. */
  13338. trackPosition?: boolean;
  13339. /**
  13340. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13341. */
  13342. positionScale?: number;
  13343. /**
  13344. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13345. */
  13346. displayName?: string;
  13347. /**
  13348. * Should the native controller meshes be initialized. (default: true)
  13349. */
  13350. controllerMeshes?: boolean;
  13351. /**
  13352. * Creating a default HemiLight only on controllers. (default: true)
  13353. */
  13354. defaultLightingOnControllers?: boolean;
  13355. /**
  13356. * If you don't want to use the default VR button of the helper. (default: false)
  13357. */
  13358. useCustomVRButton?: boolean;
  13359. /**
  13360. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13361. */
  13362. customVRButton?: HTMLButtonElement;
  13363. /**
  13364. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13365. */
  13366. rayLength?: number;
  13367. /**
  13368. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13369. */
  13370. defaultHeight?: number;
  13371. /**
  13372. * If multiview should be used if availible (default: false)
  13373. */
  13374. useMultiview?: boolean;
  13375. }
  13376. /**
  13377. * This represents a WebVR camera.
  13378. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13379. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13380. */
  13381. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13382. private webVROptions;
  13383. /**
  13384. * @hidden
  13385. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13386. */
  13387. _vrDevice: any;
  13388. /**
  13389. * The rawPose of the vrDevice.
  13390. */
  13391. rawPose: Nullable<DevicePose>;
  13392. private _onVREnabled;
  13393. private _specsVersion;
  13394. private _attached;
  13395. private _frameData;
  13396. protected _descendants: Array<Node>;
  13397. private _deviceRoomPosition;
  13398. /** @hidden */
  13399. _deviceRoomRotationQuaternion: Quaternion;
  13400. private _standingMatrix;
  13401. /**
  13402. * Represents device position in babylon space.
  13403. */
  13404. devicePosition: Vector3;
  13405. /**
  13406. * Represents device rotation in babylon space.
  13407. */
  13408. deviceRotationQuaternion: Quaternion;
  13409. /**
  13410. * The scale of the device to be used when translating from device space to babylon space.
  13411. */
  13412. deviceScaleFactor: number;
  13413. private _deviceToWorld;
  13414. private _worldToDevice;
  13415. /**
  13416. * References to the webVR controllers for the vrDevice.
  13417. */
  13418. controllers: Array<WebVRController>;
  13419. /**
  13420. * Emits an event when a controller is attached.
  13421. */
  13422. onControllersAttachedObservable: Observable<WebVRController[]>;
  13423. /**
  13424. * Emits an event when a controller's mesh has been loaded;
  13425. */
  13426. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13427. /**
  13428. * Emits an event when the HMD's pose has been updated.
  13429. */
  13430. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13431. private _poseSet;
  13432. /**
  13433. * If the rig cameras be used as parent instead of this camera.
  13434. */
  13435. rigParenting: boolean;
  13436. private _lightOnControllers;
  13437. private _defaultHeight?;
  13438. /**
  13439. * Instantiates a WebVRFreeCamera.
  13440. * @param name The name of the WebVRFreeCamera
  13441. * @param position The starting anchor position for the camera
  13442. * @param scene The scene the camera belongs to
  13443. * @param webVROptions a set of customizable options for the webVRCamera
  13444. */
  13445. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13446. /**
  13447. * Gets the device distance from the ground in meters.
  13448. * @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.
  13449. */
  13450. deviceDistanceToRoomGround(): number;
  13451. /**
  13452. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13453. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13454. */
  13455. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13456. /**
  13457. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13458. * @returns A promise with a boolean set to if the standing matrix is supported.
  13459. */
  13460. useStandingMatrixAsync(): Promise<boolean>;
  13461. /**
  13462. * Disposes the camera
  13463. */
  13464. dispose(): void;
  13465. /**
  13466. * Gets a vrController by name.
  13467. * @param name The name of the controller to retreive
  13468. * @returns the controller matching the name specified or null if not found
  13469. */
  13470. getControllerByName(name: string): Nullable<WebVRController>;
  13471. private _leftController;
  13472. /**
  13473. * The controller corrisponding to the users left hand.
  13474. */
  13475. readonly leftController: Nullable<WebVRController>;
  13476. private _rightController;
  13477. /**
  13478. * The controller corrisponding to the users right hand.
  13479. */
  13480. readonly rightController: Nullable<WebVRController>;
  13481. /**
  13482. * Casts a ray forward from the vrCamera's gaze.
  13483. * @param length Length of the ray (default: 100)
  13484. * @returns the ray corrisponding to the gaze
  13485. */
  13486. getForwardRay(length?: number): Ray;
  13487. /**
  13488. * @hidden
  13489. * Updates the camera based on device's frame data
  13490. */
  13491. _checkInputs(): void;
  13492. /**
  13493. * Updates the poseControlled values based on the input device pose.
  13494. * @param poseData Pose coming from the device
  13495. */
  13496. updateFromDevice(poseData: DevicePose): void;
  13497. private _htmlElementAttached;
  13498. private _detachIfAttached;
  13499. /**
  13500. * WebVR's attach control will start broadcasting frames to the device.
  13501. * Note that in certain browsers (chrome for example) this function must be called
  13502. * within a user-interaction callback. Example:
  13503. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13504. *
  13505. * @param element html element to attach the vrDevice to
  13506. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13507. */
  13508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13509. /**
  13510. * Detaches the camera from the html element and disables VR
  13511. *
  13512. * @param element html element to detach from
  13513. */
  13514. detachControl(element: HTMLElement): void;
  13515. /**
  13516. * @returns the name of this class
  13517. */
  13518. getClassName(): string;
  13519. /**
  13520. * Calls resetPose on the vrDisplay
  13521. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13522. */
  13523. resetToCurrentRotation(): void;
  13524. /**
  13525. * @hidden
  13526. * Updates the rig cameras (left and right eye)
  13527. */
  13528. _updateRigCameras(): void;
  13529. private _workingVector;
  13530. private _oneVector;
  13531. private _workingMatrix;
  13532. private updateCacheCalled;
  13533. private _correctPositionIfNotTrackPosition;
  13534. /**
  13535. * @hidden
  13536. * Updates the cached values of the camera
  13537. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13538. */
  13539. _updateCache(ignoreParentClass?: boolean): void;
  13540. /**
  13541. * @hidden
  13542. * Get current device position in babylon world
  13543. */
  13544. _computeDevicePosition(): void;
  13545. /**
  13546. * Updates the current device position and rotation in the babylon world
  13547. */
  13548. update(): void;
  13549. /**
  13550. * @hidden
  13551. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13552. * @returns an identity matrix
  13553. */
  13554. _getViewMatrix(): Matrix;
  13555. private _tmpMatrix;
  13556. /**
  13557. * This function is called by the two RIG cameras.
  13558. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13559. * @hidden
  13560. */
  13561. _getWebVRViewMatrix(): Matrix;
  13562. /** @hidden */
  13563. _getWebVRProjectionMatrix(): Matrix;
  13564. private _onGamepadConnectedObserver;
  13565. private _onGamepadDisconnectedObserver;
  13566. private _updateCacheWhenTrackingDisabledObserver;
  13567. /**
  13568. * Initializes the controllers and their meshes
  13569. */
  13570. initControllers(): void;
  13571. }
  13572. }
  13573. declare module "babylonjs/PostProcesses/postProcess" {
  13574. import { Nullable } from "babylonjs/types";
  13575. import { SmartArray } from "babylonjs/Misc/smartArray";
  13576. import { Observable } from "babylonjs/Misc/observable";
  13577. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13578. import { Camera } from "babylonjs/Cameras/camera";
  13579. import { Effect } from "babylonjs/Materials/effect";
  13580. import "babylonjs/Shaders/postprocess.vertex";
  13581. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13582. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13583. import { Engine } from "babylonjs/Engines/engine";
  13584. /**
  13585. * Size options for a post process
  13586. */
  13587. export type PostProcessOptions = {
  13588. width: number;
  13589. height: number;
  13590. };
  13591. /**
  13592. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13593. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13594. */
  13595. export class PostProcess {
  13596. /** Name of the PostProcess. */
  13597. name: string;
  13598. /**
  13599. * Gets or sets the unique id of the post process
  13600. */
  13601. uniqueId: number;
  13602. /**
  13603. * Width of the texture to apply the post process on
  13604. */
  13605. width: number;
  13606. /**
  13607. * Height of the texture to apply the post process on
  13608. */
  13609. height: number;
  13610. /**
  13611. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13612. * @hidden
  13613. */
  13614. _outputTexture: Nullable<InternalTexture>;
  13615. /**
  13616. * Sampling mode used by the shader
  13617. * See https://doc.babylonjs.com/classes/3.1/texture
  13618. */
  13619. renderTargetSamplingMode: number;
  13620. /**
  13621. * Clear color to use when screen clearing
  13622. */
  13623. clearColor: Color4;
  13624. /**
  13625. * If the buffer needs to be cleared before applying the post process. (default: true)
  13626. * Should be set to false if shader will overwrite all previous pixels.
  13627. */
  13628. autoClear: boolean;
  13629. /**
  13630. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13631. */
  13632. alphaMode: number;
  13633. /**
  13634. * Sets the setAlphaBlendConstants of the babylon engine
  13635. */
  13636. alphaConstants: Color4;
  13637. /**
  13638. * Animations to be used for the post processing
  13639. */
  13640. animations: import("babylonjs/Animations/animation").Animation[];
  13641. /**
  13642. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13643. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13644. */
  13645. enablePixelPerfectMode: boolean;
  13646. /**
  13647. * Force the postprocess to be applied without taking in account viewport
  13648. */
  13649. forceFullscreenViewport: boolean;
  13650. /**
  13651. * List of inspectable custom properties (used by the Inspector)
  13652. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13653. */
  13654. inspectableCustomProperties: IInspectable[];
  13655. /**
  13656. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13657. *
  13658. * | Value | Type | Description |
  13659. * | ----- | ----------------------------------- | ----------- |
  13660. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13661. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13662. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13663. *
  13664. */
  13665. scaleMode: number;
  13666. /**
  13667. * Force textures to be a power of two (default: false)
  13668. */
  13669. alwaysForcePOT: boolean;
  13670. private _samples;
  13671. /**
  13672. * Number of sample textures (default: 1)
  13673. */
  13674. samples: number;
  13675. /**
  13676. * Modify the scale of the post process to be the same as the viewport (default: false)
  13677. */
  13678. adaptScaleToCurrentViewport: boolean;
  13679. private _camera;
  13680. private _scene;
  13681. private _engine;
  13682. private _options;
  13683. private _reusable;
  13684. private _textureType;
  13685. /**
  13686. * Smart array of input and output textures for the post process.
  13687. * @hidden
  13688. */
  13689. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13690. /**
  13691. * The index in _textures that corresponds to the output texture.
  13692. * @hidden
  13693. */
  13694. _currentRenderTextureInd: number;
  13695. private _effect;
  13696. private _samplers;
  13697. private _fragmentUrl;
  13698. private _vertexUrl;
  13699. private _parameters;
  13700. private _scaleRatio;
  13701. protected _indexParameters: any;
  13702. private _shareOutputWithPostProcess;
  13703. private _texelSize;
  13704. private _forcedOutputTexture;
  13705. /**
  13706. * Returns the fragment url or shader name used in the post process.
  13707. * @returns the fragment url or name in the shader store.
  13708. */
  13709. getEffectName(): string;
  13710. /**
  13711. * An event triggered when the postprocess is activated.
  13712. */
  13713. onActivateObservable: Observable<Camera>;
  13714. private _onActivateObserver;
  13715. /**
  13716. * A function that is added to the onActivateObservable
  13717. */
  13718. onActivate: Nullable<(camera: Camera) => void>;
  13719. /**
  13720. * An event triggered when the postprocess changes its size.
  13721. */
  13722. onSizeChangedObservable: Observable<PostProcess>;
  13723. private _onSizeChangedObserver;
  13724. /**
  13725. * A function that is added to the onSizeChangedObservable
  13726. */
  13727. onSizeChanged: (postProcess: PostProcess) => void;
  13728. /**
  13729. * An event triggered when the postprocess applies its effect.
  13730. */
  13731. onApplyObservable: Observable<Effect>;
  13732. private _onApplyObserver;
  13733. /**
  13734. * A function that is added to the onApplyObservable
  13735. */
  13736. onApply: (effect: Effect) => void;
  13737. /**
  13738. * An event triggered before rendering the postprocess
  13739. */
  13740. onBeforeRenderObservable: Observable<Effect>;
  13741. private _onBeforeRenderObserver;
  13742. /**
  13743. * A function that is added to the onBeforeRenderObservable
  13744. */
  13745. onBeforeRender: (effect: Effect) => void;
  13746. /**
  13747. * An event triggered after rendering the postprocess
  13748. */
  13749. onAfterRenderObservable: Observable<Effect>;
  13750. private _onAfterRenderObserver;
  13751. /**
  13752. * A function that is added to the onAfterRenderObservable
  13753. */
  13754. onAfterRender: (efect: Effect) => void;
  13755. /**
  13756. * 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
  13757. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13758. */
  13759. inputTexture: InternalTexture;
  13760. /**
  13761. * Gets the camera which post process is applied to.
  13762. * @returns The camera the post process is applied to.
  13763. */
  13764. getCamera(): Camera;
  13765. /**
  13766. * Gets the texel size of the postprocess.
  13767. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13768. */
  13769. readonly texelSize: Vector2;
  13770. /**
  13771. * Creates a new instance PostProcess
  13772. * @param name The name of the PostProcess.
  13773. * @param fragmentUrl The url of the fragment shader to be used.
  13774. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13775. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13776. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13777. * @param camera The camera to apply the render pass to.
  13778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13779. * @param engine The engine which the post process will be applied. (default: current engine)
  13780. * @param reusable If the post process can be reused on the same frame. (default: false)
  13781. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13782. * @param textureType Type of textures used when performing the post process. (default: 0)
  13783. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13784. * @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
  13785. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13786. */
  13787. constructor(
  13788. /** Name of the PostProcess. */
  13789. 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);
  13790. /**
  13791. * Gets a string idenfifying the name of the class
  13792. * @returns "PostProcess" string
  13793. */
  13794. getClassName(): string;
  13795. /**
  13796. * Gets the engine which this post process belongs to.
  13797. * @returns The engine the post process was enabled with.
  13798. */
  13799. getEngine(): Engine;
  13800. /**
  13801. * The effect that is created when initializing the post process.
  13802. * @returns The created effect corrisponding the the postprocess.
  13803. */
  13804. getEffect(): Effect;
  13805. /**
  13806. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13807. * @param postProcess The post process to share the output with.
  13808. * @returns This post process.
  13809. */
  13810. shareOutputWith(postProcess: PostProcess): PostProcess;
  13811. /**
  13812. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13813. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13814. */
  13815. useOwnOutput(): void;
  13816. /**
  13817. * Updates the effect with the current post process compile time values and recompiles the shader.
  13818. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13819. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13820. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13821. * @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
  13822. * @param onCompiled Called when the shader has been compiled.
  13823. * @param onError Called if there is an error when compiling a shader.
  13824. */
  13825. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13826. /**
  13827. * The post process is reusable if it can be used multiple times within one frame.
  13828. * @returns If the post process is reusable
  13829. */
  13830. isReusable(): boolean;
  13831. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13832. markTextureDirty(): void;
  13833. /**
  13834. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13835. * 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.
  13836. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13837. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13838. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13839. * @returns The target texture that was bound to be written to.
  13840. */
  13841. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13842. /**
  13843. * If the post process is supported.
  13844. */
  13845. readonly isSupported: boolean;
  13846. /**
  13847. * The aspect ratio of the output texture.
  13848. */
  13849. readonly aspectRatio: number;
  13850. /**
  13851. * Get a value indicating if the post-process is ready to be used
  13852. * @returns true if the post-process is ready (shader is compiled)
  13853. */
  13854. isReady(): boolean;
  13855. /**
  13856. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13857. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13858. */
  13859. apply(): Nullable<Effect>;
  13860. private _disposeTextures;
  13861. /**
  13862. * Disposes the post process.
  13863. * @param camera The camera to dispose the post process on.
  13864. */
  13865. dispose(camera?: Camera): void;
  13866. }
  13867. }
  13868. declare module "babylonjs/PostProcesses/postProcessManager" {
  13869. import { Nullable } from "babylonjs/types";
  13870. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13871. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13872. import { Scene } from "babylonjs/scene";
  13873. /**
  13874. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13875. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13876. */
  13877. export class PostProcessManager {
  13878. private _scene;
  13879. private _indexBuffer;
  13880. private _vertexBuffers;
  13881. /**
  13882. * Creates a new instance PostProcess
  13883. * @param scene The scene that the post process is associated with.
  13884. */
  13885. constructor(scene: Scene);
  13886. private _prepareBuffers;
  13887. private _buildIndexBuffer;
  13888. /**
  13889. * Rebuilds the vertex buffers of the manager.
  13890. * @hidden
  13891. */
  13892. _rebuild(): void;
  13893. /**
  13894. * Prepares a frame to be run through a post process.
  13895. * @param sourceTexture The input texture to the post procesess. (default: null)
  13896. * @param postProcesses An array of post processes to be run. (default: null)
  13897. * @returns True if the post processes were able to be run.
  13898. * @hidden
  13899. */
  13900. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13901. /**
  13902. * Manually render a set of post processes to a texture.
  13903. * @param postProcesses An array of post processes to be run.
  13904. * @param targetTexture The target texture to render to.
  13905. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13906. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13907. * @param lodLevel defines which lod of the texture to render to
  13908. */
  13909. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13910. /**
  13911. * Finalize the result of the output of the postprocesses.
  13912. * @param doNotPresent If true the result will not be displayed to the screen.
  13913. * @param targetTexture The target texture to render to.
  13914. * @param faceIndex The index of the face to bind the target texture to.
  13915. * @param postProcesses The array of post processes to render.
  13916. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13917. * @hidden
  13918. */
  13919. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13920. /**
  13921. * Disposes of the post process manager.
  13922. */
  13923. dispose(): void;
  13924. }
  13925. }
  13926. declare module "babylonjs/Layers/layerSceneComponent" {
  13927. import { Scene } from "babylonjs/scene";
  13928. import { ISceneComponent } from "babylonjs/sceneComponent";
  13929. import { Layer } from "babylonjs/Layers/layer";
  13930. module "babylonjs/abstractScene" {
  13931. interface AbstractScene {
  13932. /**
  13933. * The list of layers (background and foreground) of the scene
  13934. */
  13935. layers: Array<Layer>;
  13936. }
  13937. }
  13938. /**
  13939. * Defines the layer scene component responsible to manage any layers
  13940. * in a given scene.
  13941. */
  13942. export class LayerSceneComponent implements ISceneComponent {
  13943. /**
  13944. * The component name helpfull to identify the component in the list of scene components.
  13945. */
  13946. readonly name: string;
  13947. /**
  13948. * The scene the component belongs to.
  13949. */
  13950. scene: Scene;
  13951. private _engine;
  13952. /**
  13953. * Creates a new instance of the component for the given scene
  13954. * @param scene Defines the scene to register the component in
  13955. */
  13956. constructor(scene: Scene);
  13957. /**
  13958. * Registers the component in a given scene
  13959. */
  13960. register(): void;
  13961. /**
  13962. * Rebuilds the elements related to this component in case of
  13963. * context lost for instance.
  13964. */
  13965. rebuild(): void;
  13966. /**
  13967. * Disposes the component and the associated ressources.
  13968. */
  13969. dispose(): void;
  13970. private _draw;
  13971. private _drawCameraPredicate;
  13972. private _drawCameraBackground;
  13973. private _drawCameraForeground;
  13974. private _drawRenderTargetPredicate;
  13975. private _drawRenderTargetBackground;
  13976. private _drawRenderTargetForeground;
  13977. }
  13978. }
  13979. declare module "babylonjs/Shaders/layer.fragment" {
  13980. /** @hidden */
  13981. export var layerPixelShader: {
  13982. name: string;
  13983. shader: string;
  13984. };
  13985. }
  13986. declare module "babylonjs/Shaders/layer.vertex" {
  13987. /** @hidden */
  13988. export var layerVertexShader: {
  13989. name: string;
  13990. shader: string;
  13991. };
  13992. }
  13993. declare module "babylonjs/Layers/layer" {
  13994. import { Observable } from "babylonjs/Misc/observable";
  13995. import { Nullable } from "babylonjs/types";
  13996. import { Scene } from "babylonjs/scene";
  13997. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13998. import { Texture } from "babylonjs/Materials/Textures/texture";
  13999. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14000. import "babylonjs/Shaders/layer.fragment";
  14001. import "babylonjs/Shaders/layer.vertex";
  14002. /**
  14003. * This represents a full screen 2d layer.
  14004. * This can be useful to display a picture in the background of your scene for instance.
  14005. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14006. */
  14007. export class Layer {
  14008. /**
  14009. * Define the name of the layer.
  14010. */
  14011. name: string;
  14012. /**
  14013. * Define the texture the layer should display.
  14014. */
  14015. texture: Nullable<Texture>;
  14016. /**
  14017. * Is the layer in background or foreground.
  14018. */
  14019. isBackground: boolean;
  14020. /**
  14021. * Define the color of the layer (instead of texture).
  14022. */
  14023. color: Color4;
  14024. /**
  14025. * Define the scale of the layer in order to zoom in out of the texture.
  14026. */
  14027. scale: Vector2;
  14028. /**
  14029. * Define an offset for the layer in order to shift the texture.
  14030. */
  14031. offset: Vector2;
  14032. /**
  14033. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14034. */
  14035. alphaBlendingMode: number;
  14036. /**
  14037. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14038. * Alpha test will not mix with the background color in case of transparency.
  14039. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14040. */
  14041. alphaTest: boolean;
  14042. /**
  14043. * Define a mask to restrict the layer to only some of the scene cameras.
  14044. */
  14045. layerMask: number;
  14046. /**
  14047. * Define the list of render target the layer is visible into.
  14048. */
  14049. renderTargetTextures: RenderTargetTexture[];
  14050. /**
  14051. * Define if the layer is only used in renderTarget or if it also
  14052. * renders in the main frame buffer of the canvas.
  14053. */
  14054. renderOnlyInRenderTargetTextures: boolean;
  14055. private _scene;
  14056. private _vertexBuffers;
  14057. private _indexBuffer;
  14058. private _effect;
  14059. private _alphaTestEffect;
  14060. /**
  14061. * An event triggered when the layer is disposed.
  14062. */
  14063. onDisposeObservable: Observable<Layer>;
  14064. private _onDisposeObserver;
  14065. /**
  14066. * Back compatibility with callback before the onDisposeObservable existed.
  14067. * The set callback will be triggered when the layer has been disposed.
  14068. */
  14069. onDispose: () => void;
  14070. /**
  14071. * An event triggered before rendering the scene
  14072. */
  14073. onBeforeRenderObservable: Observable<Layer>;
  14074. private _onBeforeRenderObserver;
  14075. /**
  14076. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14077. * The set callback will be triggered just before rendering the layer.
  14078. */
  14079. onBeforeRender: () => void;
  14080. /**
  14081. * An event triggered after rendering the scene
  14082. */
  14083. onAfterRenderObservable: Observable<Layer>;
  14084. private _onAfterRenderObserver;
  14085. /**
  14086. * Back compatibility with callback before the onAfterRenderObservable existed.
  14087. * The set callback will be triggered just after rendering the layer.
  14088. */
  14089. onAfterRender: () => void;
  14090. /**
  14091. * Instantiates a new layer.
  14092. * This represents a full screen 2d layer.
  14093. * This can be useful to display a picture in the background of your scene for instance.
  14094. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14095. * @param name Define the name of the layer in the scene
  14096. * @param imgUrl Define the url of the texture to display in the layer
  14097. * @param scene Define the scene the layer belongs to
  14098. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14099. * @param color Defines a color for the layer
  14100. */
  14101. constructor(
  14102. /**
  14103. * Define the name of the layer.
  14104. */
  14105. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14106. private _createIndexBuffer;
  14107. /** @hidden */
  14108. _rebuild(): void;
  14109. /**
  14110. * Renders the layer in the scene.
  14111. */
  14112. render(): void;
  14113. /**
  14114. * Disposes and releases the associated ressources.
  14115. */
  14116. dispose(): void;
  14117. }
  14118. }
  14119. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14120. import { Scene } from "babylonjs/scene";
  14121. import { ISceneComponent } from "babylonjs/sceneComponent";
  14122. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14123. module "babylonjs/abstractScene" {
  14124. interface AbstractScene {
  14125. /**
  14126. * The list of procedural textures added to the scene
  14127. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14128. */
  14129. proceduralTextures: Array<ProceduralTexture>;
  14130. }
  14131. }
  14132. /**
  14133. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14134. * in a given scene.
  14135. */
  14136. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14137. /**
  14138. * The component name helpfull to identify the component in the list of scene components.
  14139. */
  14140. readonly name: string;
  14141. /**
  14142. * The scene the component belongs to.
  14143. */
  14144. scene: Scene;
  14145. /**
  14146. * Creates a new instance of the component for the given scene
  14147. * @param scene Defines the scene to register the component in
  14148. */
  14149. constructor(scene: Scene);
  14150. /**
  14151. * Registers the component in a given scene
  14152. */
  14153. register(): void;
  14154. /**
  14155. * Rebuilds the elements related to this component in case of
  14156. * context lost for instance.
  14157. */
  14158. rebuild(): void;
  14159. /**
  14160. * Disposes the component and the associated ressources.
  14161. */
  14162. dispose(): void;
  14163. private _beforeClear;
  14164. }
  14165. }
  14166. declare module "babylonjs/Shaders/procedural.vertex" {
  14167. /** @hidden */
  14168. export var proceduralVertexShader: {
  14169. name: string;
  14170. shader: string;
  14171. };
  14172. }
  14173. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14174. import { Observable } from "babylonjs/Misc/observable";
  14175. import { Nullable } from "babylonjs/types";
  14176. import { Scene } from "babylonjs/scene";
  14177. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14178. import { Effect } from "babylonjs/Materials/effect";
  14179. import { Texture } from "babylonjs/Materials/Textures/texture";
  14180. import "babylonjs/Shaders/procedural.vertex";
  14181. /**
  14182. * 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.
  14183. * This is the base class of any Procedural texture and contains most of the shareable code.
  14184. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14185. */
  14186. export class ProceduralTexture extends Texture {
  14187. isCube: boolean;
  14188. /**
  14189. * Define if the texture is enabled or not (disabled texture will not render)
  14190. */
  14191. isEnabled: boolean;
  14192. /**
  14193. * Define if the texture must be cleared before rendering (default is true)
  14194. */
  14195. autoClear: boolean;
  14196. /**
  14197. * Callback called when the texture is generated
  14198. */
  14199. onGenerated: () => void;
  14200. /**
  14201. * Event raised when the texture is generated
  14202. */
  14203. onGeneratedObservable: Observable<ProceduralTexture>;
  14204. /** @hidden */
  14205. _generateMipMaps: boolean;
  14206. /** @hidden **/
  14207. _effect: Effect;
  14208. /** @hidden */
  14209. _textures: {
  14210. [key: string]: Texture;
  14211. };
  14212. private _size;
  14213. private _currentRefreshId;
  14214. private _refreshRate;
  14215. private _vertexBuffers;
  14216. private _indexBuffer;
  14217. private _uniforms;
  14218. private _samplers;
  14219. private _fragment;
  14220. private _floats;
  14221. private _ints;
  14222. private _floatsArrays;
  14223. private _colors3;
  14224. private _colors4;
  14225. private _vectors2;
  14226. private _vectors3;
  14227. private _matrices;
  14228. private _fallbackTexture;
  14229. private _fallbackTextureUsed;
  14230. private _engine;
  14231. private _cachedDefines;
  14232. private _contentUpdateId;
  14233. private _contentData;
  14234. /**
  14235. * Instantiates a new procedural texture.
  14236. * 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.
  14237. * This is the base class of any Procedural texture and contains most of the shareable code.
  14238. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14239. * @param name Define the name of the texture
  14240. * @param size Define the size of the texture to create
  14241. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14242. * @param scene Define the scene the texture belongs to
  14243. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14244. * @param generateMipMaps Define if the texture should creates mip maps or not
  14245. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14246. */
  14247. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14248. /**
  14249. * The effect that is created when initializing the post process.
  14250. * @returns The created effect corrisponding the the postprocess.
  14251. */
  14252. getEffect(): Effect;
  14253. /**
  14254. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14255. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14256. */
  14257. getContent(): Nullable<ArrayBufferView>;
  14258. private _createIndexBuffer;
  14259. /** @hidden */
  14260. _rebuild(): void;
  14261. /**
  14262. * Resets the texture in order to recreate its associated resources.
  14263. * This can be called in case of context loss
  14264. */
  14265. reset(): void;
  14266. protected _getDefines(): string;
  14267. /**
  14268. * Is the texture ready to be used ? (rendered at least once)
  14269. * @returns true if ready, otherwise, false.
  14270. */
  14271. isReady(): boolean;
  14272. /**
  14273. * Resets the refresh counter of the texture and start bak from scratch.
  14274. * Could be useful to regenerate the texture if it is setup to render only once.
  14275. */
  14276. resetRefreshCounter(): void;
  14277. /**
  14278. * Set the fragment shader to use in order to render the texture.
  14279. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14280. */
  14281. setFragment(fragment: any): void;
  14282. /**
  14283. * Define the refresh rate of the texture or the rendering frequency.
  14284. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14285. */
  14286. refreshRate: number;
  14287. /** @hidden */
  14288. _shouldRender(): boolean;
  14289. /**
  14290. * Get the size the texture is rendering at.
  14291. * @returns the size (texture is always squared)
  14292. */
  14293. getRenderSize(): number;
  14294. /**
  14295. * Resize the texture to new value.
  14296. * @param size Define the new size the texture should have
  14297. * @param generateMipMaps Define whether the new texture should create mip maps
  14298. */
  14299. resize(size: number, generateMipMaps: boolean): void;
  14300. private _checkUniform;
  14301. /**
  14302. * Set a texture in the shader program used to render.
  14303. * @param name Define the name of the uniform samplers as defined in the shader
  14304. * @param texture Define the texture to bind to this sampler
  14305. * @return the texture itself allowing "fluent" like uniform updates
  14306. */
  14307. setTexture(name: string, texture: Texture): ProceduralTexture;
  14308. /**
  14309. * Set a float in the shader.
  14310. * @param name Define the name of the uniform as defined in the shader
  14311. * @param value Define the value to give to the uniform
  14312. * @return the texture itself allowing "fluent" like uniform updates
  14313. */
  14314. setFloat(name: string, value: number): ProceduralTexture;
  14315. /**
  14316. * Set a int in the shader.
  14317. * @param name Define the name of the uniform as defined in the shader
  14318. * @param value Define the value to give to the uniform
  14319. * @return the texture itself allowing "fluent" like uniform updates
  14320. */
  14321. setInt(name: string, value: number): ProceduralTexture;
  14322. /**
  14323. * Set an array of floats in the shader.
  14324. * @param name Define the name of the uniform as defined in the shader
  14325. * @param value Define the value to give to the uniform
  14326. * @return the texture itself allowing "fluent" like uniform updates
  14327. */
  14328. setFloats(name: string, value: number[]): ProceduralTexture;
  14329. /**
  14330. * Set a vec3 in the shader from a Color3.
  14331. * @param name Define the name of the uniform as defined in the shader
  14332. * @param value Define the value to give to the uniform
  14333. * @return the texture itself allowing "fluent" like uniform updates
  14334. */
  14335. setColor3(name: string, value: Color3): ProceduralTexture;
  14336. /**
  14337. * Set a vec4 in the shader from a Color4.
  14338. * @param name Define the name of the uniform as defined in the shader
  14339. * @param value Define the value to give to the uniform
  14340. * @return the texture itself allowing "fluent" like uniform updates
  14341. */
  14342. setColor4(name: string, value: Color4): ProceduralTexture;
  14343. /**
  14344. * Set a vec2 in the shader from a Vector2.
  14345. * @param name Define the name of the uniform as defined in the shader
  14346. * @param value Define the value to give to the uniform
  14347. * @return the texture itself allowing "fluent" like uniform updates
  14348. */
  14349. setVector2(name: string, value: Vector2): ProceduralTexture;
  14350. /**
  14351. * Set a vec3 in the shader from a Vector3.
  14352. * @param name Define the name of the uniform as defined in the shader
  14353. * @param value Define the value to give to the uniform
  14354. * @return the texture itself allowing "fluent" like uniform updates
  14355. */
  14356. setVector3(name: string, value: Vector3): ProceduralTexture;
  14357. /**
  14358. * Set a mat4 in the shader from a MAtrix.
  14359. * @param name Define the name of the uniform as defined in the shader
  14360. * @param value Define the value to give to the uniform
  14361. * @return the texture itself allowing "fluent" like uniform updates
  14362. */
  14363. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14364. /**
  14365. * Render the texture to its associated render target.
  14366. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14367. */
  14368. render(useCameraPostProcess?: boolean): void;
  14369. /**
  14370. * Clone the texture.
  14371. * @returns the cloned texture
  14372. */
  14373. clone(): ProceduralTexture;
  14374. /**
  14375. * Dispose the texture and release its asoociated resources.
  14376. */
  14377. dispose(): void;
  14378. }
  14379. }
  14380. declare module "babylonjs/Particles/baseParticleSystem" {
  14381. import { Nullable } from "babylonjs/types";
  14382. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14384. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14385. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14386. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14387. import { Scene } from "babylonjs/scene";
  14388. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14389. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14390. import { Texture } from "babylonjs/Materials/Textures/texture";
  14391. import { Animation } from "babylonjs/Animations/animation";
  14392. /**
  14393. * This represents the base class for particle system in Babylon.
  14394. * 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.
  14395. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14396. * @example https://doc.babylonjs.com/babylon101/particles
  14397. */
  14398. export class BaseParticleSystem {
  14399. /**
  14400. * Source color is added to the destination color without alpha affecting the result
  14401. */
  14402. static BLENDMODE_ONEONE: number;
  14403. /**
  14404. * Blend current color and particle color using particle’s alpha
  14405. */
  14406. static BLENDMODE_STANDARD: number;
  14407. /**
  14408. * Add current color and particle color multiplied by particle’s alpha
  14409. */
  14410. static BLENDMODE_ADD: number;
  14411. /**
  14412. * Multiply current color with particle color
  14413. */
  14414. static BLENDMODE_MULTIPLY: number;
  14415. /**
  14416. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14417. */
  14418. static BLENDMODE_MULTIPLYADD: number;
  14419. /**
  14420. * List of animations used by the particle system.
  14421. */
  14422. animations: Animation[];
  14423. /**
  14424. * The id of the Particle system.
  14425. */
  14426. id: string;
  14427. /**
  14428. * The friendly name of the Particle system.
  14429. */
  14430. name: string;
  14431. /**
  14432. * The rendering group used by the Particle system to chose when to render.
  14433. */
  14434. renderingGroupId: number;
  14435. /**
  14436. * The emitter represents the Mesh or position we are attaching the particle system to.
  14437. */
  14438. emitter: Nullable<AbstractMesh | Vector3>;
  14439. /**
  14440. * The maximum number of particles to emit per frame
  14441. */
  14442. emitRate: number;
  14443. /**
  14444. * If you want to launch only a few particles at once, that can be done, as well.
  14445. */
  14446. manualEmitCount: number;
  14447. /**
  14448. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14449. */
  14450. updateSpeed: number;
  14451. /**
  14452. * The amount of time the particle system is running (depends of the overall update speed).
  14453. */
  14454. targetStopDuration: number;
  14455. /**
  14456. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14457. */
  14458. disposeOnStop: boolean;
  14459. /**
  14460. * Minimum power of emitting particles.
  14461. */
  14462. minEmitPower: number;
  14463. /**
  14464. * Maximum power of emitting particles.
  14465. */
  14466. maxEmitPower: number;
  14467. /**
  14468. * Minimum life time of emitting particles.
  14469. */
  14470. minLifeTime: number;
  14471. /**
  14472. * Maximum life time of emitting particles.
  14473. */
  14474. maxLifeTime: number;
  14475. /**
  14476. * Minimum Size of emitting particles.
  14477. */
  14478. minSize: number;
  14479. /**
  14480. * Maximum Size of emitting particles.
  14481. */
  14482. maxSize: number;
  14483. /**
  14484. * Minimum scale of emitting particles on X axis.
  14485. */
  14486. minScaleX: number;
  14487. /**
  14488. * Maximum scale of emitting particles on X axis.
  14489. */
  14490. maxScaleX: number;
  14491. /**
  14492. * Minimum scale of emitting particles on Y axis.
  14493. */
  14494. minScaleY: number;
  14495. /**
  14496. * Maximum scale of emitting particles on Y axis.
  14497. */
  14498. maxScaleY: number;
  14499. /**
  14500. * Gets or sets the minimal initial rotation in radians.
  14501. */
  14502. minInitialRotation: number;
  14503. /**
  14504. * Gets or sets the maximal initial rotation in radians.
  14505. */
  14506. maxInitialRotation: number;
  14507. /**
  14508. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14509. */
  14510. minAngularSpeed: number;
  14511. /**
  14512. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14513. */
  14514. maxAngularSpeed: number;
  14515. /**
  14516. * The texture used to render each particle. (this can be a spritesheet)
  14517. */
  14518. particleTexture: Nullable<Texture>;
  14519. /**
  14520. * The layer mask we are rendering the particles through.
  14521. */
  14522. layerMask: number;
  14523. /**
  14524. * This can help using your own shader to render the particle system.
  14525. * The according effect will be created
  14526. */
  14527. customShader: any;
  14528. /**
  14529. * By default particle system starts as soon as they are created. This prevents the
  14530. * automatic start to happen and let you decide when to start emitting particles.
  14531. */
  14532. preventAutoStart: boolean;
  14533. private _noiseTexture;
  14534. /**
  14535. * Gets or sets a texture used to add random noise to particle positions
  14536. */
  14537. noiseTexture: Nullable<ProceduralTexture>;
  14538. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14539. noiseStrength: Vector3;
  14540. /**
  14541. * Callback triggered when the particle animation is ending.
  14542. */
  14543. onAnimationEnd: Nullable<() => void>;
  14544. /**
  14545. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14546. */
  14547. blendMode: number;
  14548. /**
  14549. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14550. * to override the particles.
  14551. */
  14552. forceDepthWrite: boolean;
  14553. /** 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 */
  14554. preWarmCycles: number;
  14555. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14556. preWarmStepOffset: number;
  14557. /**
  14558. * 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)
  14559. */
  14560. spriteCellChangeSpeed: number;
  14561. /**
  14562. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14563. */
  14564. startSpriteCellID: number;
  14565. /**
  14566. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14567. */
  14568. endSpriteCellID: number;
  14569. /**
  14570. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14571. */
  14572. spriteCellWidth: number;
  14573. /**
  14574. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14575. */
  14576. spriteCellHeight: number;
  14577. /**
  14578. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14579. */
  14580. spriteRandomStartCell: boolean;
  14581. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14582. translationPivot: Vector2;
  14583. /** @hidden */
  14584. protected _isAnimationSheetEnabled: boolean;
  14585. /**
  14586. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14587. */
  14588. beginAnimationOnStart: boolean;
  14589. /**
  14590. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14591. */
  14592. beginAnimationFrom: number;
  14593. /**
  14594. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14595. */
  14596. beginAnimationTo: number;
  14597. /**
  14598. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14599. */
  14600. beginAnimationLoop: boolean;
  14601. /**
  14602. * Gets or sets a world offset applied to all particles
  14603. */
  14604. worldOffset: Vector3;
  14605. /**
  14606. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14607. */
  14608. isAnimationSheetEnabled: boolean;
  14609. /**
  14610. * Get hosting scene
  14611. * @returns the scene
  14612. */
  14613. getScene(): Scene;
  14614. /**
  14615. * You can use gravity if you want to give an orientation to your particles.
  14616. */
  14617. gravity: Vector3;
  14618. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14619. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14620. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14621. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14622. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14623. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14624. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14625. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14626. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14627. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14628. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14629. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14630. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14631. /**
  14632. * Defines the delay in milliseconds before starting the system (0 by default)
  14633. */
  14634. startDelay: number;
  14635. /**
  14636. * Gets the current list of drag gradients.
  14637. * You must use addDragGradient and removeDragGradient to udpate this list
  14638. * @returns the list of drag gradients
  14639. */
  14640. getDragGradients(): Nullable<Array<FactorGradient>>;
  14641. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14642. limitVelocityDamping: number;
  14643. /**
  14644. * Gets the current list of limit velocity gradients.
  14645. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14646. * @returns the list of limit velocity gradients
  14647. */
  14648. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14649. /**
  14650. * Gets the current list of color gradients.
  14651. * You must use addColorGradient and removeColorGradient to udpate this list
  14652. * @returns the list of color gradients
  14653. */
  14654. getColorGradients(): Nullable<Array<ColorGradient>>;
  14655. /**
  14656. * Gets the current list of size gradients.
  14657. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14658. * @returns the list of size gradients
  14659. */
  14660. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14661. /**
  14662. * Gets the current list of color remap gradients.
  14663. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14664. * @returns the list of color remap gradients
  14665. */
  14666. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14667. /**
  14668. * Gets the current list of alpha remap gradients.
  14669. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14670. * @returns the list of alpha remap gradients
  14671. */
  14672. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14673. /**
  14674. * Gets the current list of life time gradients.
  14675. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14676. * @returns the list of life time gradients
  14677. */
  14678. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14679. /**
  14680. * Gets the current list of angular speed gradients.
  14681. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14682. * @returns the list of angular speed gradients
  14683. */
  14684. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14685. /**
  14686. * Gets the current list of velocity gradients.
  14687. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14688. * @returns the list of velocity gradients
  14689. */
  14690. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14691. /**
  14692. * Gets the current list of start size gradients.
  14693. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14694. * @returns the list of start size gradients
  14695. */
  14696. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14697. /**
  14698. * Gets the current list of emit rate gradients.
  14699. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14700. * @returns the list of emit rate gradients
  14701. */
  14702. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14703. /**
  14704. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14705. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14706. */
  14707. direction1: Vector3;
  14708. /**
  14709. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14710. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14711. */
  14712. direction2: Vector3;
  14713. /**
  14714. * 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.
  14715. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14716. */
  14717. minEmitBox: Vector3;
  14718. /**
  14719. * 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.
  14720. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14721. */
  14722. maxEmitBox: Vector3;
  14723. /**
  14724. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14725. */
  14726. color1: Color4;
  14727. /**
  14728. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14729. */
  14730. color2: Color4;
  14731. /**
  14732. * Color the particle will have at the end of its lifetime
  14733. */
  14734. colorDead: Color4;
  14735. /**
  14736. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14737. */
  14738. textureMask: Color4;
  14739. /**
  14740. * The particle emitter type defines the emitter used by the particle system.
  14741. * It can be for example box, sphere, or cone...
  14742. */
  14743. particleEmitterType: IParticleEmitterType;
  14744. /** @hidden */
  14745. _isSubEmitter: boolean;
  14746. /**
  14747. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14748. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14749. */
  14750. billboardMode: number;
  14751. protected _isBillboardBased: boolean;
  14752. /**
  14753. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14754. */
  14755. isBillboardBased: boolean;
  14756. /**
  14757. * The scene the particle system belongs to.
  14758. */
  14759. protected _scene: Scene;
  14760. /**
  14761. * Local cache of defines for image processing.
  14762. */
  14763. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14764. /**
  14765. * Default configuration related to image processing available in the standard Material.
  14766. */
  14767. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14768. /**
  14769. * Gets the image processing configuration used either in this material.
  14770. */
  14771. /**
  14772. * Sets the Default image processing configuration used either in the this material.
  14773. *
  14774. * If sets to null, the scene one is in use.
  14775. */
  14776. imageProcessingConfiguration: ImageProcessingConfiguration;
  14777. /**
  14778. * Attaches a new image processing configuration to the Standard Material.
  14779. * @param configuration
  14780. */
  14781. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14782. /** @hidden */
  14783. protected _reset(): void;
  14784. /** @hidden */
  14785. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14786. /**
  14787. * Instantiates a particle system.
  14788. * 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.
  14789. * @param name The name of the particle system
  14790. */
  14791. constructor(name: string);
  14792. /**
  14793. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14794. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14795. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14796. * @returns the emitter
  14797. */
  14798. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14799. /**
  14800. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14801. * @param radius The radius of the hemisphere to emit from
  14802. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14803. * @returns the emitter
  14804. */
  14805. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14806. /**
  14807. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14808. * @param radius The radius of the sphere to emit from
  14809. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14810. * @returns the emitter
  14811. */
  14812. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14813. /**
  14814. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14815. * @param radius The radius of the sphere to emit from
  14816. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14817. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14818. * @returns the emitter
  14819. */
  14820. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14821. /**
  14822. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14823. * @param radius The radius of the emission cylinder
  14824. * @param height The height of the emission cylinder
  14825. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14826. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14827. * @returns the emitter
  14828. */
  14829. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14830. /**
  14831. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14832. * @param radius The radius of the cylinder to emit from
  14833. * @param height The height of the emission cylinder
  14834. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14835. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14836. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14837. * @returns the emitter
  14838. */
  14839. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14840. /**
  14841. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14842. * @param radius The radius of the cone to emit from
  14843. * @param angle The base angle of the cone
  14844. * @returns the emitter
  14845. */
  14846. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14847. /**
  14848. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14849. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14850. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14851. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14852. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14853. * @returns the emitter
  14854. */
  14855. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14856. }
  14857. }
  14858. declare module "babylonjs/Particles/subEmitter" {
  14859. import { Scene } from "babylonjs/scene";
  14860. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14861. /**
  14862. * Type of sub emitter
  14863. */
  14864. export enum SubEmitterType {
  14865. /**
  14866. * Attached to the particle over it's lifetime
  14867. */
  14868. ATTACHED = 0,
  14869. /**
  14870. * Created when the particle dies
  14871. */
  14872. END = 1
  14873. }
  14874. /**
  14875. * Sub emitter class used to emit particles from an existing particle
  14876. */
  14877. export class SubEmitter {
  14878. /**
  14879. * the particle system to be used by the sub emitter
  14880. */
  14881. particleSystem: ParticleSystem;
  14882. /**
  14883. * Type of the submitter (Default: END)
  14884. */
  14885. type: SubEmitterType;
  14886. /**
  14887. * 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)
  14888. * Note: This only is supported when using an emitter of type Mesh
  14889. */
  14890. inheritDirection: boolean;
  14891. /**
  14892. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14893. */
  14894. inheritedVelocityAmount: number;
  14895. /**
  14896. * Creates a sub emitter
  14897. * @param particleSystem the particle system to be used by the sub emitter
  14898. */
  14899. constructor(
  14900. /**
  14901. * the particle system to be used by the sub emitter
  14902. */
  14903. particleSystem: ParticleSystem);
  14904. /**
  14905. * Clones the sub emitter
  14906. * @returns the cloned sub emitter
  14907. */
  14908. clone(): SubEmitter;
  14909. /**
  14910. * Serialize current object to a JSON object
  14911. * @returns the serialized object
  14912. */
  14913. serialize(): any;
  14914. /** @hidden */
  14915. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14916. /**
  14917. * Creates a new SubEmitter from a serialized JSON version
  14918. * @param serializationObject defines the JSON object to read from
  14919. * @param scene defines the hosting scene
  14920. * @param rootUrl defines the rootUrl for data loading
  14921. * @returns a new SubEmitter
  14922. */
  14923. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14924. /** Release associated resources */
  14925. dispose(): void;
  14926. }
  14927. }
  14928. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14929. /** @hidden */
  14930. export var clipPlaneFragmentDeclaration: {
  14931. name: string;
  14932. shader: string;
  14933. };
  14934. }
  14935. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14936. /** @hidden */
  14937. export var imageProcessingDeclaration: {
  14938. name: string;
  14939. shader: string;
  14940. };
  14941. }
  14942. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14943. /** @hidden */
  14944. export var imageProcessingFunctions: {
  14945. name: string;
  14946. shader: string;
  14947. };
  14948. }
  14949. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14950. /** @hidden */
  14951. export var clipPlaneFragment: {
  14952. name: string;
  14953. shader: string;
  14954. };
  14955. }
  14956. declare module "babylonjs/Shaders/particles.fragment" {
  14957. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14958. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14959. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14960. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14961. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14962. /** @hidden */
  14963. export var particlesPixelShader: {
  14964. name: string;
  14965. shader: string;
  14966. };
  14967. }
  14968. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14969. /** @hidden */
  14970. export var clipPlaneVertexDeclaration: {
  14971. name: string;
  14972. shader: string;
  14973. };
  14974. }
  14975. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14976. /** @hidden */
  14977. export var clipPlaneVertex: {
  14978. name: string;
  14979. shader: string;
  14980. };
  14981. }
  14982. declare module "babylonjs/Shaders/particles.vertex" {
  14983. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14984. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14985. /** @hidden */
  14986. export var particlesVertexShader: {
  14987. name: string;
  14988. shader: string;
  14989. };
  14990. }
  14991. declare module "babylonjs/Particles/particleSystem" {
  14992. import { Nullable } from "babylonjs/types";
  14993. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14994. import { Observable } from "babylonjs/Misc/observable";
  14995. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14996. import { Effect } from "babylonjs/Materials/effect";
  14997. import { Scene, IDisposable } from "babylonjs/scene";
  14998. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14999. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15000. import { Particle } from "babylonjs/Particles/particle";
  15001. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15002. import "babylonjs/Shaders/particles.fragment";
  15003. import "babylonjs/Shaders/particles.vertex";
  15004. /**
  15005. * This represents a particle system in Babylon.
  15006. * 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.
  15007. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15008. * @example https://doc.babylonjs.com/babylon101/particles
  15009. */
  15010. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15011. /**
  15012. * Billboard mode will only apply to Y axis
  15013. */
  15014. static readonly BILLBOARDMODE_Y: number;
  15015. /**
  15016. * Billboard mode will apply to all axes
  15017. */
  15018. static readonly BILLBOARDMODE_ALL: number;
  15019. /**
  15020. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15021. */
  15022. static readonly BILLBOARDMODE_STRETCHED: number;
  15023. /**
  15024. * This function can be defined to provide custom update for active particles.
  15025. * This function will be called instead of regular update (age, position, color, etc.).
  15026. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15027. */
  15028. updateFunction: (particles: Particle[]) => void;
  15029. private _emitterWorldMatrix;
  15030. /**
  15031. * This function can be defined to specify initial direction for every new particle.
  15032. * It by default use the emitterType defined function
  15033. */
  15034. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15035. /**
  15036. * This function can be defined to specify initial position for every new particle.
  15037. * It by default use the emitterType defined function
  15038. */
  15039. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15040. /**
  15041. * @hidden
  15042. */
  15043. _inheritedVelocityOffset: Vector3;
  15044. /**
  15045. * An event triggered when the system is disposed
  15046. */
  15047. onDisposeObservable: Observable<ParticleSystem>;
  15048. private _onDisposeObserver;
  15049. /**
  15050. * Sets a callback that will be triggered when the system is disposed
  15051. */
  15052. onDispose: () => void;
  15053. private _particles;
  15054. private _epsilon;
  15055. private _capacity;
  15056. private _stockParticles;
  15057. private _newPartsExcess;
  15058. private _vertexData;
  15059. private _vertexBuffer;
  15060. private _vertexBuffers;
  15061. private _spriteBuffer;
  15062. private _indexBuffer;
  15063. private _effect;
  15064. private _customEffect;
  15065. private _cachedDefines;
  15066. private _scaledColorStep;
  15067. private _colorDiff;
  15068. private _scaledDirection;
  15069. private _scaledGravity;
  15070. private _currentRenderId;
  15071. private _alive;
  15072. private _useInstancing;
  15073. private _started;
  15074. private _stopped;
  15075. private _actualFrame;
  15076. private _scaledUpdateSpeed;
  15077. private _vertexBufferSize;
  15078. /** @hidden */
  15079. _currentEmitRateGradient: Nullable<FactorGradient>;
  15080. /** @hidden */
  15081. _currentEmitRate1: number;
  15082. /** @hidden */
  15083. _currentEmitRate2: number;
  15084. /** @hidden */
  15085. _currentStartSizeGradient: Nullable<FactorGradient>;
  15086. /** @hidden */
  15087. _currentStartSize1: number;
  15088. /** @hidden */
  15089. _currentStartSize2: number;
  15090. private readonly _rawTextureWidth;
  15091. private _rampGradientsTexture;
  15092. private _useRampGradients;
  15093. /** Gets or sets a boolean indicating that ramp gradients must be used
  15094. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15095. */
  15096. useRampGradients: boolean;
  15097. /**
  15098. * 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.
  15099. * 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: [])
  15100. */
  15101. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15102. private _subEmitters;
  15103. /**
  15104. * @hidden
  15105. * If the particle systems emitter should be disposed when the particle system is disposed
  15106. */
  15107. _disposeEmitterOnDispose: boolean;
  15108. /**
  15109. * The current active Sub-systems, this property is used by the root particle system only.
  15110. */
  15111. activeSubSystems: Array<ParticleSystem>;
  15112. private _rootParticleSystem;
  15113. /**
  15114. * Gets the current list of active particles
  15115. */
  15116. readonly particles: Particle[];
  15117. /**
  15118. * Returns the string "ParticleSystem"
  15119. * @returns a string containing the class name
  15120. */
  15121. getClassName(): string;
  15122. /**
  15123. * Instantiates a particle system.
  15124. * 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.
  15125. * @param name The name of the particle system
  15126. * @param capacity The max number of particles alive at the same time
  15127. * @param scene The scene the particle system belongs to
  15128. * @param customEffect a custom effect used to change the way particles are rendered by default
  15129. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15130. * @param epsilon Offset used to render the particles
  15131. */
  15132. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15133. private _addFactorGradient;
  15134. private _removeFactorGradient;
  15135. /**
  15136. * Adds a new life time gradient
  15137. * @param gradient defines the gradient to use (between 0 and 1)
  15138. * @param factor defines the life time factor to affect to the specified gradient
  15139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15140. * @returns the current particle system
  15141. */
  15142. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15143. /**
  15144. * Remove a specific life time gradient
  15145. * @param gradient defines the gradient to remove
  15146. * @returns the current particle system
  15147. */
  15148. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15149. /**
  15150. * Adds a new size gradient
  15151. * @param gradient defines the gradient to use (between 0 and 1)
  15152. * @param factor defines the size factor to affect to the specified gradient
  15153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15154. * @returns the current particle system
  15155. */
  15156. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15157. /**
  15158. * Remove a specific size gradient
  15159. * @param gradient defines the gradient to remove
  15160. * @returns the current particle system
  15161. */
  15162. removeSizeGradient(gradient: number): IParticleSystem;
  15163. /**
  15164. * Adds a new color remap gradient
  15165. * @param gradient defines the gradient to use (between 0 and 1)
  15166. * @param min defines the color remap minimal range
  15167. * @param max defines the color remap maximal range
  15168. * @returns the current particle system
  15169. */
  15170. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15171. /**
  15172. * Remove a specific color remap gradient
  15173. * @param gradient defines the gradient to remove
  15174. * @returns the current particle system
  15175. */
  15176. removeColorRemapGradient(gradient: number): IParticleSystem;
  15177. /**
  15178. * Adds a new alpha remap gradient
  15179. * @param gradient defines the gradient to use (between 0 and 1)
  15180. * @param min defines the alpha remap minimal range
  15181. * @param max defines the alpha remap maximal range
  15182. * @returns the current particle system
  15183. */
  15184. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15185. /**
  15186. * Remove a specific alpha remap gradient
  15187. * @param gradient defines the gradient to remove
  15188. * @returns the current particle system
  15189. */
  15190. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15191. /**
  15192. * Adds a new angular speed gradient
  15193. * @param gradient defines the gradient to use (between 0 and 1)
  15194. * @param factor defines the angular speed to affect to the specified gradient
  15195. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15196. * @returns the current particle system
  15197. */
  15198. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15199. /**
  15200. * Remove a specific angular speed gradient
  15201. * @param gradient defines the gradient to remove
  15202. * @returns the current particle system
  15203. */
  15204. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15205. /**
  15206. * Adds a new velocity gradient
  15207. * @param gradient defines the gradient to use (between 0 and 1)
  15208. * @param factor defines the velocity to affect to the specified gradient
  15209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15210. * @returns the current particle system
  15211. */
  15212. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15213. /**
  15214. * Remove a specific velocity gradient
  15215. * @param gradient defines the gradient to remove
  15216. * @returns the current particle system
  15217. */
  15218. removeVelocityGradient(gradient: number): IParticleSystem;
  15219. /**
  15220. * Adds a new limit velocity gradient
  15221. * @param gradient defines the gradient to use (between 0 and 1)
  15222. * @param factor defines the limit velocity value to affect to the specified gradient
  15223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15224. * @returns the current particle system
  15225. */
  15226. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15227. /**
  15228. * Remove a specific limit velocity gradient
  15229. * @param gradient defines the gradient to remove
  15230. * @returns the current particle system
  15231. */
  15232. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15233. /**
  15234. * Adds a new drag gradient
  15235. * @param gradient defines the gradient to use (between 0 and 1)
  15236. * @param factor defines the drag value to affect to the specified gradient
  15237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15238. * @returns the current particle system
  15239. */
  15240. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15241. /**
  15242. * Remove a specific drag gradient
  15243. * @param gradient defines the gradient to remove
  15244. * @returns the current particle system
  15245. */
  15246. removeDragGradient(gradient: number): IParticleSystem;
  15247. /**
  15248. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15249. * @param gradient defines the gradient to use (between 0 and 1)
  15250. * @param factor defines the emit rate value to affect to the specified gradient
  15251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15252. * @returns the current particle system
  15253. */
  15254. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15255. /**
  15256. * Remove a specific emit rate gradient
  15257. * @param gradient defines the gradient to remove
  15258. * @returns the current particle system
  15259. */
  15260. removeEmitRateGradient(gradient: number): IParticleSystem;
  15261. /**
  15262. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15263. * @param gradient defines the gradient to use (between 0 and 1)
  15264. * @param factor defines the start size value to affect to the specified gradient
  15265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15266. * @returns the current particle system
  15267. */
  15268. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15269. /**
  15270. * Remove a specific start size gradient
  15271. * @param gradient defines the gradient to remove
  15272. * @returns the current particle system
  15273. */
  15274. removeStartSizeGradient(gradient: number): IParticleSystem;
  15275. private _createRampGradientTexture;
  15276. /**
  15277. * Gets the current list of ramp gradients.
  15278. * You must use addRampGradient and removeRampGradient to udpate this list
  15279. * @returns the list of ramp gradients
  15280. */
  15281. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15282. /**
  15283. * Adds a new ramp gradient used to remap particle colors
  15284. * @param gradient defines the gradient to use (between 0 and 1)
  15285. * @param color defines the color to affect to the specified gradient
  15286. * @returns the current particle system
  15287. */
  15288. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15289. /**
  15290. * Remove a specific ramp gradient
  15291. * @param gradient defines the gradient to remove
  15292. * @returns the current particle system
  15293. */
  15294. removeRampGradient(gradient: number): ParticleSystem;
  15295. /**
  15296. * Adds a new color gradient
  15297. * @param gradient defines the gradient to use (between 0 and 1)
  15298. * @param color1 defines the color to affect to the specified gradient
  15299. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15300. * @returns this particle system
  15301. */
  15302. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15303. /**
  15304. * Remove a specific color gradient
  15305. * @param gradient defines the gradient to remove
  15306. * @returns this particle system
  15307. */
  15308. removeColorGradient(gradient: number): IParticleSystem;
  15309. private _fetchR;
  15310. protected _reset(): void;
  15311. private _resetEffect;
  15312. private _createVertexBuffers;
  15313. private _createIndexBuffer;
  15314. /**
  15315. * Gets the maximum number of particles active at the same time.
  15316. * @returns The max number of active particles.
  15317. */
  15318. getCapacity(): number;
  15319. /**
  15320. * Gets whether there are still active particles in the system.
  15321. * @returns True if it is alive, otherwise false.
  15322. */
  15323. isAlive(): boolean;
  15324. /**
  15325. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15326. * @returns True if it has been started, otherwise false.
  15327. */
  15328. isStarted(): boolean;
  15329. private _prepareSubEmitterInternalArray;
  15330. /**
  15331. * Starts the particle system and begins to emit
  15332. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15333. */
  15334. start(delay?: number): void;
  15335. /**
  15336. * Stops the particle system.
  15337. * @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.
  15338. */
  15339. stop(stopSubEmitters?: boolean): void;
  15340. /**
  15341. * Remove all active particles
  15342. */
  15343. reset(): void;
  15344. /**
  15345. * @hidden (for internal use only)
  15346. */
  15347. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15348. /**
  15349. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15350. * Its lifetime will start back at 0.
  15351. */
  15352. recycleParticle: (particle: Particle) => void;
  15353. private _stopSubEmitters;
  15354. private _createParticle;
  15355. private _removeFromRoot;
  15356. private _emitFromParticle;
  15357. private _update;
  15358. /** @hidden */
  15359. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15360. /** @hidden */
  15361. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15362. /** @hidden */
  15363. private _getEffect;
  15364. /**
  15365. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15366. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15367. */
  15368. animate(preWarmOnly?: boolean): void;
  15369. private _appendParticleVertices;
  15370. /**
  15371. * Rebuilds the particle system.
  15372. */
  15373. rebuild(): void;
  15374. /**
  15375. * Is this system ready to be used/rendered
  15376. * @return true if the system is ready
  15377. */
  15378. isReady(): boolean;
  15379. private _render;
  15380. /**
  15381. * Renders the particle system in its current state.
  15382. * @returns the current number of particles
  15383. */
  15384. render(): number;
  15385. /**
  15386. * Disposes the particle system and free the associated resources
  15387. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15388. */
  15389. dispose(disposeTexture?: boolean): void;
  15390. /**
  15391. * Clones the particle system.
  15392. * @param name The name of the cloned object
  15393. * @param newEmitter The new emitter to use
  15394. * @returns the cloned particle system
  15395. */
  15396. clone(name: string, newEmitter: any): ParticleSystem;
  15397. /**
  15398. * Serializes the particle system to a JSON object.
  15399. * @returns the JSON object
  15400. */
  15401. serialize(): any;
  15402. /** @hidden */
  15403. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15404. /** @hidden */
  15405. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15406. /**
  15407. * Parses a JSON object to create a particle system.
  15408. * @param parsedParticleSystem The JSON object to parse
  15409. * @param scene The scene to create the particle system in
  15410. * @param rootUrl The root url to use to load external dependencies like texture
  15411. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15412. * @returns the Parsed particle system
  15413. */
  15414. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15415. }
  15416. }
  15417. declare module "babylonjs/Particles/particle" {
  15418. import { Nullable } from "babylonjs/types";
  15419. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15420. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15421. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15422. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15423. /**
  15424. * A particle represents one of the element emitted by a particle system.
  15425. * This is mainly define by its coordinates, direction, velocity and age.
  15426. */
  15427. export class Particle {
  15428. /**
  15429. * The particle system the particle belongs to.
  15430. */
  15431. particleSystem: ParticleSystem;
  15432. private static _Count;
  15433. /**
  15434. * Unique ID of the particle
  15435. */
  15436. id: number;
  15437. /**
  15438. * The world position of the particle in the scene.
  15439. */
  15440. position: Vector3;
  15441. /**
  15442. * The world direction of the particle in the scene.
  15443. */
  15444. direction: Vector3;
  15445. /**
  15446. * The color of the particle.
  15447. */
  15448. color: Color4;
  15449. /**
  15450. * The color change of the particle per step.
  15451. */
  15452. colorStep: Color4;
  15453. /**
  15454. * Defines how long will the life of the particle be.
  15455. */
  15456. lifeTime: number;
  15457. /**
  15458. * The current age of the particle.
  15459. */
  15460. age: number;
  15461. /**
  15462. * The current size of the particle.
  15463. */
  15464. size: number;
  15465. /**
  15466. * The current scale of the particle.
  15467. */
  15468. scale: Vector2;
  15469. /**
  15470. * The current angle of the particle.
  15471. */
  15472. angle: number;
  15473. /**
  15474. * Defines how fast is the angle changing.
  15475. */
  15476. angularSpeed: number;
  15477. /**
  15478. * Defines the cell index used by the particle to be rendered from a sprite.
  15479. */
  15480. cellIndex: number;
  15481. /**
  15482. * The information required to support color remapping
  15483. */
  15484. remapData: Vector4;
  15485. /** @hidden */
  15486. _randomCellOffset?: number;
  15487. /** @hidden */
  15488. _initialDirection: Nullable<Vector3>;
  15489. /** @hidden */
  15490. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15491. /** @hidden */
  15492. _initialStartSpriteCellID: number;
  15493. /** @hidden */
  15494. _initialEndSpriteCellID: number;
  15495. /** @hidden */
  15496. _currentColorGradient: Nullable<ColorGradient>;
  15497. /** @hidden */
  15498. _currentColor1: Color4;
  15499. /** @hidden */
  15500. _currentColor2: Color4;
  15501. /** @hidden */
  15502. _currentSizeGradient: Nullable<FactorGradient>;
  15503. /** @hidden */
  15504. _currentSize1: number;
  15505. /** @hidden */
  15506. _currentSize2: number;
  15507. /** @hidden */
  15508. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15509. /** @hidden */
  15510. _currentAngularSpeed1: number;
  15511. /** @hidden */
  15512. _currentAngularSpeed2: number;
  15513. /** @hidden */
  15514. _currentVelocityGradient: Nullable<FactorGradient>;
  15515. /** @hidden */
  15516. _currentVelocity1: number;
  15517. /** @hidden */
  15518. _currentVelocity2: number;
  15519. /** @hidden */
  15520. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15521. /** @hidden */
  15522. _currentLimitVelocity1: number;
  15523. /** @hidden */
  15524. _currentLimitVelocity2: number;
  15525. /** @hidden */
  15526. _currentDragGradient: Nullable<FactorGradient>;
  15527. /** @hidden */
  15528. _currentDrag1: number;
  15529. /** @hidden */
  15530. _currentDrag2: number;
  15531. /** @hidden */
  15532. _randomNoiseCoordinates1: Vector3;
  15533. /** @hidden */
  15534. _randomNoiseCoordinates2: Vector3;
  15535. /**
  15536. * Creates a new instance Particle
  15537. * @param particleSystem the particle system the particle belongs to
  15538. */
  15539. constructor(
  15540. /**
  15541. * The particle system the particle belongs to.
  15542. */
  15543. particleSystem: ParticleSystem);
  15544. private updateCellInfoFromSystem;
  15545. /**
  15546. * Defines how the sprite cell index is updated for the particle
  15547. */
  15548. updateCellIndex(): void;
  15549. /** @hidden */
  15550. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15551. /** @hidden */
  15552. _inheritParticleInfoToSubEmitters(): void;
  15553. /** @hidden */
  15554. _reset(): void;
  15555. /**
  15556. * Copy the properties of particle to another one.
  15557. * @param other the particle to copy the information to.
  15558. */
  15559. copyTo(other: Particle): void;
  15560. }
  15561. }
  15562. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15563. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15564. import { Effect } from "babylonjs/Materials/effect";
  15565. import { Particle } from "babylonjs/Particles/particle";
  15566. /**
  15567. * Particle emitter represents a volume emitting particles.
  15568. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15569. */
  15570. export interface IParticleEmitterType {
  15571. /**
  15572. * Called by the particle System when the direction is computed for the created particle.
  15573. * @param worldMatrix is the world matrix of the particle system
  15574. * @param directionToUpdate is the direction vector to update with the result
  15575. * @param particle is the particle we are computed the direction for
  15576. */
  15577. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15578. /**
  15579. * Called by the particle System when the position is computed for the created particle.
  15580. * @param worldMatrix is the world matrix of the particle system
  15581. * @param positionToUpdate is the position vector to update with the result
  15582. * @param particle is the particle we are computed the position for
  15583. */
  15584. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15585. /**
  15586. * Clones the current emitter and returns a copy of it
  15587. * @returns the new emitter
  15588. */
  15589. clone(): IParticleEmitterType;
  15590. /**
  15591. * Called by the GPUParticleSystem to setup the update shader
  15592. * @param effect defines the update shader
  15593. */
  15594. applyToShader(effect: Effect): void;
  15595. /**
  15596. * Returns a string to use to update the GPU particles update shader
  15597. * @returns the effect defines string
  15598. */
  15599. getEffectDefines(): string;
  15600. /**
  15601. * Returns a string representing the class name
  15602. * @returns a string containing the class name
  15603. */
  15604. getClassName(): string;
  15605. /**
  15606. * Serializes the particle system to a JSON object.
  15607. * @returns the JSON object
  15608. */
  15609. serialize(): any;
  15610. /**
  15611. * Parse properties from a JSON object
  15612. * @param serializationObject defines the JSON object
  15613. */
  15614. parse(serializationObject: any): void;
  15615. }
  15616. }
  15617. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15618. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15619. import { Effect } from "babylonjs/Materials/effect";
  15620. import { Particle } from "babylonjs/Particles/particle";
  15621. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15622. /**
  15623. * Particle emitter emitting particles from the inside of a box.
  15624. * It emits the particles randomly between 2 given directions.
  15625. */
  15626. export class BoxParticleEmitter implements IParticleEmitterType {
  15627. /**
  15628. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15629. */
  15630. direction1: Vector3;
  15631. /**
  15632. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15633. */
  15634. direction2: Vector3;
  15635. /**
  15636. * 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.
  15637. */
  15638. minEmitBox: Vector3;
  15639. /**
  15640. * 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.
  15641. */
  15642. maxEmitBox: Vector3;
  15643. /**
  15644. * Creates a new instance BoxParticleEmitter
  15645. */
  15646. constructor();
  15647. /**
  15648. * Called by the particle System when the direction is computed for the created particle.
  15649. * @param worldMatrix is the world matrix of the particle system
  15650. * @param directionToUpdate is the direction vector to update with the result
  15651. * @param particle is the particle we are computed the direction for
  15652. */
  15653. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15654. /**
  15655. * Called by the particle System when the position is computed for the created particle.
  15656. * @param worldMatrix is the world matrix of the particle system
  15657. * @param positionToUpdate is the position vector to update with the result
  15658. * @param particle is the particle we are computed the position for
  15659. */
  15660. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15661. /**
  15662. * Clones the current emitter and returns a copy of it
  15663. * @returns the new emitter
  15664. */
  15665. clone(): BoxParticleEmitter;
  15666. /**
  15667. * Called by the GPUParticleSystem to setup the update shader
  15668. * @param effect defines the update shader
  15669. */
  15670. applyToShader(effect: Effect): void;
  15671. /**
  15672. * Returns a string to use to update the GPU particles update shader
  15673. * @returns a string containng the defines string
  15674. */
  15675. getEffectDefines(): string;
  15676. /**
  15677. * Returns the string "BoxParticleEmitter"
  15678. * @returns a string containing the class name
  15679. */
  15680. getClassName(): string;
  15681. /**
  15682. * Serializes the particle system to a JSON object.
  15683. * @returns the JSON object
  15684. */
  15685. serialize(): any;
  15686. /**
  15687. * Parse properties from a JSON object
  15688. * @param serializationObject defines the JSON object
  15689. */
  15690. parse(serializationObject: any): void;
  15691. }
  15692. }
  15693. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15694. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15695. import { Effect } from "babylonjs/Materials/effect";
  15696. import { Particle } from "babylonjs/Particles/particle";
  15697. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15698. /**
  15699. * Particle emitter emitting particles from the inside of a cone.
  15700. * It emits the particles alongside the cone volume from the base to the particle.
  15701. * The emission direction might be randomized.
  15702. */
  15703. export class ConeParticleEmitter implements IParticleEmitterType {
  15704. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15705. directionRandomizer: number;
  15706. private _radius;
  15707. private _angle;
  15708. private _height;
  15709. /**
  15710. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15711. */
  15712. radiusRange: number;
  15713. /**
  15714. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15715. */
  15716. heightRange: number;
  15717. /**
  15718. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15719. */
  15720. emitFromSpawnPointOnly: boolean;
  15721. /**
  15722. * Gets or sets the radius of the emission cone
  15723. */
  15724. radius: number;
  15725. /**
  15726. * Gets or sets the angle of the emission cone
  15727. */
  15728. angle: number;
  15729. private _buildHeight;
  15730. /**
  15731. * Creates a new instance ConeParticleEmitter
  15732. * @param radius the radius of the emission cone (1 by default)
  15733. * @param angle the cone base angle (PI by default)
  15734. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15735. */
  15736. constructor(radius?: number, angle?: number,
  15737. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15738. directionRandomizer?: number);
  15739. /**
  15740. * Called by the particle System when the direction is computed for the created particle.
  15741. * @param worldMatrix is the world matrix of the particle system
  15742. * @param directionToUpdate is the direction vector to update with the result
  15743. * @param particle is the particle we are computed the direction for
  15744. */
  15745. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15746. /**
  15747. * Called by the particle System when the position is computed for the created particle.
  15748. * @param worldMatrix is the world matrix of the particle system
  15749. * @param positionToUpdate is the position vector to update with the result
  15750. * @param particle is the particle we are computed the position for
  15751. */
  15752. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15753. /**
  15754. * Clones the current emitter and returns a copy of it
  15755. * @returns the new emitter
  15756. */
  15757. clone(): ConeParticleEmitter;
  15758. /**
  15759. * Called by the GPUParticleSystem to setup the update shader
  15760. * @param effect defines the update shader
  15761. */
  15762. applyToShader(effect: Effect): void;
  15763. /**
  15764. * Returns a string to use to update the GPU particles update shader
  15765. * @returns a string containng the defines string
  15766. */
  15767. getEffectDefines(): string;
  15768. /**
  15769. * Returns the string "ConeParticleEmitter"
  15770. * @returns a string containing the class name
  15771. */
  15772. getClassName(): string;
  15773. /**
  15774. * Serializes the particle system to a JSON object.
  15775. * @returns the JSON object
  15776. */
  15777. serialize(): any;
  15778. /**
  15779. * Parse properties from a JSON object
  15780. * @param serializationObject defines the JSON object
  15781. */
  15782. parse(serializationObject: any): void;
  15783. }
  15784. }
  15785. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15786. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15787. import { Effect } from "babylonjs/Materials/effect";
  15788. import { Particle } from "babylonjs/Particles/particle";
  15789. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15790. /**
  15791. * Particle emitter emitting particles from the inside of a cylinder.
  15792. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15793. */
  15794. export class CylinderParticleEmitter implements IParticleEmitterType {
  15795. /**
  15796. * The radius of the emission cylinder.
  15797. */
  15798. radius: number;
  15799. /**
  15800. * The height of the emission cylinder.
  15801. */
  15802. height: number;
  15803. /**
  15804. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15805. */
  15806. radiusRange: number;
  15807. /**
  15808. * How much to randomize the particle direction [0-1].
  15809. */
  15810. directionRandomizer: number;
  15811. /**
  15812. * Creates a new instance CylinderParticleEmitter
  15813. * @param radius the radius of the emission cylinder (1 by default)
  15814. * @param height the height of the emission cylinder (1 by default)
  15815. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15816. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15817. */
  15818. constructor(
  15819. /**
  15820. * The radius of the emission cylinder.
  15821. */
  15822. radius?: number,
  15823. /**
  15824. * The height of the emission cylinder.
  15825. */
  15826. height?: number,
  15827. /**
  15828. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15829. */
  15830. radiusRange?: number,
  15831. /**
  15832. * How much to randomize the particle direction [0-1].
  15833. */
  15834. directionRandomizer?: number);
  15835. /**
  15836. * Called by the particle System when the direction is computed for the created particle.
  15837. * @param worldMatrix is the world matrix of the particle system
  15838. * @param directionToUpdate is the direction vector to update with the result
  15839. * @param particle is the particle we are computed the direction for
  15840. */
  15841. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15842. /**
  15843. * Called by the particle System when the position is computed for the created particle.
  15844. * @param worldMatrix is the world matrix of the particle system
  15845. * @param positionToUpdate is the position vector to update with the result
  15846. * @param particle is the particle we are computed the position for
  15847. */
  15848. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15849. /**
  15850. * Clones the current emitter and returns a copy of it
  15851. * @returns the new emitter
  15852. */
  15853. clone(): CylinderParticleEmitter;
  15854. /**
  15855. * Called by the GPUParticleSystem to setup the update shader
  15856. * @param effect defines the update shader
  15857. */
  15858. applyToShader(effect: Effect): void;
  15859. /**
  15860. * Returns a string to use to update the GPU particles update shader
  15861. * @returns a string containng the defines string
  15862. */
  15863. getEffectDefines(): string;
  15864. /**
  15865. * Returns the string "CylinderParticleEmitter"
  15866. * @returns a string containing the class name
  15867. */
  15868. getClassName(): string;
  15869. /**
  15870. * Serializes the particle system to a JSON object.
  15871. * @returns the JSON object
  15872. */
  15873. serialize(): any;
  15874. /**
  15875. * Parse properties from a JSON object
  15876. * @param serializationObject defines the JSON object
  15877. */
  15878. parse(serializationObject: any): void;
  15879. }
  15880. /**
  15881. * Particle emitter emitting particles from the inside of a cylinder.
  15882. * It emits the particles randomly between two vectors.
  15883. */
  15884. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15885. /**
  15886. * The min limit of the emission direction.
  15887. */
  15888. direction1: Vector3;
  15889. /**
  15890. * The max limit of the emission direction.
  15891. */
  15892. direction2: Vector3;
  15893. /**
  15894. * Creates a new instance CylinderDirectedParticleEmitter
  15895. * @param radius the radius of the emission cylinder (1 by default)
  15896. * @param height the height of the emission cylinder (1 by default)
  15897. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15898. * @param direction1 the min limit of the emission direction (up vector by default)
  15899. * @param direction2 the max limit of the emission direction (up vector by default)
  15900. */
  15901. constructor(radius?: number, height?: number, radiusRange?: number,
  15902. /**
  15903. * The min limit of the emission direction.
  15904. */
  15905. direction1?: Vector3,
  15906. /**
  15907. * The max limit of the emission direction.
  15908. */
  15909. direction2?: Vector3);
  15910. /**
  15911. * Called by the particle System when the direction is computed for the created particle.
  15912. * @param worldMatrix is the world matrix of the particle system
  15913. * @param directionToUpdate is the direction vector to update with the result
  15914. * @param particle is the particle we are computed the direction for
  15915. */
  15916. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15917. /**
  15918. * Clones the current emitter and returns a copy of it
  15919. * @returns the new emitter
  15920. */
  15921. clone(): CylinderDirectedParticleEmitter;
  15922. /**
  15923. * Called by the GPUParticleSystem to setup the update shader
  15924. * @param effect defines the update shader
  15925. */
  15926. applyToShader(effect: Effect): void;
  15927. /**
  15928. * Returns a string to use to update the GPU particles update shader
  15929. * @returns a string containng the defines string
  15930. */
  15931. getEffectDefines(): string;
  15932. /**
  15933. * Returns the string "CylinderDirectedParticleEmitter"
  15934. * @returns a string containing the class name
  15935. */
  15936. getClassName(): string;
  15937. /**
  15938. * Serializes the particle system to a JSON object.
  15939. * @returns the JSON object
  15940. */
  15941. serialize(): any;
  15942. /**
  15943. * Parse properties from a JSON object
  15944. * @param serializationObject defines the JSON object
  15945. */
  15946. parse(serializationObject: any): void;
  15947. }
  15948. }
  15949. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15950. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15951. import { Effect } from "babylonjs/Materials/effect";
  15952. import { Particle } from "babylonjs/Particles/particle";
  15953. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15954. /**
  15955. * Particle emitter emitting particles from the inside of a hemisphere.
  15956. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15957. */
  15958. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15959. /**
  15960. * The radius of the emission hemisphere.
  15961. */
  15962. radius: number;
  15963. /**
  15964. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15965. */
  15966. radiusRange: number;
  15967. /**
  15968. * How much to randomize the particle direction [0-1].
  15969. */
  15970. directionRandomizer: number;
  15971. /**
  15972. * Creates a new instance HemisphericParticleEmitter
  15973. * @param radius the radius of the emission hemisphere (1 by default)
  15974. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15975. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15976. */
  15977. constructor(
  15978. /**
  15979. * The radius of the emission hemisphere.
  15980. */
  15981. radius?: number,
  15982. /**
  15983. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15984. */
  15985. radiusRange?: number,
  15986. /**
  15987. * How much to randomize the particle direction [0-1].
  15988. */
  15989. directionRandomizer?: number);
  15990. /**
  15991. * Called by the particle System when the direction is computed for the created particle.
  15992. * @param worldMatrix is the world matrix of the particle system
  15993. * @param directionToUpdate is the direction vector to update with the result
  15994. * @param particle is the particle we are computed the direction for
  15995. */
  15996. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15997. /**
  15998. * Called by the particle System when the position is computed for the created particle.
  15999. * @param worldMatrix is the world matrix of the particle system
  16000. * @param positionToUpdate is the position vector to update with the result
  16001. * @param particle is the particle we are computed the position for
  16002. */
  16003. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16004. /**
  16005. * Clones the current emitter and returns a copy of it
  16006. * @returns the new emitter
  16007. */
  16008. clone(): HemisphericParticleEmitter;
  16009. /**
  16010. * Called by the GPUParticleSystem to setup the update shader
  16011. * @param effect defines the update shader
  16012. */
  16013. applyToShader(effect: Effect): void;
  16014. /**
  16015. * Returns a string to use to update the GPU particles update shader
  16016. * @returns a string containng the defines string
  16017. */
  16018. getEffectDefines(): string;
  16019. /**
  16020. * Returns the string "HemisphericParticleEmitter"
  16021. * @returns a string containing the class name
  16022. */
  16023. getClassName(): string;
  16024. /**
  16025. * Serializes the particle system to a JSON object.
  16026. * @returns the JSON object
  16027. */
  16028. serialize(): any;
  16029. /**
  16030. * Parse properties from a JSON object
  16031. * @param serializationObject defines the JSON object
  16032. */
  16033. parse(serializationObject: any): void;
  16034. }
  16035. }
  16036. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16037. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16038. import { Effect } from "babylonjs/Materials/effect";
  16039. import { Particle } from "babylonjs/Particles/particle";
  16040. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16041. /**
  16042. * Particle emitter emitting particles from a point.
  16043. * It emits the particles randomly between 2 given directions.
  16044. */
  16045. export class PointParticleEmitter implements IParticleEmitterType {
  16046. /**
  16047. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16048. */
  16049. direction1: Vector3;
  16050. /**
  16051. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16052. */
  16053. direction2: Vector3;
  16054. /**
  16055. * Creates a new instance PointParticleEmitter
  16056. */
  16057. constructor();
  16058. /**
  16059. * Called by the particle System when the direction is computed for the created particle.
  16060. * @param worldMatrix is the world matrix of the particle system
  16061. * @param directionToUpdate is the direction vector to update with the result
  16062. * @param particle is the particle we are computed the direction for
  16063. */
  16064. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16065. /**
  16066. * Called by the particle System when the position is computed for the created particle.
  16067. * @param worldMatrix is the world matrix of the particle system
  16068. * @param positionToUpdate is the position vector to update with the result
  16069. * @param particle is the particle we are computed the position for
  16070. */
  16071. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16072. /**
  16073. * Clones the current emitter and returns a copy of it
  16074. * @returns the new emitter
  16075. */
  16076. clone(): PointParticleEmitter;
  16077. /**
  16078. * Called by the GPUParticleSystem to setup the update shader
  16079. * @param effect defines the update shader
  16080. */
  16081. applyToShader(effect: Effect): void;
  16082. /**
  16083. * Returns a string to use to update the GPU particles update shader
  16084. * @returns a string containng the defines string
  16085. */
  16086. getEffectDefines(): string;
  16087. /**
  16088. * Returns the string "PointParticleEmitter"
  16089. * @returns a string containing the class name
  16090. */
  16091. getClassName(): string;
  16092. /**
  16093. * Serializes the particle system to a JSON object.
  16094. * @returns the JSON object
  16095. */
  16096. serialize(): any;
  16097. /**
  16098. * Parse properties from a JSON object
  16099. * @param serializationObject defines the JSON object
  16100. */
  16101. parse(serializationObject: any): void;
  16102. }
  16103. }
  16104. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16105. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16106. import { Effect } from "babylonjs/Materials/effect";
  16107. import { Particle } from "babylonjs/Particles/particle";
  16108. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16109. /**
  16110. * Particle emitter emitting particles from the inside of a sphere.
  16111. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16112. */
  16113. export class SphereParticleEmitter implements IParticleEmitterType {
  16114. /**
  16115. * The radius of the emission sphere.
  16116. */
  16117. radius: number;
  16118. /**
  16119. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16120. */
  16121. radiusRange: number;
  16122. /**
  16123. * How much to randomize the particle direction [0-1].
  16124. */
  16125. directionRandomizer: number;
  16126. /**
  16127. * Creates a new instance SphereParticleEmitter
  16128. * @param radius the radius of the emission sphere (1 by default)
  16129. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16130. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16131. */
  16132. constructor(
  16133. /**
  16134. * The radius of the emission sphere.
  16135. */
  16136. radius?: number,
  16137. /**
  16138. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16139. */
  16140. radiusRange?: number,
  16141. /**
  16142. * How much to randomize the particle direction [0-1].
  16143. */
  16144. directionRandomizer?: number);
  16145. /**
  16146. * Called by the particle System when the direction is computed for the created particle.
  16147. * @param worldMatrix is the world matrix of the particle system
  16148. * @param directionToUpdate is the direction vector to update with the result
  16149. * @param particle is the particle we are computed the direction for
  16150. */
  16151. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16152. /**
  16153. * Called by the particle System when the position is computed for the created particle.
  16154. * @param worldMatrix is the world matrix of the particle system
  16155. * @param positionToUpdate is the position vector to update with the result
  16156. * @param particle is the particle we are computed the position for
  16157. */
  16158. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16159. /**
  16160. * Clones the current emitter and returns a copy of it
  16161. * @returns the new emitter
  16162. */
  16163. clone(): SphereParticleEmitter;
  16164. /**
  16165. * Called by the GPUParticleSystem to setup the update shader
  16166. * @param effect defines the update shader
  16167. */
  16168. applyToShader(effect: Effect): void;
  16169. /**
  16170. * Returns a string to use to update the GPU particles update shader
  16171. * @returns a string containng the defines string
  16172. */
  16173. getEffectDefines(): string;
  16174. /**
  16175. * Returns the string "SphereParticleEmitter"
  16176. * @returns a string containing the class name
  16177. */
  16178. getClassName(): string;
  16179. /**
  16180. * Serializes the particle system to a JSON object.
  16181. * @returns the JSON object
  16182. */
  16183. serialize(): any;
  16184. /**
  16185. * Parse properties from a JSON object
  16186. * @param serializationObject defines the JSON object
  16187. */
  16188. parse(serializationObject: any): void;
  16189. }
  16190. /**
  16191. * Particle emitter emitting particles from the inside of a sphere.
  16192. * It emits the particles randomly between two vectors.
  16193. */
  16194. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16195. /**
  16196. * The min limit of the emission direction.
  16197. */
  16198. direction1: Vector3;
  16199. /**
  16200. * The max limit of the emission direction.
  16201. */
  16202. direction2: Vector3;
  16203. /**
  16204. * Creates a new instance SphereDirectedParticleEmitter
  16205. * @param radius the radius of the emission sphere (1 by default)
  16206. * @param direction1 the min limit of the emission direction (up vector by default)
  16207. * @param direction2 the max limit of the emission direction (up vector by default)
  16208. */
  16209. constructor(radius?: number,
  16210. /**
  16211. * The min limit of the emission direction.
  16212. */
  16213. direction1?: Vector3,
  16214. /**
  16215. * The max limit of the emission direction.
  16216. */
  16217. direction2?: Vector3);
  16218. /**
  16219. * Called by the particle System when the direction is computed for the created particle.
  16220. * @param worldMatrix is the world matrix of the particle system
  16221. * @param directionToUpdate is the direction vector to update with the result
  16222. * @param particle is the particle we are computed the direction for
  16223. */
  16224. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16225. /**
  16226. * Clones the current emitter and returns a copy of it
  16227. * @returns the new emitter
  16228. */
  16229. clone(): SphereDirectedParticleEmitter;
  16230. /**
  16231. * Called by the GPUParticleSystem to setup the update shader
  16232. * @param effect defines the update shader
  16233. */
  16234. applyToShader(effect: Effect): void;
  16235. /**
  16236. * Returns a string to use to update the GPU particles update shader
  16237. * @returns a string containng the defines string
  16238. */
  16239. getEffectDefines(): string;
  16240. /**
  16241. * Returns the string "SphereDirectedParticleEmitter"
  16242. * @returns a string containing the class name
  16243. */
  16244. getClassName(): string;
  16245. /**
  16246. * Serializes the particle system to a JSON object.
  16247. * @returns the JSON object
  16248. */
  16249. serialize(): any;
  16250. /**
  16251. * Parse properties from a JSON object
  16252. * @param serializationObject defines the JSON object
  16253. */
  16254. parse(serializationObject: any): void;
  16255. }
  16256. }
  16257. declare module "babylonjs/Particles/EmitterTypes/index" {
  16258. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16259. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16260. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16261. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16262. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16263. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16264. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16265. }
  16266. declare module "babylonjs/Particles/IParticleSystem" {
  16267. import { Nullable } from "babylonjs/types";
  16268. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16270. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16271. import { Texture } from "babylonjs/Materials/Textures/texture";
  16272. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16273. import { Scene } from "babylonjs/scene";
  16274. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16275. import { Animation } from "babylonjs/Animations/animation";
  16276. /**
  16277. * Interface representing a particle system in Babylon.js.
  16278. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16279. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16280. */
  16281. export interface IParticleSystem {
  16282. /**
  16283. * List of animations used by the particle system.
  16284. */
  16285. animations: Animation[];
  16286. /**
  16287. * The id of the Particle system.
  16288. */
  16289. id: string;
  16290. /**
  16291. * The name of the Particle system.
  16292. */
  16293. name: string;
  16294. /**
  16295. * The emitter represents the Mesh or position we are attaching the particle system to.
  16296. */
  16297. emitter: Nullable<AbstractMesh | Vector3>;
  16298. /**
  16299. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16300. */
  16301. isBillboardBased: boolean;
  16302. /**
  16303. * The rendering group used by the Particle system to chose when to render.
  16304. */
  16305. renderingGroupId: number;
  16306. /**
  16307. * The layer mask we are rendering the particles through.
  16308. */
  16309. layerMask: number;
  16310. /**
  16311. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16312. */
  16313. updateSpeed: number;
  16314. /**
  16315. * The amount of time the particle system is running (depends of the overall update speed).
  16316. */
  16317. targetStopDuration: number;
  16318. /**
  16319. * The texture used to render each particle. (this can be a spritesheet)
  16320. */
  16321. particleTexture: Nullable<Texture>;
  16322. /**
  16323. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16324. */
  16325. blendMode: number;
  16326. /**
  16327. * Minimum life time of emitting particles.
  16328. */
  16329. minLifeTime: number;
  16330. /**
  16331. * Maximum life time of emitting particles.
  16332. */
  16333. maxLifeTime: number;
  16334. /**
  16335. * Minimum Size of emitting particles.
  16336. */
  16337. minSize: number;
  16338. /**
  16339. * Maximum Size of emitting particles.
  16340. */
  16341. maxSize: number;
  16342. /**
  16343. * Minimum scale of emitting particles on X axis.
  16344. */
  16345. minScaleX: number;
  16346. /**
  16347. * Maximum scale of emitting particles on X axis.
  16348. */
  16349. maxScaleX: number;
  16350. /**
  16351. * Minimum scale of emitting particles on Y axis.
  16352. */
  16353. minScaleY: number;
  16354. /**
  16355. * Maximum scale of emitting particles on Y axis.
  16356. */
  16357. maxScaleY: number;
  16358. /**
  16359. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16360. */
  16361. color1: Color4;
  16362. /**
  16363. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16364. */
  16365. color2: Color4;
  16366. /**
  16367. * Color the particle will have at the end of its lifetime.
  16368. */
  16369. colorDead: Color4;
  16370. /**
  16371. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16372. */
  16373. emitRate: number;
  16374. /**
  16375. * You can use gravity if you want to give an orientation to your particles.
  16376. */
  16377. gravity: Vector3;
  16378. /**
  16379. * Minimum power of emitting particles.
  16380. */
  16381. minEmitPower: number;
  16382. /**
  16383. * Maximum power of emitting particles.
  16384. */
  16385. maxEmitPower: number;
  16386. /**
  16387. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16388. */
  16389. minAngularSpeed: number;
  16390. /**
  16391. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16392. */
  16393. maxAngularSpeed: number;
  16394. /**
  16395. * Gets or sets the minimal initial rotation in radians.
  16396. */
  16397. minInitialRotation: number;
  16398. /**
  16399. * Gets or sets the maximal initial rotation in radians.
  16400. */
  16401. maxInitialRotation: number;
  16402. /**
  16403. * The particle emitter type defines the emitter used by the particle system.
  16404. * It can be for example box, sphere, or cone...
  16405. */
  16406. particleEmitterType: Nullable<IParticleEmitterType>;
  16407. /**
  16408. * Defines the delay in milliseconds before starting the system (0 by default)
  16409. */
  16410. startDelay: number;
  16411. /**
  16412. * 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
  16413. */
  16414. preWarmCycles: number;
  16415. /**
  16416. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16417. */
  16418. preWarmStepOffset: number;
  16419. /**
  16420. * 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)
  16421. */
  16422. spriteCellChangeSpeed: number;
  16423. /**
  16424. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16425. */
  16426. startSpriteCellID: number;
  16427. /**
  16428. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16429. */
  16430. endSpriteCellID: number;
  16431. /**
  16432. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16433. */
  16434. spriteCellWidth: number;
  16435. /**
  16436. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16437. */
  16438. spriteCellHeight: number;
  16439. /**
  16440. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16441. */
  16442. spriteRandomStartCell: boolean;
  16443. /**
  16444. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16445. */
  16446. isAnimationSheetEnabled: boolean;
  16447. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16448. translationPivot: Vector2;
  16449. /**
  16450. * Gets or sets a texture used to add random noise to particle positions
  16451. */
  16452. noiseTexture: Nullable<BaseTexture>;
  16453. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16454. noiseStrength: Vector3;
  16455. /**
  16456. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16457. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16458. */
  16459. billboardMode: number;
  16460. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16461. limitVelocityDamping: number;
  16462. /**
  16463. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16464. */
  16465. beginAnimationOnStart: boolean;
  16466. /**
  16467. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16468. */
  16469. beginAnimationFrom: number;
  16470. /**
  16471. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16472. */
  16473. beginAnimationTo: number;
  16474. /**
  16475. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16476. */
  16477. beginAnimationLoop: boolean;
  16478. /**
  16479. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16480. */
  16481. disposeOnStop: boolean;
  16482. /**
  16483. * Gets the maximum number of particles active at the same time.
  16484. * @returns The max number of active particles.
  16485. */
  16486. getCapacity(): number;
  16487. /**
  16488. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16489. * @returns True if it has been started, otherwise false.
  16490. */
  16491. isStarted(): boolean;
  16492. /**
  16493. * Animates the particle system for this frame.
  16494. */
  16495. animate(): void;
  16496. /**
  16497. * Renders the particle system in its current state.
  16498. * @returns the current number of particles
  16499. */
  16500. render(): number;
  16501. /**
  16502. * Dispose the particle system and frees its associated resources.
  16503. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16504. */
  16505. dispose(disposeTexture?: boolean): void;
  16506. /**
  16507. * Clones the particle system.
  16508. * @param name The name of the cloned object
  16509. * @param newEmitter The new emitter to use
  16510. * @returns the cloned particle system
  16511. */
  16512. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16513. /**
  16514. * Serializes the particle system to a JSON object.
  16515. * @returns the JSON object
  16516. */
  16517. serialize(): any;
  16518. /**
  16519. * Rebuild the particle system
  16520. */
  16521. rebuild(): void;
  16522. /**
  16523. * Starts the particle system and begins to emit
  16524. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16525. */
  16526. start(delay?: number): void;
  16527. /**
  16528. * Stops the particle system.
  16529. */
  16530. stop(): void;
  16531. /**
  16532. * Remove all active particles
  16533. */
  16534. reset(): void;
  16535. /**
  16536. * Is this system ready to be used/rendered
  16537. * @return true if the system is ready
  16538. */
  16539. isReady(): boolean;
  16540. /**
  16541. * Adds a new color gradient
  16542. * @param gradient defines the gradient to use (between 0 and 1)
  16543. * @param color1 defines the color to affect to the specified gradient
  16544. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16545. * @returns the current particle system
  16546. */
  16547. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16548. /**
  16549. * Remove a specific color gradient
  16550. * @param gradient defines the gradient to remove
  16551. * @returns the current particle system
  16552. */
  16553. removeColorGradient(gradient: number): IParticleSystem;
  16554. /**
  16555. * Adds a new size gradient
  16556. * @param gradient defines the gradient to use (between 0 and 1)
  16557. * @param factor defines the size factor to affect to the specified gradient
  16558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16559. * @returns the current particle system
  16560. */
  16561. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16562. /**
  16563. * Remove a specific size gradient
  16564. * @param gradient defines the gradient to remove
  16565. * @returns the current particle system
  16566. */
  16567. removeSizeGradient(gradient: number): IParticleSystem;
  16568. /**
  16569. * Gets the current list of color gradients.
  16570. * You must use addColorGradient and removeColorGradient to udpate this list
  16571. * @returns the list of color gradients
  16572. */
  16573. getColorGradients(): Nullable<Array<ColorGradient>>;
  16574. /**
  16575. * Gets the current list of size gradients.
  16576. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16577. * @returns the list of size gradients
  16578. */
  16579. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16580. /**
  16581. * Gets the current list of angular speed gradients.
  16582. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16583. * @returns the list of angular speed gradients
  16584. */
  16585. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16586. /**
  16587. * Adds a new angular speed gradient
  16588. * @param gradient defines the gradient to use (between 0 and 1)
  16589. * @param factor defines the angular speed to affect to the specified gradient
  16590. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16591. * @returns the current particle system
  16592. */
  16593. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16594. /**
  16595. * Remove a specific angular speed gradient
  16596. * @param gradient defines the gradient to remove
  16597. * @returns the current particle system
  16598. */
  16599. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16600. /**
  16601. * Gets the current list of velocity gradients.
  16602. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16603. * @returns the list of velocity gradients
  16604. */
  16605. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16606. /**
  16607. * Adds a new velocity gradient
  16608. * @param gradient defines the gradient to use (between 0 and 1)
  16609. * @param factor defines the velocity to affect to the specified gradient
  16610. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16611. * @returns the current particle system
  16612. */
  16613. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16614. /**
  16615. * Remove a specific velocity gradient
  16616. * @param gradient defines the gradient to remove
  16617. * @returns the current particle system
  16618. */
  16619. removeVelocityGradient(gradient: number): IParticleSystem;
  16620. /**
  16621. * Gets the current list of limit velocity gradients.
  16622. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16623. * @returns the list of limit velocity gradients
  16624. */
  16625. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16626. /**
  16627. * Adds a new limit velocity gradient
  16628. * @param gradient defines the gradient to use (between 0 and 1)
  16629. * @param factor defines the limit velocity to affect to the specified gradient
  16630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16631. * @returns the current particle system
  16632. */
  16633. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16634. /**
  16635. * Remove a specific limit velocity gradient
  16636. * @param gradient defines the gradient to remove
  16637. * @returns the current particle system
  16638. */
  16639. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16640. /**
  16641. * Adds a new drag gradient
  16642. * @param gradient defines the gradient to use (between 0 and 1)
  16643. * @param factor defines the drag to affect to the specified gradient
  16644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16645. * @returns the current particle system
  16646. */
  16647. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16648. /**
  16649. * Remove a specific drag gradient
  16650. * @param gradient defines the gradient to remove
  16651. * @returns the current particle system
  16652. */
  16653. removeDragGradient(gradient: number): IParticleSystem;
  16654. /**
  16655. * Gets the current list of drag gradients.
  16656. * You must use addDragGradient and removeDragGradient to udpate this list
  16657. * @returns the list of drag gradients
  16658. */
  16659. getDragGradients(): Nullable<Array<FactorGradient>>;
  16660. /**
  16661. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16662. * @param gradient defines the gradient to use (between 0 and 1)
  16663. * @param factor defines the emit rate to affect to the specified gradient
  16664. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16665. * @returns the current particle system
  16666. */
  16667. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16668. /**
  16669. * Remove a specific emit rate gradient
  16670. * @param gradient defines the gradient to remove
  16671. * @returns the current particle system
  16672. */
  16673. removeEmitRateGradient(gradient: number): IParticleSystem;
  16674. /**
  16675. * Gets the current list of emit rate gradients.
  16676. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16677. * @returns the list of emit rate gradients
  16678. */
  16679. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16680. /**
  16681. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16682. * @param gradient defines the gradient to use (between 0 and 1)
  16683. * @param factor defines the start size to affect to the specified gradient
  16684. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16685. * @returns the current particle system
  16686. */
  16687. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16688. /**
  16689. * Remove a specific start size gradient
  16690. * @param gradient defines the gradient to remove
  16691. * @returns the current particle system
  16692. */
  16693. removeStartSizeGradient(gradient: number): IParticleSystem;
  16694. /**
  16695. * Gets the current list of start size gradients.
  16696. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16697. * @returns the list of start size gradients
  16698. */
  16699. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16700. /**
  16701. * Adds a new life time gradient
  16702. * @param gradient defines the gradient to use (between 0 and 1)
  16703. * @param factor defines the life time factor to affect to the specified gradient
  16704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16705. * @returns the current particle system
  16706. */
  16707. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16708. /**
  16709. * Remove a specific life time gradient
  16710. * @param gradient defines the gradient to remove
  16711. * @returns the current particle system
  16712. */
  16713. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16714. /**
  16715. * Gets the current list of life time gradients.
  16716. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16717. * @returns the list of life time gradients
  16718. */
  16719. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16720. /**
  16721. * Gets the current list of color gradients.
  16722. * You must use addColorGradient and removeColorGradient to udpate this list
  16723. * @returns the list of color gradients
  16724. */
  16725. getColorGradients(): Nullable<Array<ColorGradient>>;
  16726. /**
  16727. * Adds a new ramp gradient used to remap particle colors
  16728. * @param gradient defines the gradient to use (between 0 and 1)
  16729. * @param color defines the color to affect to the specified gradient
  16730. * @returns the current particle system
  16731. */
  16732. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16733. /**
  16734. * Gets the current list of ramp gradients.
  16735. * You must use addRampGradient and removeRampGradient to udpate this list
  16736. * @returns the list of ramp gradients
  16737. */
  16738. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16739. /** Gets or sets a boolean indicating that ramp gradients must be used
  16740. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16741. */
  16742. useRampGradients: boolean;
  16743. /**
  16744. * Adds a new color remap gradient
  16745. * @param gradient defines the gradient to use (between 0 and 1)
  16746. * @param min defines the color remap minimal range
  16747. * @param max defines the color remap maximal range
  16748. * @returns the current particle system
  16749. */
  16750. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16751. /**
  16752. * Gets the current list of color remap gradients.
  16753. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16754. * @returns the list of color remap gradients
  16755. */
  16756. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16757. /**
  16758. * Adds a new alpha remap gradient
  16759. * @param gradient defines the gradient to use (between 0 and 1)
  16760. * @param min defines the alpha remap minimal range
  16761. * @param max defines the alpha remap maximal range
  16762. * @returns the current particle system
  16763. */
  16764. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16765. /**
  16766. * Gets the current list of alpha remap gradients.
  16767. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16768. * @returns the list of alpha remap gradients
  16769. */
  16770. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16771. /**
  16772. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16773. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16774. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16775. * @returns the emitter
  16776. */
  16777. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16778. /**
  16779. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16780. * @param radius The radius of the hemisphere to emit from
  16781. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16782. * @returns the emitter
  16783. */
  16784. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16785. /**
  16786. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16787. * @param radius The radius of the sphere to emit from
  16788. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16789. * @returns the emitter
  16790. */
  16791. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16792. /**
  16793. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16794. * @param radius The radius of the sphere to emit from
  16795. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16796. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16797. * @returns the emitter
  16798. */
  16799. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16800. /**
  16801. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16802. * @param radius The radius of the emission cylinder
  16803. * @param height The height of the emission cylinder
  16804. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16805. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16806. * @returns the emitter
  16807. */
  16808. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16809. /**
  16810. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16811. * @param radius The radius of the cylinder to emit from
  16812. * @param height The height of the emission cylinder
  16813. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16814. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16815. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16816. * @returns the emitter
  16817. */
  16818. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16819. /**
  16820. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16821. * @param radius The radius of the cone to emit from
  16822. * @param angle The base angle of the cone
  16823. * @returns the emitter
  16824. */
  16825. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16826. /**
  16827. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16828. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16829. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16830. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16831. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16832. * @returns the emitter
  16833. */
  16834. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16835. /**
  16836. * Get hosting scene
  16837. * @returns the scene
  16838. */
  16839. getScene(): Scene;
  16840. }
  16841. }
  16842. declare module "babylonjs/Meshes/instancedMesh" {
  16843. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16844. import { Vector3 } from "babylonjs/Maths/math";
  16845. import { Camera } from "babylonjs/Cameras/camera";
  16846. import { Node } from "babylonjs/node";
  16847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16848. import { Mesh } from "babylonjs/Meshes/mesh";
  16849. import { Material } from "babylonjs/Materials/material";
  16850. import { Skeleton } from "babylonjs/Bones/skeleton";
  16851. /**
  16852. * Creates an instance based on a source mesh.
  16853. */
  16854. export class InstancedMesh extends AbstractMesh {
  16855. private _sourceMesh;
  16856. private _currentLOD;
  16857. /** @hidden */
  16858. _indexInSourceMeshInstanceArray: number;
  16859. constructor(name: string, source: Mesh);
  16860. /**
  16861. * Returns the string "InstancedMesh".
  16862. */
  16863. getClassName(): string;
  16864. /**
  16865. * If the source mesh receives shadows
  16866. */
  16867. readonly receiveShadows: boolean;
  16868. /**
  16869. * The material of the source mesh
  16870. */
  16871. readonly material: Nullable<Material>;
  16872. /**
  16873. * Visibility of the source mesh
  16874. */
  16875. readonly visibility: number;
  16876. /**
  16877. * Skeleton of the source mesh
  16878. */
  16879. readonly skeleton: Nullable<Skeleton>;
  16880. /**
  16881. * Rendering ground id of the source mesh
  16882. */
  16883. renderingGroupId: number;
  16884. /**
  16885. * Returns the total number of vertices (integer).
  16886. */
  16887. getTotalVertices(): number;
  16888. /**
  16889. * Returns a positive integer : the total number of indices in this mesh geometry.
  16890. * @returns the numner of indices or zero if the mesh has no geometry.
  16891. */
  16892. getTotalIndices(): number;
  16893. /**
  16894. * The source mesh of the instance
  16895. */
  16896. readonly sourceMesh: Mesh;
  16897. /**
  16898. * Is this node ready to be used/rendered
  16899. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16900. * @return {boolean} is it ready
  16901. */
  16902. isReady(completeCheck?: boolean): boolean;
  16903. /**
  16904. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16905. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16906. * @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.
  16907. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16908. */
  16909. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16910. /**
  16911. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16912. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16913. * The `data` are either a numeric array either a Float32Array.
  16914. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16915. * 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).
  16916. * Note that a new underlying VertexBuffer object is created each call.
  16917. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16918. *
  16919. * Possible `kind` values :
  16920. * - VertexBuffer.PositionKind
  16921. * - VertexBuffer.UVKind
  16922. * - VertexBuffer.UV2Kind
  16923. * - VertexBuffer.UV3Kind
  16924. * - VertexBuffer.UV4Kind
  16925. * - VertexBuffer.UV5Kind
  16926. * - VertexBuffer.UV6Kind
  16927. * - VertexBuffer.ColorKind
  16928. * - VertexBuffer.MatricesIndicesKind
  16929. * - VertexBuffer.MatricesIndicesExtraKind
  16930. * - VertexBuffer.MatricesWeightsKind
  16931. * - VertexBuffer.MatricesWeightsExtraKind
  16932. *
  16933. * Returns the Mesh.
  16934. */
  16935. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16936. /**
  16937. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16938. * If the mesh has no geometry, it is simply returned as it is.
  16939. * The `data` are either a numeric array either a Float32Array.
  16940. * No new underlying VertexBuffer object is created.
  16941. * 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.
  16942. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16943. *
  16944. * Possible `kind` values :
  16945. * - VertexBuffer.PositionKind
  16946. * - VertexBuffer.UVKind
  16947. * - VertexBuffer.UV2Kind
  16948. * - VertexBuffer.UV3Kind
  16949. * - VertexBuffer.UV4Kind
  16950. * - VertexBuffer.UV5Kind
  16951. * - VertexBuffer.UV6Kind
  16952. * - VertexBuffer.ColorKind
  16953. * - VertexBuffer.MatricesIndicesKind
  16954. * - VertexBuffer.MatricesIndicesExtraKind
  16955. * - VertexBuffer.MatricesWeightsKind
  16956. * - VertexBuffer.MatricesWeightsExtraKind
  16957. *
  16958. * Returns the Mesh.
  16959. */
  16960. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16961. /**
  16962. * Sets the mesh indices.
  16963. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16964. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16965. * This method creates a new index buffer each call.
  16966. * Returns the Mesh.
  16967. */
  16968. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16969. /**
  16970. * Boolean : True if the mesh owns the requested kind of data.
  16971. */
  16972. isVerticesDataPresent(kind: string): boolean;
  16973. /**
  16974. * Returns an array of indices (IndicesArray).
  16975. */
  16976. getIndices(): Nullable<IndicesArray>;
  16977. readonly _positions: Nullable<Vector3[]>;
  16978. /**
  16979. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16980. * This means the mesh underlying bounding box and sphere are recomputed.
  16981. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16982. * @returns the current mesh
  16983. */
  16984. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16985. /** @hidden */
  16986. _preActivate(): InstancedMesh;
  16987. /** @hidden */
  16988. _activate(renderId: number): InstancedMesh;
  16989. /**
  16990. * Returns the current associated LOD AbstractMesh.
  16991. */
  16992. getLOD(camera: Camera): AbstractMesh;
  16993. /** @hidden */
  16994. _syncSubMeshes(): InstancedMesh;
  16995. /** @hidden */
  16996. _generatePointsArray(): boolean;
  16997. /**
  16998. * Creates a new InstancedMesh from the current mesh.
  16999. * - name (string) : the cloned mesh name
  17000. * - newParent (optional Node) : the optional Node to parent the clone to.
  17001. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17002. *
  17003. * Returns the clone.
  17004. */
  17005. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17006. /**
  17007. * Disposes the InstancedMesh.
  17008. * Returns nothing.
  17009. */
  17010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17011. }
  17012. }
  17013. declare module "babylonjs/Materials/shaderMaterial" {
  17014. import { Scene } from "babylonjs/scene";
  17015. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17017. import { Mesh } from "babylonjs/Meshes/mesh";
  17018. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17020. import { Texture } from "babylonjs/Materials/Textures/texture";
  17021. import { Material } from "babylonjs/Materials/material";
  17022. /**
  17023. * Defines the options associated with the creation of a shader material.
  17024. */
  17025. export interface IShaderMaterialOptions {
  17026. /**
  17027. * Does the material work in alpha blend mode
  17028. */
  17029. needAlphaBlending: boolean;
  17030. /**
  17031. * Does the material work in alpha test mode
  17032. */
  17033. needAlphaTesting: boolean;
  17034. /**
  17035. * The list of attribute names used in the shader
  17036. */
  17037. attributes: string[];
  17038. /**
  17039. * The list of unifrom names used in the shader
  17040. */
  17041. uniforms: string[];
  17042. /**
  17043. * The list of UBO names used in the shader
  17044. */
  17045. uniformBuffers: string[];
  17046. /**
  17047. * The list of sampler names used in the shader
  17048. */
  17049. samplers: string[];
  17050. /**
  17051. * The list of defines used in the shader
  17052. */
  17053. defines: string[];
  17054. }
  17055. /**
  17056. * 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.
  17057. *
  17058. * This returned material effects how the mesh will look based on the code in the shaders.
  17059. *
  17060. * @see http://doc.babylonjs.com/how_to/shader_material
  17061. */
  17062. export class ShaderMaterial extends Material {
  17063. private _shaderPath;
  17064. private _options;
  17065. private _textures;
  17066. private _textureArrays;
  17067. private _floats;
  17068. private _ints;
  17069. private _floatsArrays;
  17070. private _colors3;
  17071. private _colors3Arrays;
  17072. private _colors4;
  17073. private _vectors2;
  17074. private _vectors3;
  17075. private _vectors4;
  17076. private _matrices;
  17077. private _matrices3x3;
  17078. private _matrices2x2;
  17079. private _vectors2Arrays;
  17080. private _vectors3Arrays;
  17081. private _cachedWorldViewMatrix;
  17082. private _renderId;
  17083. /**
  17084. * Instantiate a new shader material.
  17085. * 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.
  17086. * This returned material effects how the mesh will look based on the code in the shaders.
  17087. * @see http://doc.babylonjs.com/how_to/shader_material
  17088. * @param name Define the name of the material in the scene
  17089. * @param scene Define the scene the material belongs to
  17090. * @param shaderPath Defines the route to the shader code in one of three ways:
  17091. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17092. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17093. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17094. * @param options Define the options used to create the shader
  17095. */
  17096. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17097. /**
  17098. * Gets the options used to compile the shader.
  17099. * They can be modified to trigger a new compilation
  17100. */
  17101. readonly options: IShaderMaterialOptions;
  17102. /**
  17103. * Gets the current class name of the material e.g. "ShaderMaterial"
  17104. * Mainly use in serialization.
  17105. * @returns the class name
  17106. */
  17107. getClassName(): string;
  17108. /**
  17109. * Specifies if the material will require alpha blending
  17110. * @returns a boolean specifying if alpha blending is needed
  17111. */
  17112. needAlphaBlending(): boolean;
  17113. /**
  17114. * Specifies if this material should be rendered in alpha test mode
  17115. * @returns a boolean specifying if an alpha test is needed.
  17116. */
  17117. needAlphaTesting(): boolean;
  17118. private _checkUniform;
  17119. /**
  17120. * Set a texture in the shader.
  17121. * @param name Define the name of the uniform samplers as defined in the shader
  17122. * @param texture Define the texture to bind to this sampler
  17123. * @return the material itself allowing "fluent" like uniform updates
  17124. */
  17125. setTexture(name: string, texture: Texture): ShaderMaterial;
  17126. /**
  17127. * Set a texture array in the shader.
  17128. * @param name Define the name of the uniform sampler array as defined in the shader
  17129. * @param textures Define the list of textures to bind to this sampler
  17130. * @return the material itself allowing "fluent" like uniform updates
  17131. */
  17132. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17133. /**
  17134. * Set a float in the shader.
  17135. * @param name Define the name of the uniform as defined in the shader
  17136. * @param value Define the value to give to the uniform
  17137. * @return the material itself allowing "fluent" like uniform updates
  17138. */
  17139. setFloat(name: string, value: number): ShaderMaterial;
  17140. /**
  17141. * Set a int in the shader.
  17142. * @param name Define the name of the uniform as defined in the shader
  17143. * @param value Define the value to give to the uniform
  17144. * @return the material itself allowing "fluent" like uniform updates
  17145. */
  17146. setInt(name: string, value: number): ShaderMaterial;
  17147. /**
  17148. * Set an array of floats in the shader.
  17149. * @param name Define the name of the uniform as defined in the shader
  17150. * @param value Define the value to give to the uniform
  17151. * @return the material itself allowing "fluent" like uniform updates
  17152. */
  17153. setFloats(name: string, value: number[]): ShaderMaterial;
  17154. /**
  17155. * Set a vec3 in the shader from a Color3.
  17156. * @param name Define the name of the uniform as defined in the shader
  17157. * @param value Define the value to give to the uniform
  17158. * @return the material itself allowing "fluent" like uniform updates
  17159. */
  17160. setColor3(name: string, value: Color3): ShaderMaterial;
  17161. /**
  17162. * Set a vec3 array in the shader from a Color3 array.
  17163. * @param name Define the name of the uniform as defined in the shader
  17164. * @param value Define the value to give to the uniform
  17165. * @return the material itself allowing "fluent" like uniform updates
  17166. */
  17167. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17168. /**
  17169. * Set a vec4 in the shader from a Color4.
  17170. * @param name Define the name of the uniform as defined in the shader
  17171. * @param value Define the value to give to the uniform
  17172. * @return the material itself allowing "fluent" like uniform updates
  17173. */
  17174. setColor4(name: string, value: Color4): ShaderMaterial;
  17175. /**
  17176. * Set a vec2 in the shader from a Vector2.
  17177. * @param name Define the name of the uniform as defined in the shader
  17178. * @param value Define the value to give to the uniform
  17179. * @return the material itself allowing "fluent" like uniform updates
  17180. */
  17181. setVector2(name: string, value: Vector2): ShaderMaterial;
  17182. /**
  17183. * Set a vec3 in the shader from a Vector3.
  17184. * @param name Define the name of the uniform as defined in the shader
  17185. * @param value Define the value to give to the uniform
  17186. * @return the material itself allowing "fluent" like uniform updates
  17187. */
  17188. setVector3(name: string, value: Vector3): ShaderMaterial;
  17189. /**
  17190. * Set a vec4 in the shader from a Vector4.
  17191. * @param name Define the name of the uniform as defined in the shader
  17192. * @param value Define the value to give to the uniform
  17193. * @return the material itself allowing "fluent" like uniform updates
  17194. */
  17195. setVector4(name: string, value: Vector4): ShaderMaterial;
  17196. /**
  17197. * Set a mat4 in the shader from a Matrix.
  17198. * @param name Define the name of the uniform as defined in the shader
  17199. * @param value Define the value to give to the uniform
  17200. * @return the material itself allowing "fluent" like uniform updates
  17201. */
  17202. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17203. /**
  17204. * Set a mat3 in the shader from a Float32Array.
  17205. * @param name Define the name of the uniform as defined in the shader
  17206. * @param value Define the value to give to the uniform
  17207. * @return the material itself allowing "fluent" like uniform updates
  17208. */
  17209. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17210. /**
  17211. * Set a mat2 in the shader from a Float32Array.
  17212. * @param name Define the name of the uniform as defined in the shader
  17213. * @param value Define the value to give to the uniform
  17214. * @return the material itself allowing "fluent" like uniform updates
  17215. */
  17216. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17217. /**
  17218. * Set a vec2 array in the shader from a number array.
  17219. * @param name Define the name of the uniform as defined in the shader
  17220. * @param value Define the value to give to the uniform
  17221. * @return the material itself allowing "fluent" like uniform updates
  17222. */
  17223. setArray2(name: string, value: number[]): ShaderMaterial;
  17224. /**
  17225. * Set a vec3 array in the shader from a number array.
  17226. * @param name Define the name of the uniform as defined in the shader
  17227. * @param value Define the value to give to the uniform
  17228. * @return the material itself allowing "fluent" like uniform updates
  17229. */
  17230. setArray3(name: string, value: number[]): ShaderMaterial;
  17231. private _checkCache;
  17232. /**
  17233. * Specifies that the submesh is ready to be used
  17234. * @param mesh defines the mesh to check
  17235. * @param subMesh defines which submesh to check
  17236. * @param useInstances specifies that instances should be used
  17237. * @returns a boolean indicating that the submesh is ready or not
  17238. */
  17239. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17240. /**
  17241. * Checks if the material is ready to render the requested mesh
  17242. * @param mesh Define the mesh to render
  17243. * @param useInstances Define whether or not the material is used with instances
  17244. * @returns true if ready, otherwise false
  17245. */
  17246. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17247. /**
  17248. * Binds the world matrix to the material
  17249. * @param world defines the world transformation matrix
  17250. */
  17251. bindOnlyWorldMatrix(world: Matrix): void;
  17252. /**
  17253. * Binds the material to the mesh
  17254. * @param world defines the world transformation matrix
  17255. * @param mesh defines the mesh to bind the material to
  17256. */
  17257. bind(world: Matrix, mesh?: Mesh): void;
  17258. /**
  17259. * Gets the active textures from the material
  17260. * @returns an array of textures
  17261. */
  17262. getActiveTextures(): BaseTexture[];
  17263. /**
  17264. * Specifies if the material uses a texture
  17265. * @param texture defines the texture to check against the material
  17266. * @returns a boolean specifying if the material uses the texture
  17267. */
  17268. hasTexture(texture: BaseTexture): boolean;
  17269. /**
  17270. * Makes a duplicate of the material, and gives it a new name
  17271. * @param name defines the new name for the duplicated material
  17272. * @returns the cloned material
  17273. */
  17274. clone(name: string): ShaderMaterial;
  17275. /**
  17276. * Disposes the material
  17277. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17278. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17279. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17280. */
  17281. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17282. /**
  17283. * Serializes this material in a JSON representation
  17284. * @returns the serialized material object
  17285. */
  17286. serialize(): any;
  17287. /**
  17288. * Creates a shader material from parsed shader material data
  17289. * @param source defines the JSON represnetation of the material
  17290. * @param scene defines the hosting scene
  17291. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17292. * @returns a new material
  17293. */
  17294. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17295. }
  17296. }
  17297. declare module "babylonjs/Shaders/color.fragment" {
  17298. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17299. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17300. /** @hidden */
  17301. export var colorPixelShader: {
  17302. name: string;
  17303. shader: string;
  17304. };
  17305. }
  17306. declare module "babylonjs/Shaders/color.vertex" {
  17307. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17308. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17309. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17310. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17311. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17312. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17313. /** @hidden */
  17314. export var colorVertexShader: {
  17315. name: string;
  17316. shader: string;
  17317. };
  17318. }
  17319. declare module "babylonjs/Meshes/linesMesh" {
  17320. import { Nullable } from "babylonjs/types";
  17321. import { Scene } from "babylonjs/scene";
  17322. import { Color3 } from "babylonjs/Maths/math";
  17323. import { Node } from "babylonjs/node";
  17324. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17325. import { Mesh } from "babylonjs/Meshes/mesh";
  17326. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17327. import { Effect } from "babylonjs/Materials/effect";
  17328. import { Material } from "babylonjs/Materials/material";
  17329. import "babylonjs/Shaders/color.fragment";
  17330. import "babylonjs/Shaders/color.vertex";
  17331. /**
  17332. * Line mesh
  17333. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17334. */
  17335. export class LinesMesh extends Mesh {
  17336. /**
  17337. * If vertex color should be applied to the mesh
  17338. */
  17339. useVertexColor?: boolean | undefined;
  17340. /**
  17341. * If vertex alpha should be applied to the mesh
  17342. */
  17343. useVertexAlpha?: boolean | undefined;
  17344. /**
  17345. * Color of the line (Default: White)
  17346. */
  17347. color: Color3;
  17348. /**
  17349. * Alpha of the line (Default: 1)
  17350. */
  17351. alpha: number;
  17352. /**
  17353. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17354. * This margin is expressed in world space coordinates, so its value may vary.
  17355. * Default value is 0.1
  17356. */
  17357. intersectionThreshold: number;
  17358. private _colorShader;
  17359. /**
  17360. * Creates a new LinesMesh
  17361. * @param name defines the name
  17362. * @param scene defines the hosting scene
  17363. * @param parent defines the parent mesh if any
  17364. * @param source defines the optional source LinesMesh used to clone data from
  17365. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17366. * When false, achieved by calling a clone(), also passing False.
  17367. * This will make creation of children, recursive.
  17368. * @param useVertexColor defines if this LinesMesh supports vertex color
  17369. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17370. */
  17371. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17372. /**
  17373. * If vertex color should be applied to the mesh
  17374. */
  17375. useVertexColor?: boolean | undefined,
  17376. /**
  17377. * If vertex alpha should be applied to the mesh
  17378. */
  17379. useVertexAlpha?: boolean | undefined);
  17380. private _addClipPlaneDefine;
  17381. private _removeClipPlaneDefine;
  17382. isReady(): boolean;
  17383. /**
  17384. * Returns the string "LineMesh"
  17385. */
  17386. getClassName(): string;
  17387. /**
  17388. * @hidden
  17389. */
  17390. /**
  17391. * @hidden
  17392. */
  17393. material: Material;
  17394. /**
  17395. * @hidden
  17396. */
  17397. readonly checkCollisions: boolean;
  17398. /** @hidden */
  17399. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17400. /** @hidden */
  17401. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17402. /**
  17403. * Disposes of the line mesh
  17404. * @param doNotRecurse If children should be disposed
  17405. */
  17406. dispose(doNotRecurse?: boolean): void;
  17407. /**
  17408. * Returns a new LineMesh object cloned from the current one.
  17409. */
  17410. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17411. /**
  17412. * Creates a new InstancedLinesMesh object from the mesh model.
  17413. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17414. * @param name defines the name of the new instance
  17415. * @returns a new InstancedLinesMesh
  17416. */
  17417. createInstance(name: string): InstancedLinesMesh;
  17418. }
  17419. /**
  17420. * Creates an instance based on a source LinesMesh
  17421. */
  17422. export class InstancedLinesMesh extends InstancedMesh {
  17423. /**
  17424. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17425. * This margin is expressed in world space coordinates, so its value may vary.
  17426. * Initilized with the intersectionThreshold value of the source LinesMesh
  17427. */
  17428. intersectionThreshold: number;
  17429. constructor(name: string, source: LinesMesh);
  17430. /**
  17431. * Returns the string "InstancedLinesMesh".
  17432. */
  17433. getClassName(): string;
  17434. }
  17435. }
  17436. declare module "babylonjs/Shaders/line.fragment" {
  17437. /** @hidden */
  17438. export var linePixelShader: {
  17439. name: string;
  17440. shader: string;
  17441. };
  17442. }
  17443. declare module "babylonjs/Shaders/line.vertex" {
  17444. /** @hidden */
  17445. export var lineVertexShader: {
  17446. name: string;
  17447. shader: string;
  17448. };
  17449. }
  17450. declare module "babylonjs/Rendering/edgesRenderer" {
  17451. import { Nullable } from "babylonjs/types";
  17452. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17454. import { Vector3 } from "babylonjs/Maths/math";
  17455. import { IDisposable } from "babylonjs/scene";
  17456. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17457. import "babylonjs/Shaders/line.fragment";
  17458. import "babylonjs/Shaders/line.vertex";
  17459. module "babylonjs/Meshes/abstractMesh" {
  17460. interface AbstractMesh {
  17461. /**
  17462. * Disables the mesh edge rendering mode
  17463. * @returns the currentAbstractMesh
  17464. */
  17465. disableEdgesRendering(): AbstractMesh;
  17466. /**
  17467. * Enables the edge rendering mode on the mesh.
  17468. * This mode makes the mesh edges visible
  17469. * @param epsilon defines the maximal distance between two angles to detect a face
  17470. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17471. * @returns the currentAbstractMesh
  17472. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17473. */
  17474. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17475. /**
  17476. * Gets the edgesRenderer associated with the mesh
  17477. */
  17478. edgesRenderer: Nullable<EdgesRenderer>;
  17479. }
  17480. }
  17481. module "babylonjs/Meshes/linesMesh" {
  17482. interface LinesMesh {
  17483. /**
  17484. * Enables the edge rendering mode on the mesh.
  17485. * This mode makes the mesh edges visible
  17486. * @param epsilon defines the maximal distance between two angles to detect a face
  17487. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17488. * @returns the currentAbstractMesh
  17489. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17490. */
  17491. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17492. }
  17493. }
  17494. module "babylonjs/Meshes/linesMesh" {
  17495. interface InstancedLinesMesh {
  17496. /**
  17497. * Enables the edge rendering mode on the mesh.
  17498. * This mode makes the mesh edges visible
  17499. * @param epsilon defines the maximal distance between two angles to detect a face
  17500. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17501. * @returns the current InstancedLinesMesh
  17502. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17503. */
  17504. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17505. }
  17506. }
  17507. /**
  17508. * Defines the minimum contract an Edges renderer should follow.
  17509. */
  17510. export interface IEdgesRenderer extends IDisposable {
  17511. /**
  17512. * Gets or sets a boolean indicating if the edgesRenderer is active
  17513. */
  17514. isEnabled: boolean;
  17515. /**
  17516. * Renders the edges of the attached mesh,
  17517. */
  17518. render(): void;
  17519. /**
  17520. * Checks wether or not the edges renderer is ready to render.
  17521. * @return true if ready, otherwise false.
  17522. */
  17523. isReady(): boolean;
  17524. }
  17525. /**
  17526. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17527. */
  17528. export class EdgesRenderer implements IEdgesRenderer {
  17529. /**
  17530. * Define the size of the edges with an orthographic camera
  17531. */
  17532. edgesWidthScalerForOrthographic: number;
  17533. /**
  17534. * Define the size of the edges with a perspective camera
  17535. */
  17536. edgesWidthScalerForPerspective: number;
  17537. protected _source: AbstractMesh;
  17538. protected _linesPositions: number[];
  17539. protected _linesNormals: number[];
  17540. protected _linesIndices: number[];
  17541. protected _epsilon: number;
  17542. protected _indicesCount: number;
  17543. protected _lineShader: ShaderMaterial;
  17544. protected _ib: WebGLBuffer;
  17545. protected _buffers: {
  17546. [key: string]: Nullable<VertexBuffer>;
  17547. };
  17548. protected _checkVerticesInsteadOfIndices: boolean;
  17549. private _meshRebuildObserver;
  17550. private _meshDisposeObserver;
  17551. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17552. isEnabled: boolean;
  17553. /**
  17554. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17555. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17556. * @param source Mesh used to create edges
  17557. * @param epsilon sum of angles in adjacency to check for edge
  17558. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17559. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17560. */
  17561. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17562. protected _prepareRessources(): void;
  17563. /** @hidden */
  17564. _rebuild(): void;
  17565. /**
  17566. * Releases the required resources for the edges renderer
  17567. */
  17568. dispose(): void;
  17569. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17570. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17571. /**
  17572. * Checks if the pair of p0 and p1 is en edge
  17573. * @param faceIndex
  17574. * @param edge
  17575. * @param faceNormals
  17576. * @param p0
  17577. * @param p1
  17578. * @private
  17579. */
  17580. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17581. /**
  17582. * push line into the position, normal and index buffer
  17583. * @protected
  17584. */
  17585. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17586. /**
  17587. * Generates lines edges from adjacencjes
  17588. * @private
  17589. */
  17590. _generateEdgesLines(): void;
  17591. /**
  17592. * Checks wether or not the edges renderer is ready to render.
  17593. * @return true if ready, otherwise false.
  17594. */
  17595. isReady(): boolean;
  17596. /**
  17597. * Renders the edges of the attached mesh,
  17598. */
  17599. render(): void;
  17600. }
  17601. /**
  17602. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17603. */
  17604. export class LineEdgesRenderer extends EdgesRenderer {
  17605. /**
  17606. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17607. * @param source LineMesh used to generate edges
  17608. * @param epsilon not important (specified angle for edge detection)
  17609. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17610. */
  17611. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17612. /**
  17613. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17614. */
  17615. _generateEdgesLines(): void;
  17616. }
  17617. }
  17618. declare module "babylonjs/Rendering/renderingGroup" {
  17619. import { SmartArray } from "babylonjs/Misc/smartArray";
  17620. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17622. import { Nullable } from "babylonjs/types";
  17623. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17624. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17625. import { Material } from "babylonjs/Materials/material";
  17626. import { Scene } from "babylonjs/scene";
  17627. /**
  17628. * This represents the object necessary to create a rendering group.
  17629. * This is exclusively used and created by the rendering manager.
  17630. * To modify the behavior, you use the available helpers in your scene or meshes.
  17631. * @hidden
  17632. */
  17633. export class RenderingGroup {
  17634. index: number;
  17635. private _scene;
  17636. private _opaqueSubMeshes;
  17637. private _transparentSubMeshes;
  17638. private _alphaTestSubMeshes;
  17639. private _depthOnlySubMeshes;
  17640. private _particleSystems;
  17641. private _spriteManagers;
  17642. private _opaqueSortCompareFn;
  17643. private _alphaTestSortCompareFn;
  17644. private _transparentSortCompareFn;
  17645. private _renderOpaque;
  17646. private _renderAlphaTest;
  17647. private _renderTransparent;
  17648. private _edgesRenderers;
  17649. onBeforeTransparentRendering: () => void;
  17650. /**
  17651. * Set the opaque sort comparison function.
  17652. * If null the sub meshes will be render in the order they were created
  17653. */
  17654. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17655. /**
  17656. * Set the alpha test sort comparison function.
  17657. * If null the sub meshes will be render in the order they were created
  17658. */
  17659. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17660. /**
  17661. * Set the transparent sort comparison function.
  17662. * If null the sub meshes will be render in the order they were created
  17663. */
  17664. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17665. /**
  17666. * Creates a new rendering group.
  17667. * @param index The rendering group index
  17668. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17669. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17670. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17671. */
  17672. 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>);
  17673. /**
  17674. * Render all the sub meshes contained in the group.
  17675. * @param customRenderFunction Used to override the default render behaviour of the group.
  17676. * @returns true if rendered some submeshes.
  17677. */
  17678. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17679. /**
  17680. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17681. * @param subMeshes The submeshes to render
  17682. */
  17683. private renderOpaqueSorted;
  17684. /**
  17685. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17686. * @param subMeshes The submeshes to render
  17687. */
  17688. private renderAlphaTestSorted;
  17689. /**
  17690. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17691. * @param subMeshes The submeshes to render
  17692. */
  17693. private renderTransparentSorted;
  17694. /**
  17695. * Renders the submeshes in a specified order.
  17696. * @param subMeshes The submeshes to sort before render
  17697. * @param sortCompareFn The comparison function use to sort
  17698. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17699. * @param transparent Specifies to activate blending if true
  17700. */
  17701. private static renderSorted;
  17702. /**
  17703. * Renders the submeshes in the order they were dispatched (no sort applied).
  17704. * @param subMeshes The submeshes to render
  17705. */
  17706. private static renderUnsorted;
  17707. /**
  17708. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17709. * are rendered back to front if in the same alpha index.
  17710. *
  17711. * @param a The first submesh
  17712. * @param b The second submesh
  17713. * @returns The result of the comparison
  17714. */
  17715. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17716. /**
  17717. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17718. * are rendered back to front.
  17719. *
  17720. * @param a The first submesh
  17721. * @param b The second submesh
  17722. * @returns The result of the comparison
  17723. */
  17724. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17725. /**
  17726. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17727. * are rendered front to back (prevent overdraw).
  17728. *
  17729. * @param a The first submesh
  17730. * @param b The second submesh
  17731. * @returns The result of the comparison
  17732. */
  17733. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17734. /**
  17735. * Resets the different lists of submeshes to prepare a new frame.
  17736. */
  17737. prepare(): void;
  17738. dispose(): void;
  17739. /**
  17740. * Inserts the submesh in its correct queue depending on its material.
  17741. * @param subMesh The submesh to dispatch
  17742. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17743. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17744. */
  17745. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17746. dispatchSprites(spriteManager: ISpriteManager): void;
  17747. dispatchParticles(particleSystem: IParticleSystem): void;
  17748. private _renderParticles;
  17749. private _renderSprites;
  17750. }
  17751. }
  17752. declare module "babylonjs/Rendering/renderingManager" {
  17753. import { Nullable } from "babylonjs/types";
  17754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17755. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17756. import { SmartArray } from "babylonjs/Misc/smartArray";
  17757. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17758. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17759. import { Material } from "babylonjs/Materials/material";
  17760. import { Scene } from "babylonjs/scene";
  17761. import { Camera } from "babylonjs/Cameras/camera";
  17762. /**
  17763. * Interface describing the different options available in the rendering manager
  17764. * regarding Auto Clear between groups.
  17765. */
  17766. export interface IRenderingManagerAutoClearSetup {
  17767. /**
  17768. * Defines whether or not autoclear is enable.
  17769. */
  17770. autoClear: boolean;
  17771. /**
  17772. * Defines whether or not to autoclear the depth buffer.
  17773. */
  17774. depth: boolean;
  17775. /**
  17776. * Defines whether or not to autoclear the stencil buffer.
  17777. */
  17778. stencil: boolean;
  17779. }
  17780. /**
  17781. * This class is used by the onRenderingGroupObservable
  17782. */
  17783. export class RenderingGroupInfo {
  17784. /**
  17785. * The Scene that being rendered
  17786. */
  17787. scene: Scene;
  17788. /**
  17789. * The camera currently used for the rendering pass
  17790. */
  17791. camera: Nullable<Camera>;
  17792. /**
  17793. * The ID of the renderingGroup being processed
  17794. */
  17795. renderingGroupId: number;
  17796. }
  17797. /**
  17798. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17799. * It is enable to manage the different groups as well as the different necessary sort functions.
  17800. * This should not be used directly aside of the few static configurations
  17801. */
  17802. export class RenderingManager {
  17803. /**
  17804. * The max id used for rendering groups (not included)
  17805. */
  17806. static MAX_RENDERINGGROUPS: number;
  17807. /**
  17808. * The min id used for rendering groups (included)
  17809. */
  17810. static MIN_RENDERINGGROUPS: number;
  17811. /**
  17812. * Used to globally prevent autoclearing scenes.
  17813. */
  17814. static AUTOCLEAR: boolean;
  17815. /**
  17816. * @hidden
  17817. */
  17818. _useSceneAutoClearSetup: boolean;
  17819. private _scene;
  17820. private _renderingGroups;
  17821. private _depthStencilBufferAlreadyCleaned;
  17822. private _autoClearDepthStencil;
  17823. private _customOpaqueSortCompareFn;
  17824. private _customAlphaTestSortCompareFn;
  17825. private _customTransparentSortCompareFn;
  17826. private _renderingGroupInfo;
  17827. /**
  17828. * Instantiates a new rendering group for a particular scene
  17829. * @param scene Defines the scene the groups belongs to
  17830. */
  17831. constructor(scene: Scene);
  17832. private _clearDepthStencilBuffer;
  17833. /**
  17834. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17835. * @hidden
  17836. */
  17837. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17838. /**
  17839. * Resets the different information of the group to prepare a new frame
  17840. * @hidden
  17841. */
  17842. reset(): void;
  17843. /**
  17844. * Dispose and release the group and its associated resources.
  17845. * @hidden
  17846. */
  17847. dispose(): void;
  17848. /**
  17849. * Clear the info related to rendering groups preventing retention points during dispose.
  17850. */
  17851. freeRenderingGroups(): void;
  17852. private _prepareRenderingGroup;
  17853. /**
  17854. * Add a sprite manager to the rendering manager in order to render it this frame.
  17855. * @param spriteManager Define the sprite manager to render
  17856. */
  17857. dispatchSprites(spriteManager: ISpriteManager): void;
  17858. /**
  17859. * Add a particle system to the rendering manager in order to render it this frame.
  17860. * @param particleSystem Define the particle system to render
  17861. */
  17862. dispatchParticles(particleSystem: IParticleSystem): void;
  17863. /**
  17864. * Add a submesh to the manager in order to render it this frame
  17865. * @param subMesh The submesh to dispatch
  17866. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17867. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17868. */
  17869. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17870. /**
  17871. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17872. * This allowed control for front to back rendering or reversly depending of the special needs.
  17873. *
  17874. * @param renderingGroupId The rendering group id corresponding to its index
  17875. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17876. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17877. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17878. */
  17879. 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;
  17880. /**
  17881. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17882. *
  17883. * @param renderingGroupId The rendering group id corresponding to its index
  17884. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17885. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17886. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17887. */
  17888. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17889. /**
  17890. * Gets the current auto clear configuration for one rendering group of the rendering
  17891. * manager.
  17892. * @param index the rendering group index to get the information for
  17893. * @returns The auto clear setup for the requested rendering group
  17894. */
  17895. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17896. }
  17897. }
  17898. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17899. import { Observable } from "babylonjs/Misc/observable";
  17900. import { SmartArray } from "babylonjs/Misc/smartArray";
  17901. import { Nullable } from "babylonjs/types";
  17902. import { Camera } from "babylonjs/Cameras/camera";
  17903. import { Scene } from "babylonjs/scene";
  17904. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17905. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17907. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17908. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17909. import { Texture } from "babylonjs/Materials/Textures/texture";
  17910. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17911. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17912. import { Engine } from "babylonjs/Engines/engine";
  17913. /**
  17914. * This Helps creating a texture that will be created from a camera in your scene.
  17915. * It is basically a dynamic texture that could be used to create special effects for instance.
  17916. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17917. */
  17918. export class RenderTargetTexture extends Texture {
  17919. isCube: boolean;
  17920. /**
  17921. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17922. */
  17923. static readonly REFRESHRATE_RENDER_ONCE: number;
  17924. /**
  17925. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17926. */
  17927. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17928. /**
  17929. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17930. * the central point of your effect and can save a lot of performances.
  17931. */
  17932. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17933. /**
  17934. * Use this predicate to dynamically define the list of mesh you want to render.
  17935. * If set, the renderList property will be overwritten.
  17936. */
  17937. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17938. private _renderList;
  17939. /**
  17940. * Use this list to define the list of mesh you want to render.
  17941. */
  17942. renderList: Nullable<Array<AbstractMesh>>;
  17943. private _hookArray;
  17944. /**
  17945. * Define if particles should be rendered in your texture.
  17946. */
  17947. renderParticles: boolean;
  17948. /**
  17949. * Define if sprites should be rendered in your texture.
  17950. */
  17951. renderSprites: boolean;
  17952. /**
  17953. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17954. */
  17955. coordinatesMode: number;
  17956. /**
  17957. * Define the camera used to render the texture.
  17958. */
  17959. activeCamera: Nullable<Camera>;
  17960. /**
  17961. * Override the render function of the texture with your own one.
  17962. */
  17963. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17964. /**
  17965. * Define if camera post processes should be use while rendering the texture.
  17966. */
  17967. useCameraPostProcesses: boolean;
  17968. /**
  17969. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17970. */
  17971. ignoreCameraViewport: boolean;
  17972. private _postProcessManager;
  17973. private _postProcesses;
  17974. private _resizeObserver;
  17975. /**
  17976. * An event triggered when the texture is unbind.
  17977. */
  17978. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17979. /**
  17980. * An event triggered when the texture is unbind.
  17981. */
  17982. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17983. private _onAfterUnbindObserver;
  17984. /**
  17985. * Set a after unbind callback in the texture.
  17986. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17987. */
  17988. onAfterUnbind: () => void;
  17989. /**
  17990. * An event triggered before rendering the texture
  17991. */
  17992. onBeforeRenderObservable: Observable<number>;
  17993. private _onBeforeRenderObserver;
  17994. /**
  17995. * Set a before render callback in the texture.
  17996. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17997. */
  17998. onBeforeRender: (faceIndex: number) => void;
  17999. /**
  18000. * An event triggered after rendering the texture
  18001. */
  18002. onAfterRenderObservable: Observable<number>;
  18003. private _onAfterRenderObserver;
  18004. /**
  18005. * Set a after render callback in the texture.
  18006. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18007. */
  18008. onAfterRender: (faceIndex: number) => void;
  18009. /**
  18010. * An event triggered after the texture clear
  18011. */
  18012. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18013. private _onClearObserver;
  18014. /**
  18015. * Set a clear callback in the texture.
  18016. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18017. */
  18018. onClear: (Engine: Engine) => void;
  18019. /**
  18020. * Define the clear color of the Render Target if it should be different from the scene.
  18021. */
  18022. clearColor: Color4;
  18023. protected _size: number | {
  18024. width: number;
  18025. height: number;
  18026. };
  18027. protected _initialSizeParameter: number | {
  18028. width: number;
  18029. height: number;
  18030. } | {
  18031. ratio: number;
  18032. };
  18033. protected _sizeRatio: Nullable<number>;
  18034. /** @hidden */
  18035. _generateMipMaps: boolean;
  18036. protected _renderingManager: RenderingManager;
  18037. /** @hidden */
  18038. _waitingRenderList: string[];
  18039. protected _doNotChangeAspectRatio: boolean;
  18040. protected _currentRefreshId: number;
  18041. protected _refreshRate: number;
  18042. protected _textureMatrix: Matrix;
  18043. protected _samples: number;
  18044. protected _renderTargetOptions: RenderTargetCreationOptions;
  18045. /**
  18046. * Gets render target creation options that were used.
  18047. */
  18048. readonly renderTargetOptions: RenderTargetCreationOptions;
  18049. protected _engine: Engine;
  18050. protected _onRatioRescale(): void;
  18051. /**
  18052. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18053. * It must define where the camera used to render the texture is set
  18054. */
  18055. boundingBoxPosition: Vector3;
  18056. private _boundingBoxSize;
  18057. /**
  18058. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18059. * When defined, the cubemap will switch to local mode
  18060. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18061. * @example https://www.babylonjs-playground.com/#RNASML
  18062. */
  18063. boundingBoxSize: Vector3;
  18064. /**
  18065. * In case the RTT has been created with a depth texture, get the associated
  18066. * depth texture.
  18067. * Otherwise, return null.
  18068. */
  18069. depthStencilTexture: Nullable<InternalTexture>;
  18070. /**
  18071. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18072. * or used a shadow, depth texture...
  18073. * @param name The friendly name of the texture
  18074. * @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)
  18075. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18076. * @param generateMipMaps True if mip maps need to be generated after render.
  18077. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18078. * @param type The type of the buffer in the RTT (int, half float, float...)
  18079. * @param isCube True if a cube texture needs to be created
  18080. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18081. * @param generateDepthBuffer True to generate a depth buffer
  18082. * @param generateStencilBuffer True to generate a stencil buffer
  18083. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18084. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18085. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18086. */
  18087. constructor(name: string, size: number | {
  18088. width: number;
  18089. height: number;
  18090. } | {
  18091. ratio: number;
  18092. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18093. /**
  18094. * Creates a depth stencil texture.
  18095. * This is only available in WebGL 2 or with the depth texture extension available.
  18096. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18097. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18098. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18099. */
  18100. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18101. private _processSizeParameter;
  18102. /**
  18103. * Define the number of samples to use in case of MSAA.
  18104. * It defaults to one meaning no MSAA has been enabled.
  18105. */
  18106. samples: number;
  18107. /**
  18108. * Resets the refresh counter of the texture and start bak from scratch.
  18109. * Could be useful to regenerate the texture if it is setup to render only once.
  18110. */
  18111. resetRefreshCounter(): void;
  18112. /**
  18113. * Define the refresh rate of the texture or the rendering frequency.
  18114. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18115. */
  18116. refreshRate: number;
  18117. /**
  18118. * Adds a post process to the render target rendering passes.
  18119. * @param postProcess define the post process to add
  18120. */
  18121. addPostProcess(postProcess: PostProcess): void;
  18122. /**
  18123. * Clear all the post processes attached to the render target
  18124. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18125. */
  18126. clearPostProcesses(dispose?: boolean): void;
  18127. /**
  18128. * Remove one of the post process from the list of attached post processes to the texture
  18129. * @param postProcess define the post process to remove from the list
  18130. */
  18131. removePostProcess(postProcess: PostProcess): void;
  18132. /** @hidden */
  18133. _shouldRender(): boolean;
  18134. /**
  18135. * Gets the actual render size of the texture.
  18136. * @returns the width of the render size
  18137. */
  18138. getRenderSize(): number;
  18139. /**
  18140. * Gets the actual render width of the texture.
  18141. * @returns the width of the render size
  18142. */
  18143. getRenderWidth(): number;
  18144. /**
  18145. * Gets the actual render height of the texture.
  18146. * @returns the height of the render size
  18147. */
  18148. getRenderHeight(): number;
  18149. /**
  18150. * Get if the texture can be rescaled or not.
  18151. */
  18152. readonly canRescale: boolean;
  18153. /**
  18154. * Resize the texture using a ratio.
  18155. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18156. */
  18157. scale(ratio: number): void;
  18158. /**
  18159. * Get the texture reflection matrix used to rotate/transform the reflection.
  18160. * @returns the reflection matrix
  18161. */
  18162. getReflectionTextureMatrix(): Matrix;
  18163. /**
  18164. * Resize the texture to a new desired size.
  18165. * Be carrefull as it will recreate all the data in the new texture.
  18166. * @param size Define the new size. It can be:
  18167. * - a number for squared texture,
  18168. * - an object containing { width: number, height: number }
  18169. * - or an object containing a ratio { ratio: number }
  18170. */
  18171. resize(size: number | {
  18172. width: number;
  18173. height: number;
  18174. } | {
  18175. ratio: number;
  18176. }): void;
  18177. /**
  18178. * Renders all the objects from the render list into the texture.
  18179. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18180. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18181. */
  18182. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18183. private _bestReflectionRenderTargetDimension;
  18184. /**
  18185. * @hidden
  18186. * @param faceIndex face index to bind to if this is a cubetexture
  18187. */
  18188. _bindFrameBuffer(faceIndex?: number): void;
  18189. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18190. private renderToTarget;
  18191. /**
  18192. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18193. * This allowed control for front to back rendering or reversly depending of the special needs.
  18194. *
  18195. * @param renderingGroupId The rendering group id corresponding to its index
  18196. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18197. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18198. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18199. */
  18200. 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;
  18201. /**
  18202. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18203. *
  18204. * @param renderingGroupId The rendering group id corresponding to its index
  18205. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18206. */
  18207. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18208. /**
  18209. * Clones the texture.
  18210. * @returns the cloned texture
  18211. */
  18212. clone(): RenderTargetTexture;
  18213. /**
  18214. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18215. * @returns The JSON representation of the texture
  18216. */
  18217. serialize(): any;
  18218. /**
  18219. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18220. */
  18221. disposeFramebufferObjects(): void;
  18222. /**
  18223. * Dispose the texture and release its associated resources.
  18224. */
  18225. dispose(): void;
  18226. /** @hidden */
  18227. _rebuild(): void;
  18228. /**
  18229. * Clear the info related to rendering groups preventing retention point in material dispose.
  18230. */
  18231. freeRenderingGroups(): void;
  18232. /**
  18233. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18234. * @returns the view count
  18235. */
  18236. getViewCount(): number;
  18237. }
  18238. }
  18239. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18240. import { Scene } from "babylonjs/scene";
  18241. import { Plane } from "babylonjs/Maths/math";
  18242. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18243. /**
  18244. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18245. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18246. * You can then easily use it as a reflectionTexture on a flat surface.
  18247. * In case the surface is not a plane, please consider relying on reflection probes.
  18248. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18249. */
  18250. export class MirrorTexture extends RenderTargetTexture {
  18251. private scene;
  18252. /**
  18253. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18254. * 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.
  18255. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18256. */
  18257. mirrorPlane: Plane;
  18258. /**
  18259. * Define the blur ratio used to blur the reflection if needed.
  18260. */
  18261. blurRatio: number;
  18262. /**
  18263. * Define the adaptive blur kernel used to blur the reflection if needed.
  18264. * This will autocompute the closest best match for the `blurKernel`
  18265. */
  18266. adaptiveBlurKernel: number;
  18267. /**
  18268. * Define the blur kernel used to blur the reflection if needed.
  18269. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18270. */
  18271. blurKernel: number;
  18272. /**
  18273. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18274. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18275. */
  18276. blurKernelX: number;
  18277. /**
  18278. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18279. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18280. */
  18281. blurKernelY: number;
  18282. private _autoComputeBlurKernel;
  18283. protected _onRatioRescale(): void;
  18284. private _updateGammaSpace;
  18285. private _imageProcessingConfigChangeObserver;
  18286. private _transformMatrix;
  18287. private _mirrorMatrix;
  18288. private _savedViewMatrix;
  18289. private _blurX;
  18290. private _blurY;
  18291. private _adaptiveBlurKernel;
  18292. private _blurKernelX;
  18293. private _blurKernelY;
  18294. private _blurRatio;
  18295. /**
  18296. * Instantiates a Mirror Texture.
  18297. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18298. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18299. * You can then easily use it as a reflectionTexture on a flat surface.
  18300. * In case the surface is not a plane, please consider relying on reflection probes.
  18301. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18302. * @param name
  18303. * @param size
  18304. * @param scene
  18305. * @param generateMipMaps
  18306. * @param type
  18307. * @param samplingMode
  18308. * @param generateDepthBuffer
  18309. */
  18310. constructor(name: string, size: number | {
  18311. width: number;
  18312. height: number;
  18313. } | {
  18314. ratio: number;
  18315. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18316. private _preparePostProcesses;
  18317. /**
  18318. * Clone the mirror texture.
  18319. * @returns the cloned texture
  18320. */
  18321. clone(): MirrorTexture;
  18322. /**
  18323. * Serialize the texture to a JSON representation you could use in Parse later on
  18324. * @returns the serialized JSON representation
  18325. */
  18326. serialize(): any;
  18327. /**
  18328. * Dispose the texture and release its associated resources.
  18329. */
  18330. dispose(): void;
  18331. }
  18332. }
  18333. declare module "babylonjs/Materials/Textures/texture" {
  18334. import { Observable } from "babylonjs/Misc/observable";
  18335. import { Nullable } from "babylonjs/types";
  18336. import { Scene } from "babylonjs/scene";
  18337. import { Matrix } from "babylonjs/Maths/math";
  18338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18339. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18340. /**
  18341. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18342. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18343. */
  18344. export class Texture extends BaseTexture {
  18345. /** @hidden */
  18346. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18347. /** @hidden */
  18348. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18349. /** @hidden */
  18350. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18351. /** nearest is mag = nearest and min = nearest and mip = linear */
  18352. static readonly NEAREST_SAMPLINGMODE: number;
  18353. /** nearest is mag = nearest and min = nearest and mip = linear */
  18354. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18355. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18356. static readonly BILINEAR_SAMPLINGMODE: number;
  18357. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18358. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18359. /** Trilinear is mag = linear and min = linear and mip = linear */
  18360. static readonly TRILINEAR_SAMPLINGMODE: number;
  18361. /** Trilinear is mag = linear and min = linear and mip = linear */
  18362. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18363. /** mag = nearest and min = nearest and mip = nearest */
  18364. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18365. /** mag = nearest and min = linear and mip = nearest */
  18366. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18367. /** mag = nearest and min = linear and mip = linear */
  18368. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18369. /** mag = nearest and min = linear and mip = none */
  18370. static readonly NEAREST_LINEAR: number;
  18371. /** mag = nearest and min = nearest and mip = none */
  18372. static readonly NEAREST_NEAREST: number;
  18373. /** mag = linear and min = nearest and mip = nearest */
  18374. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18375. /** mag = linear and min = nearest and mip = linear */
  18376. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18377. /** mag = linear and min = linear and mip = none */
  18378. static readonly LINEAR_LINEAR: number;
  18379. /** mag = linear and min = nearest and mip = none */
  18380. static readonly LINEAR_NEAREST: number;
  18381. /** Explicit coordinates mode */
  18382. static readonly EXPLICIT_MODE: number;
  18383. /** Spherical coordinates mode */
  18384. static readonly SPHERICAL_MODE: number;
  18385. /** Planar coordinates mode */
  18386. static readonly PLANAR_MODE: number;
  18387. /** Cubic coordinates mode */
  18388. static readonly CUBIC_MODE: number;
  18389. /** Projection coordinates mode */
  18390. static readonly PROJECTION_MODE: number;
  18391. /** Inverse Cubic coordinates mode */
  18392. static readonly SKYBOX_MODE: number;
  18393. /** Inverse Cubic coordinates mode */
  18394. static readonly INVCUBIC_MODE: number;
  18395. /** Equirectangular coordinates mode */
  18396. static readonly EQUIRECTANGULAR_MODE: number;
  18397. /** Equirectangular Fixed coordinates mode */
  18398. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18399. /** Equirectangular Fixed Mirrored coordinates mode */
  18400. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18401. /** Texture is not repeating outside of 0..1 UVs */
  18402. static readonly CLAMP_ADDRESSMODE: number;
  18403. /** Texture is repeating outside of 0..1 UVs */
  18404. static readonly WRAP_ADDRESSMODE: number;
  18405. /** Texture is repeating and mirrored */
  18406. static readonly MIRROR_ADDRESSMODE: number;
  18407. /**
  18408. * 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
  18409. */
  18410. static UseSerializedUrlIfAny: boolean;
  18411. /**
  18412. * Define the url of the texture.
  18413. */
  18414. url: Nullable<string>;
  18415. /**
  18416. * Define an offset on the texture to offset the u coordinates of the UVs
  18417. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18418. */
  18419. uOffset: number;
  18420. /**
  18421. * Define an offset on the texture to offset the v coordinates of the UVs
  18422. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18423. */
  18424. vOffset: number;
  18425. /**
  18426. * Define an offset on the texture to scale the u coordinates of the UVs
  18427. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18428. */
  18429. uScale: number;
  18430. /**
  18431. * Define an offset on the texture to scale the v coordinates of the UVs
  18432. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18433. */
  18434. vScale: number;
  18435. /**
  18436. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18437. * @see http://doc.babylonjs.com/how_to/more_materials
  18438. */
  18439. uAng: number;
  18440. /**
  18441. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18442. * @see http://doc.babylonjs.com/how_to/more_materials
  18443. */
  18444. vAng: number;
  18445. /**
  18446. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18447. * @see http://doc.babylonjs.com/how_to/more_materials
  18448. */
  18449. wAng: number;
  18450. /**
  18451. * Defines the center of rotation (U)
  18452. */
  18453. uRotationCenter: number;
  18454. /**
  18455. * Defines the center of rotation (V)
  18456. */
  18457. vRotationCenter: number;
  18458. /**
  18459. * Defines the center of rotation (W)
  18460. */
  18461. wRotationCenter: number;
  18462. /**
  18463. * Are mip maps generated for this texture or not.
  18464. */
  18465. readonly noMipmap: boolean;
  18466. /**
  18467. * List of inspectable custom properties (used by the Inspector)
  18468. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18469. */
  18470. inspectableCustomProperties: IInspectable[];
  18471. private _noMipmap;
  18472. /** @hidden */
  18473. _invertY: boolean;
  18474. private _rowGenerationMatrix;
  18475. private _cachedTextureMatrix;
  18476. private _projectionModeMatrix;
  18477. private _t0;
  18478. private _t1;
  18479. private _t2;
  18480. private _cachedUOffset;
  18481. private _cachedVOffset;
  18482. private _cachedUScale;
  18483. private _cachedVScale;
  18484. private _cachedUAng;
  18485. private _cachedVAng;
  18486. private _cachedWAng;
  18487. private _cachedProjectionMatrixId;
  18488. private _cachedCoordinatesMode;
  18489. /** @hidden */
  18490. protected _initialSamplingMode: number;
  18491. /** @hidden */
  18492. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18493. private _deleteBuffer;
  18494. protected _format: Nullable<number>;
  18495. private _delayedOnLoad;
  18496. private _delayedOnError;
  18497. /**
  18498. * Observable triggered once the texture has been loaded.
  18499. */
  18500. onLoadObservable: Observable<Texture>;
  18501. protected _isBlocking: boolean;
  18502. /**
  18503. * Is the texture preventing material to render while loading.
  18504. * If false, a default texture will be used instead of the loading one during the preparation step.
  18505. */
  18506. isBlocking: boolean;
  18507. /**
  18508. * Get the current sampling mode associated with the texture.
  18509. */
  18510. readonly samplingMode: number;
  18511. /**
  18512. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18513. */
  18514. readonly invertY: boolean;
  18515. /**
  18516. * Instantiates a new texture.
  18517. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18518. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18519. * @param url define the url of the picture to load as a texture
  18520. * @param scene define the scene the texture will belong to
  18521. * @param noMipmap define if the texture will require mip maps or not
  18522. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18523. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18524. * @param onLoad define a callback triggered when the texture has been loaded
  18525. * @param onError define a callback triggered when an error occurred during the loading session
  18526. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18527. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18528. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18529. */
  18530. 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);
  18531. /**
  18532. * Update the url (and optional buffer) of this texture if url was null during construction.
  18533. * @param url the url of the texture
  18534. * @param buffer the buffer of the texture (defaults to null)
  18535. * @param onLoad callback called when the texture is loaded (defaults to null)
  18536. */
  18537. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18538. /**
  18539. * Finish the loading sequence of a texture flagged as delayed load.
  18540. * @hidden
  18541. */
  18542. delayLoad(): void;
  18543. private _prepareRowForTextureGeneration;
  18544. /**
  18545. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18546. * @returns the transform matrix of the texture.
  18547. */
  18548. getTextureMatrix(): Matrix;
  18549. /**
  18550. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18551. * @returns The reflection texture transform
  18552. */
  18553. getReflectionTextureMatrix(): Matrix;
  18554. /**
  18555. * Clones the texture.
  18556. * @returns the cloned texture
  18557. */
  18558. clone(): Texture;
  18559. /**
  18560. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18561. * @returns The JSON representation of the texture
  18562. */
  18563. serialize(): any;
  18564. /**
  18565. * Get the current class name of the texture useful for serialization or dynamic coding.
  18566. * @returns "Texture"
  18567. */
  18568. getClassName(): string;
  18569. /**
  18570. * Dispose the texture and release its associated resources.
  18571. */
  18572. dispose(): void;
  18573. /**
  18574. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18575. * @param parsedTexture Define the JSON representation of the texture
  18576. * @param scene Define the scene the parsed texture should be instantiated in
  18577. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18578. * @returns The parsed texture if successful
  18579. */
  18580. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18581. /**
  18582. * Creates a texture from its base 64 representation.
  18583. * @param data Define the base64 payload without the data: prefix
  18584. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18585. * @param scene Define the scene the texture should belong to
  18586. * @param noMipmap Forces the texture to not create mip map information if true
  18587. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18588. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18589. * @param onLoad define a callback triggered when the texture has been loaded
  18590. * @param onError define a callback triggered when an error occurred during the loading session
  18591. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18592. * @returns the created texture
  18593. */
  18594. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18595. /**
  18596. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18597. * @param data Define the base64 payload without the data: prefix
  18598. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18599. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18600. * @param scene Define the scene the texture should belong to
  18601. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18602. * @param noMipmap Forces the texture to not create mip map information if true
  18603. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18604. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18605. * @param onLoad define a callback triggered when the texture has been loaded
  18606. * @param onError define a callback triggered when an error occurred during the loading session
  18607. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18608. * @returns the created texture
  18609. */
  18610. 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;
  18611. }
  18612. }
  18613. declare module "babylonjs/Materials/Textures/rawTexture" {
  18614. import { Scene } from "babylonjs/scene";
  18615. import { Texture } from "babylonjs/Materials/Textures/texture";
  18616. /**
  18617. * Raw texture can help creating a texture directly from an array of data.
  18618. * This can be super useful if you either get the data from an uncompressed source or
  18619. * if you wish to create your texture pixel by pixel.
  18620. */
  18621. export class RawTexture extends Texture {
  18622. /**
  18623. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18624. */
  18625. format: number;
  18626. private _engine;
  18627. /**
  18628. * Instantiates a new RawTexture.
  18629. * Raw texture can help creating a texture directly from an array of data.
  18630. * This can be super useful if you either get the data from an uncompressed source or
  18631. * if you wish to create your texture pixel by pixel.
  18632. * @param data define the array of data to use to create the texture
  18633. * @param width define the width of the texture
  18634. * @param height define the height of the texture
  18635. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18636. * @param scene define the scene the texture belongs to
  18637. * @param generateMipMaps define whether mip maps should be generated or not
  18638. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18639. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18640. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18641. */
  18642. constructor(data: ArrayBufferView, width: number, height: number,
  18643. /**
  18644. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18645. */
  18646. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18647. /**
  18648. * Updates the texture underlying data.
  18649. * @param data Define the new data of the texture
  18650. */
  18651. update(data: ArrayBufferView): void;
  18652. /**
  18653. * Creates a luminance texture from some data.
  18654. * @param data Define the texture data
  18655. * @param width Define the width of the texture
  18656. * @param height Define the height of the texture
  18657. * @param scene Define the scene the texture belongs to
  18658. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18659. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18660. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18661. * @returns the luminance texture
  18662. */
  18663. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18664. /**
  18665. * Creates a luminance alpha texture from some data.
  18666. * @param data Define the texture data
  18667. * @param width Define the width of the texture
  18668. * @param height Define the height of the texture
  18669. * @param scene Define the scene the texture belongs to
  18670. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18671. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18672. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18673. * @returns the luminance alpha texture
  18674. */
  18675. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18676. /**
  18677. * Creates an alpha texture from some data.
  18678. * @param data Define the texture data
  18679. * @param width Define the width of the texture
  18680. * @param height Define the height of the texture
  18681. * @param scene Define the scene the texture belongs to
  18682. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18683. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18684. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18685. * @returns the alpha texture
  18686. */
  18687. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18688. /**
  18689. * Creates a RGB texture from some data.
  18690. * @param data Define the texture data
  18691. * @param width Define the width of the texture
  18692. * @param height Define the height of the texture
  18693. * @param scene Define the scene the texture belongs to
  18694. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18695. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18696. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18697. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18698. * @returns the RGB alpha texture
  18699. */
  18700. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18701. /**
  18702. * Creates a RGBA texture from some data.
  18703. * @param data Define the texture data
  18704. * @param width Define the width of the texture
  18705. * @param height Define the height of the texture
  18706. * @param scene Define the scene the texture belongs to
  18707. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18708. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18709. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18710. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18711. * @returns the RGBA texture
  18712. */
  18713. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18714. /**
  18715. * Creates a R texture from some data.
  18716. * @param data Define the texture data
  18717. * @param width Define the width of the texture
  18718. * @param height Define the height of the texture
  18719. * @param scene Define the scene the texture belongs to
  18720. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18721. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18722. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18723. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18724. * @returns the R texture
  18725. */
  18726. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18727. }
  18728. }
  18729. declare module "babylonjs/Animations/runtimeAnimation" {
  18730. import { Animation } from "babylonjs/Animations/animation";
  18731. import { Animatable } from "babylonjs/Animations/animatable";
  18732. import { Scene } from "babylonjs/scene";
  18733. /**
  18734. * Defines a runtime animation
  18735. */
  18736. export class RuntimeAnimation {
  18737. private _events;
  18738. /**
  18739. * The current frame of the runtime animation
  18740. */
  18741. private _currentFrame;
  18742. /**
  18743. * The animation used by the runtime animation
  18744. */
  18745. private _animation;
  18746. /**
  18747. * The target of the runtime animation
  18748. */
  18749. private _target;
  18750. /**
  18751. * The initiating animatable
  18752. */
  18753. private _host;
  18754. /**
  18755. * The original value of the runtime animation
  18756. */
  18757. private _originalValue;
  18758. /**
  18759. * The original blend value of the runtime animation
  18760. */
  18761. private _originalBlendValue;
  18762. /**
  18763. * The offsets cache of the runtime animation
  18764. */
  18765. private _offsetsCache;
  18766. /**
  18767. * The high limits cache of the runtime animation
  18768. */
  18769. private _highLimitsCache;
  18770. /**
  18771. * Specifies if the runtime animation has been stopped
  18772. */
  18773. private _stopped;
  18774. /**
  18775. * The blending factor of the runtime animation
  18776. */
  18777. private _blendingFactor;
  18778. /**
  18779. * The BabylonJS scene
  18780. */
  18781. private _scene;
  18782. /**
  18783. * The current value of the runtime animation
  18784. */
  18785. private _currentValue;
  18786. /** @hidden */
  18787. _workValue: any;
  18788. /**
  18789. * The active target of the runtime animation
  18790. */
  18791. private _activeTarget;
  18792. /**
  18793. * The target path of the runtime animation
  18794. */
  18795. private _targetPath;
  18796. /**
  18797. * The weight of the runtime animation
  18798. */
  18799. private _weight;
  18800. /**
  18801. * The ratio offset of the runtime animation
  18802. */
  18803. private _ratioOffset;
  18804. /**
  18805. * The previous delay of the runtime animation
  18806. */
  18807. private _previousDelay;
  18808. /**
  18809. * The previous ratio of the runtime animation
  18810. */
  18811. private _previousRatio;
  18812. private _enableBlending;
  18813. private _correctLoopMode;
  18814. /**
  18815. * Gets the current frame of the runtime animation
  18816. */
  18817. readonly currentFrame: number;
  18818. /**
  18819. * Gets the weight of the runtime animation
  18820. */
  18821. readonly weight: number;
  18822. /**
  18823. * Gets the current value of the runtime animation
  18824. */
  18825. readonly currentValue: any;
  18826. /**
  18827. * Gets the target path of the runtime animation
  18828. */
  18829. readonly targetPath: string;
  18830. /**
  18831. * Gets the actual target of the runtime animation
  18832. */
  18833. readonly target: any;
  18834. /**
  18835. * Create a new RuntimeAnimation object
  18836. * @param target defines the target of the animation
  18837. * @param animation defines the source animation object
  18838. * @param scene defines the hosting scene
  18839. * @param host defines the initiating Animatable
  18840. */
  18841. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18842. /**
  18843. * Gets the animation from the runtime animation
  18844. */
  18845. readonly animation: Animation;
  18846. /**
  18847. * Resets the runtime animation to the beginning
  18848. * @param restoreOriginal defines whether to restore the target property to the original value
  18849. */
  18850. reset(restoreOriginal?: boolean): void;
  18851. /**
  18852. * Specifies if the runtime animation is stopped
  18853. * @returns Boolean specifying if the runtime animation is stopped
  18854. */
  18855. isStopped(): boolean;
  18856. /**
  18857. * Disposes of the runtime animation
  18858. */
  18859. dispose(): void;
  18860. /**
  18861. * Interpolates the animation from the current frame
  18862. * @param currentFrame The frame to interpolate the animation to
  18863. * @param repeatCount The number of times that the animation should loop
  18864. * @param loopMode The type of looping mode to use
  18865. * @param offsetValue Animation offset value
  18866. * @param highLimitValue The high limit value
  18867. * @returns The interpolated value
  18868. */
  18869. private _interpolate;
  18870. /**
  18871. * Apply the interpolated value to the target
  18872. * @param currentValue defines the value computed by the animation
  18873. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18874. */
  18875. setValue(currentValue: any, weight?: number): void;
  18876. private _setValue;
  18877. /**
  18878. * Gets the loop pmode of the runtime animation
  18879. * @returns Loop Mode
  18880. */
  18881. private _getCorrectLoopMode;
  18882. /**
  18883. * Move the current animation to a given frame
  18884. * @param frame defines the frame to move to
  18885. */
  18886. goToFrame(frame: number): void;
  18887. /**
  18888. * @hidden Internal use only
  18889. */
  18890. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18891. /**
  18892. * Execute the current animation
  18893. * @param delay defines the delay to add to the current frame
  18894. * @param from defines the lower bound of the animation range
  18895. * @param to defines the upper bound of the animation range
  18896. * @param loop defines if the current animation must loop
  18897. * @param speedRatio defines the current speed ratio
  18898. * @param weight defines the weight of the animation (default is -1 so no weight)
  18899. * @param onLoop optional callback called when animation loops
  18900. * @returns a boolean indicating if the animation is running
  18901. */
  18902. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18903. }
  18904. }
  18905. declare module "babylonjs/Animations/animatable" {
  18906. import { Animation } from "babylonjs/Animations/animation";
  18907. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18908. import { Nullable } from "babylonjs/types";
  18909. import { Observable } from "babylonjs/Misc/observable";
  18910. import { Scene } from "babylonjs/scene";
  18911. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18912. import { Node } from "babylonjs/node";
  18913. /**
  18914. * Class used to store an actual running animation
  18915. */
  18916. export class Animatable {
  18917. /** defines the target object */
  18918. target: any;
  18919. /** defines the starting frame number (default is 0) */
  18920. fromFrame: number;
  18921. /** defines the ending frame number (default is 100) */
  18922. toFrame: number;
  18923. /** defines if the animation must loop (default is false) */
  18924. loopAnimation: boolean;
  18925. /** defines a callback to call when animation ends if it is not looping */
  18926. onAnimationEnd?: (() => void) | null | undefined;
  18927. /** defines a callback to call when animation loops */
  18928. onAnimationLoop?: (() => void) | null | undefined;
  18929. private _localDelayOffset;
  18930. private _pausedDelay;
  18931. private _runtimeAnimations;
  18932. private _paused;
  18933. private _scene;
  18934. private _speedRatio;
  18935. private _weight;
  18936. private _syncRoot;
  18937. /**
  18938. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18939. * This will only apply for non looping animation (default is true)
  18940. */
  18941. disposeOnEnd: boolean;
  18942. /**
  18943. * Gets a boolean indicating if the animation has started
  18944. */
  18945. animationStarted: boolean;
  18946. /**
  18947. * Observer raised when the animation ends
  18948. */
  18949. onAnimationEndObservable: Observable<Animatable>;
  18950. /**
  18951. * Observer raised when the animation loops
  18952. */
  18953. onAnimationLoopObservable: Observable<Animatable>;
  18954. /**
  18955. * Gets the root Animatable used to synchronize and normalize animations
  18956. */
  18957. readonly syncRoot: Animatable;
  18958. /**
  18959. * Gets the current frame of the first RuntimeAnimation
  18960. * Used to synchronize Animatables
  18961. */
  18962. readonly masterFrame: number;
  18963. /**
  18964. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18965. */
  18966. weight: number;
  18967. /**
  18968. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18969. */
  18970. speedRatio: number;
  18971. /**
  18972. * Creates a new Animatable
  18973. * @param scene defines the hosting scene
  18974. * @param target defines the target object
  18975. * @param fromFrame defines the starting frame number (default is 0)
  18976. * @param toFrame defines the ending frame number (default is 100)
  18977. * @param loopAnimation defines if the animation must loop (default is false)
  18978. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18979. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18980. * @param animations defines a group of animation to add to the new Animatable
  18981. * @param onAnimationLoop defines a callback to call when animation loops
  18982. */
  18983. constructor(scene: Scene,
  18984. /** defines the target object */
  18985. target: any,
  18986. /** defines the starting frame number (default is 0) */
  18987. fromFrame?: number,
  18988. /** defines the ending frame number (default is 100) */
  18989. toFrame?: number,
  18990. /** defines if the animation must loop (default is false) */
  18991. loopAnimation?: boolean, speedRatio?: number,
  18992. /** defines a callback to call when animation ends if it is not looping */
  18993. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18994. /** defines a callback to call when animation loops */
  18995. onAnimationLoop?: (() => void) | null | undefined);
  18996. /**
  18997. * Synchronize and normalize current Animatable with a source Animatable
  18998. * This is useful when using animation weights and when animations are not of the same length
  18999. * @param root defines the root Animatable to synchronize with
  19000. * @returns the current Animatable
  19001. */
  19002. syncWith(root: Animatable): Animatable;
  19003. /**
  19004. * Gets the list of runtime animations
  19005. * @returns an array of RuntimeAnimation
  19006. */
  19007. getAnimations(): RuntimeAnimation[];
  19008. /**
  19009. * Adds more animations to the current animatable
  19010. * @param target defines the target of the animations
  19011. * @param animations defines the new animations to add
  19012. */
  19013. appendAnimations(target: any, animations: Animation[]): void;
  19014. /**
  19015. * Gets the source animation for a specific property
  19016. * @param property defines the propertyu to look for
  19017. * @returns null or the source animation for the given property
  19018. */
  19019. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19020. /**
  19021. * Gets the runtime animation for a specific property
  19022. * @param property defines the propertyu to look for
  19023. * @returns null or the runtime animation for the given property
  19024. */
  19025. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19026. /**
  19027. * Resets the animatable to its original state
  19028. */
  19029. reset(): void;
  19030. /**
  19031. * Allows the animatable to blend with current running animations
  19032. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19033. * @param blendingSpeed defines the blending speed to use
  19034. */
  19035. enableBlending(blendingSpeed: number): void;
  19036. /**
  19037. * Disable animation blending
  19038. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19039. */
  19040. disableBlending(): void;
  19041. /**
  19042. * Jump directly to a given frame
  19043. * @param frame defines the frame to jump to
  19044. */
  19045. goToFrame(frame: number): void;
  19046. /**
  19047. * Pause the animation
  19048. */
  19049. pause(): void;
  19050. /**
  19051. * Restart the animation
  19052. */
  19053. restart(): void;
  19054. private _raiseOnAnimationEnd;
  19055. /**
  19056. * Stop and delete the current animation
  19057. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19058. * @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)
  19059. */
  19060. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19061. /**
  19062. * Wait asynchronously for the animation to end
  19063. * @returns a promise which will be fullfilled when the animation ends
  19064. */
  19065. waitAsync(): Promise<Animatable>;
  19066. /** @hidden */
  19067. _animate(delay: number): boolean;
  19068. }
  19069. module "babylonjs/scene" {
  19070. interface Scene {
  19071. /** @hidden */
  19072. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19073. /** @hidden */
  19074. _processLateAnimationBindingsForMatrices(holder: {
  19075. totalWeight: number;
  19076. animations: RuntimeAnimation[];
  19077. originalValue: Matrix;
  19078. }): any;
  19079. /** @hidden */
  19080. _processLateAnimationBindingsForQuaternions(holder: {
  19081. totalWeight: number;
  19082. animations: RuntimeAnimation[];
  19083. originalValue: Quaternion;
  19084. }, refQuaternion: Quaternion): Quaternion;
  19085. /** @hidden */
  19086. _processLateAnimationBindings(): void;
  19087. /**
  19088. * Will start the animation sequence of a given target
  19089. * @param target defines the target
  19090. * @param from defines from which frame should animation start
  19091. * @param to defines until which frame should animation run.
  19092. * @param weight defines the weight to apply to the animation (1.0 by default)
  19093. * @param loop defines if the animation loops
  19094. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19095. * @param onAnimationEnd defines the function to be executed when the animation ends
  19096. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19097. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19098. * @param onAnimationLoop defines the callback to call when an animation loops
  19099. * @returns the animatable object created for this animation
  19100. */
  19101. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19102. /**
  19103. * Will start the animation sequence of a given target
  19104. * @param target defines the target
  19105. * @param from defines from which frame should animation start
  19106. * @param to defines until which frame should animation run.
  19107. * @param loop defines if the animation loops
  19108. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19109. * @param onAnimationEnd defines the function to be executed when the animation ends
  19110. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19111. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19112. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19113. * @param onAnimationLoop defines the callback to call when an animation loops
  19114. * @returns the animatable object created for this animation
  19115. */
  19116. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19117. /**
  19118. * Will start the animation sequence of a given target and its hierarchy
  19119. * @param target defines the target
  19120. * @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.
  19121. * @param from defines from which frame should animation start
  19122. * @param to defines until which frame should animation run.
  19123. * @param loop defines if the animation loops
  19124. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19125. * @param onAnimationEnd defines the function to be executed when the animation ends
  19126. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19127. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19128. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19129. * @param onAnimationLoop defines the callback to call when an animation loops
  19130. * @returns the list of created animatables
  19131. */
  19132. 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[];
  19133. /**
  19134. * Begin a new animation on a given node
  19135. * @param target defines the target where the animation will take place
  19136. * @param animations defines the list of animations to start
  19137. * @param from defines the initial value
  19138. * @param to defines the final value
  19139. * @param loop defines if you want animation to loop (off by default)
  19140. * @param speedRatio defines the speed ratio to apply to all animations
  19141. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19142. * @param onAnimationLoop defines the callback to call when an animation loops
  19143. * @returns the list of created animatables
  19144. */
  19145. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19146. /**
  19147. * Begin a new animation on a given node and its hierarchy
  19148. * @param target defines the root node where the animation will take place
  19149. * @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.
  19150. * @param animations defines the list of animations to start
  19151. * @param from defines the initial value
  19152. * @param to defines the final value
  19153. * @param loop defines if you want animation to loop (off by default)
  19154. * @param speedRatio defines the speed ratio to apply to all animations
  19155. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19156. * @param onAnimationLoop defines the callback to call when an animation loops
  19157. * @returns the list of animatables created for all nodes
  19158. */
  19159. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19160. /**
  19161. * Gets the animatable associated with a specific target
  19162. * @param target defines the target of the animatable
  19163. * @returns the required animatable if found
  19164. */
  19165. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19166. /**
  19167. * Gets all animatables associated with a given target
  19168. * @param target defines the target to look animatables for
  19169. * @returns an array of Animatables
  19170. */
  19171. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19172. /**
  19173. * Will stop the animation of the given target
  19174. * @param target - the target
  19175. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19176. * @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)
  19177. */
  19178. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19179. /**
  19180. * Stops and removes all animations that have been applied to the scene
  19181. */
  19182. stopAllAnimations(): void;
  19183. }
  19184. }
  19185. module "babylonjs/Bones/bone" {
  19186. interface Bone {
  19187. /**
  19188. * Copy an animation range from another bone
  19189. * @param source defines the source bone
  19190. * @param rangeName defines the range name to copy
  19191. * @param frameOffset defines the frame offset
  19192. * @param rescaleAsRequired defines if rescaling must be applied if required
  19193. * @param skelDimensionsRatio defines the scaling ratio
  19194. * @returns true if operation was successful
  19195. */
  19196. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19197. }
  19198. }
  19199. }
  19200. declare module "babylonjs/Bones/skeleton" {
  19201. import { Bone } from "babylonjs/Bones/bone";
  19202. import { IAnimatable } from "babylonjs/Misc/tools";
  19203. import { Observable } from "babylonjs/Misc/observable";
  19204. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19205. import { Scene } from "babylonjs/scene";
  19206. import { Nullable } from "babylonjs/types";
  19207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19208. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19209. import { Animatable } from "babylonjs/Animations/animatable";
  19210. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19211. import { Animation } from "babylonjs/Animations/animation";
  19212. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19213. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19214. /**
  19215. * Class used to handle skinning animations
  19216. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19217. */
  19218. export class Skeleton implements IAnimatable {
  19219. /** defines the skeleton name */
  19220. name: string;
  19221. /** defines the skeleton Id */
  19222. id: string;
  19223. /**
  19224. * Defines the list of child bones
  19225. */
  19226. bones: Bone[];
  19227. /**
  19228. * Defines an estimate of the dimension of the skeleton at rest
  19229. */
  19230. dimensionsAtRest: Vector3;
  19231. /**
  19232. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19233. */
  19234. needInitialSkinMatrix: boolean;
  19235. /**
  19236. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19237. */
  19238. overrideMesh: Nullable<AbstractMesh>;
  19239. /**
  19240. * Gets the list of animations attached to this skeleton
  19241. */
  19242. animations: Array<Animation>;
  19243. private _scene;
  19244. private _isDirty;
  19245. private _transformMatrices;
  19246. private _transformMatrixTexture;
  19247. private _meshesWithPoseMatrix;
  19248. private _animatables;
  19249. private _identity;
  19250. private _synchronizedWithMesh;
  19251. private _ranges;
  19252. private _lastAbsoluteTransformsUpdateId;
  19253. private _canUseTextureForBones;
  19254. private _uniqueId;
  19255. /** @hidden */
  19256. _numBonesWithLinkedTransformNode: number;
  19257. /**
  19258. * Specifies if the skeleton should be serialized
  19259. */
  19260. doNotSerialize: boolean;
  19261. private _useTextureToStoreBoneMatrices;
  19262. /**
  19263. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19264. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19265. */
  19266. useTextureToStoreBoneMatrices: boolean;
  19267. private _animationPropertiesOverride;
  19268. /**
  19269. * Gets or sets the animation properties override
  19270. */
  19271. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19272. /**
  19273. * List of inspectable custom properties (used by the Inspector)
  19274. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19275. */
  19276. inspectableCustomProperties: IInspectable[];
  19277. /**
  19278. * An observable triggered before computing the skeleton's matrices
  19279. */
  19280. onBeforeComputeObservable: Observable<Skeleton>;
  19281. /**
  19282. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19283. */
  19284. readonly isUsingTextureForMatrices: boolean;
  19285. /**
  19286. * Gets the unique ID of this skeleton
  19287. */
  19288. readonly uniqueId: number;
  19289. /**
  19290. * Creates a new skeleton
  19291. * @param name defines the skeleton name
  19292. * @param id defines the skeleton Id
  19293. * @param scene defines the hosting scene
  19294. */
  19295. constructor(
  19296. /** defines the skeleton name */
  19297. name: string,
  19298. /** defines the skeleton Id */
  19299. id: string, scene: Scene);
  19300. /**
  19301. * Gets the current object class name.
  19302. * @return the class name
  19303. */
  19304. getClassName(): string;
  19305. /**
  19306. * Returns an array containing the root bones
  19307. * @returns an array containing the root bones
  19308. */
  19309. getChildren(): Array<Bone>;
  19310. /**
  19311. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19312. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19313. * @returns a Float32Array containing matrices data
  19314. */
  19315. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19316. /**
  19317. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19318. * @returns a raw texture containing the data
  19319. */
  19320. getTransformMatrixTexture(): Nullable<RawTexture>;
  19321. /**
  19322. * Gets the current hosting scene
  19323. * @returns a scene object
  19324. */
  19325. getScene(): Scene;
  19326. /**
  19327. * Gets a string representing the current skeleton data
  19328. * @param fullDetails defines a boolean indicating if we want a verbose version
  19329. * @returns a string representing the current skeleton data
  19330. */
  19331. toString(fullDetails?: boolean): string;
  19332. /**
  19333. * Get bone's index searching by name
  19334. * @param name defines bone's name to search for
  19335. * @return the indice of the bone. Returns -1 if not found
  19336. */
  19337. getBoneIndexByName(name: string): number;
  19338. /**
  19339. * Creater a new animation range
  19340. * @param name defines the name of the range
  19341. * @param from defines the start key
  19342. * @param to defines the end key
  19343. */
  19344. createAnimationRange(name: string, from: number, to: number): void;
  19345. /**
  19346. * Delete a specific animation range
  19347. * @param name defines the name of the range
  19348. * @param deleteFrames defines if frames must be removed as well
  19349. */
  19350. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19351. /**
  19352. * Gets a specific animation range
  19353. * @param name defines the name of the range to look for
  19354. * @returns the requested animation range or null if not found
  19355. */
  19356. getAnimationRange(name: string): Nullable<AnimationRange>;
  19357. /**
  19358. * Gets the list of all animation ranges defined on this skeleton
  19359. * @returns an array
  19360. */
  19361. getAnimationRanges(): Nullable<AnimationRange>[];
  19362. /**
  19363. * Copy animation range from a source skeleton.
  19364. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19365. * @param source defines the source skeleton
  19366. * @param name defines the name of the range to copy
  19367. * @param rescaleAsRequired defines if rescaling must be applied if required
  19368. * @returns true if operation was successful
  19369. */
  19370. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19371. /**
  19372. * Forces the skeleton to go to rest pose
  19373. */
  19374. returnToRest(): void;
  19375. private _getHighestAnimationFrame;
  19376. /**
  19377. * Begin a specific animation range
  19378. * @param name defines the name of the range to start
  19379. * @param loop defines if looping must be turned on (false by default)
  19380. * @param speedRatio defines the speed ratio to apply (1 by default)
  19381. * @param onAnimationEnd defines a callback which will be called when animation will end
  19382. * @returns a new animatable
  19383. */
  19384. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19385. /** @hidden */
  19386. _markAsDirty(): void;
  19387. /** @hidden */
  19388. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19389. /** @hidden */
  19390. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19391. private _computeTransformMatrices;
  19392. /**
  19393. * Build all resources required to render a skeleton
  19394. */
  19395. prepare(): void;
  19396. /**
  19397. * Gets the list of animatables currently running for this skeleton
  19398. * @returns an array of animatables
  19399. */
  19400. getAnimatables(): IAnimatable[];
  19401. /**
  19402. * Clone the current skeleton
  19403. * @param name defines the name of the new skeleton
  19404. * @param id defines the id of the enw skeleton
  19405. * @returns the new skeleton
  19406. */
  19407. clone(name: string, id: string): Skeleton;
  19408. /**
  19409. * Enable animation blending for this skeleton
  19410. * @param blendingSpeed defines the blending speed to apply
  19411. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19412. */
  19413. enableBlending(blendingSpeed?: number): void;
  19414. /**
  19415. * Releases all resources associated with the current skeleton
  19416. */
  19417. dispose(): void;
  19418. /**
  19419. * Serialize the skeleton in a JSON object
  19420. * @returns a JSON object
  19421. */
  19422. serialize(): any;
  19423. /**
  19424. * Creates a new skeleton from serialized data
  19425. * @param parsedSkeleton defines the serialized data
  19426. * @param scene defines the hosting scene
  19427. * @returns a new skeleton
  19428. */
  19429. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19430. /**
  19431. * Compute all node absolute transforms
  19432. * @param forceUpdate defines if computation must be done even if cache is up to date
  19433. */
  19434. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19435. /**
  19436. * Gets the root pose matrix
  19437. * @returns a matrix
  19438. */
  19439. getPoseMatrix(): Nullable<Matrix>;
  19440. /**
  19441. * Sorts bones per internal index
  19442. */
  19443. sortBones(): void;
  19444. private _sortBones;
  19445. }
  19446. }
  19447. declare module "babylonjs/Morph/morphTarget" {
  19448. import { IAnimatable } from "babylonjs/Misc/tools";
  19449. import { Observable } from "babylonjs/Misc/observable";
  19450. import { Nullable, FloatArray } from "babylonjs/types";
  19451. import { Scene } from "babylonjs/scene";
  19452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19453. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19454. /**
  19455. * Defines a target to use with MorphTargetManager
  19456. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19457. */
  19458. export class MorphTarget implements IAnimatable {
  19459. /** defines the name of the target */
  19460. name: string;
  19461. /**
  19462. * Gets or sets the list of animations
  19463. */
  19464. animations: import("babylonjs/Animations/animation").Animation[];
  19465. private _scene;
  19466. private _positions;
  19467. private _normals;
  19468. private _tangents;
  19469. private _influence;
  19470. /**
  19471. * Observable raised when the influence changes
  19472. */
  19473. onInfluenceChanged: Observable<boolean>;
  19474. /** @hidden */
  19475. _onDataLayoutChanged: Observable<void>;
  19476. /**
  19477. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19478. */
  19479. influence: number;
  19480. /**
  19481. * Gets or sets the id of the morph Target
  19482. */
  19483. id: string;
  19484. private _animationPropertiesOverride;
  19485. /**
  19486. * Gets or sets the animation properties override
  19487. */
  19488. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19489. /**
  19490. * Creates a new MorphTarget
  19491. * @param name defines the name of the target
  19492. * @param influence defines the influence to use
  19493. * @param scene defines the scene the morphtarget belongs to
  19494. */
  19495. constructor(
  19496. /** defines the name of the target */
  19497. name: string, influence?: number, scene?: Nullable<Scene>);
  19498. /**
  19499. * Gets a boolean defining if the target contains position data
  19500. */
  19501. readonly hasPositions: boolean;
  19502. /**
  19503. * Gets a boolean defining if the target contains normal data
  19504. */
  19505. readonly hasNormals: boolean;
  19506. /**
  19507. * Gets a boolean defining if the target contains tangent data
  19508. */
  19509. readonly hasTangents: boolean;
  19510. /**
  19511. * Affects position data to this target
  19512. * @param data defines the position data to use
  19513. */
  19514. setPositions(data: Nullable<FloatArray>): void;
  19515. /**
  19516. * Gets the position data stored in this target
  19517. * @returns a FloatArray containing the position data (or null if not present)
  19518. */
  19519. getPositions(): Nullable<FloatArray>;
  19520. /**
  19521. * Affects normal data to this target
  19522. * @param data defines the normal data to use
  19523. */
  19524. setNormals(data: Nullable<FloatArray>): void;
  19525. /**
  19526. * Gets the normal data stored in this target
  19527. * @returns a FloatArray containing the normal data (or null if not present)
  19528. */
  19529. getNormals(): Nullable<FloatArray>;
  19530. /**
  19531. * Affects tangent data to this target
  19532. * @param data defines the tangent data to use
  19533. */
  19534. setTangents(data: Nullable<FloatArray>): void;
  19535. /**
  19536. * Gets the tangent data stored in this target
  19537. * @returns a FloatArray containing the tangent data (or null if not present)
  19538. */
  19539. getTangents(): Nullable<FloatArray>;
  19540. /**
  19541. * Serializes the current target into a Serialization object
  19542. * @returns the serialized object
  19543. */
  19544. serialize(): any;
  19545. /**
  19546. * Returns the string "MorphTarget"
  19547. * @returns "MorphTarget"
  19548. */
  19549. getClassName(): string;
  19550. /**
  19551. * Creates a new target from serialized data
  19552. * @param serializationObject defines the serialized data to use
  19553. * @returns a new MorphTarget
  19554. */
  19555. static Parse(serializationObject: any): MorphTarget;
  19556. /**
  19557. * Creates a MorphTarget from mesh data
  19558. * @param mesh defines the source mesh
  19559. * @param name defines the name to use for the new target
  19560. * @param influence defines the influence to attach to the target
  19561. * @returns a new MorphTarget
  19562. */
  19563. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19564. }
  19565. }
  19566. declare module "babylonjs/Morph/morphTargetManager" {
  19567. import { Nullable } from "babylonjs/types";
  19568. import { Scene } from "babylonjs/scene";
  19569. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19570. /**
  19571. * This class is used to deform meshes using morphing between different targets
  19572. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19573. */
  19574. export class MorphTargetManager {
  19575. private _targets;
  19576. private _targetInfluenceChangedObservers;
  19577. private _targetDataLayoutChangedObservers;
  19578. private _activeTargets;
  19579. private _scene;
  19580. private _influences;
  19581. private _supportsNormals;
  19582. private _supportsTangents;
  19583. private _vertexCount;
  19584. private _uniqueId;
  19585. private _tempInfluences;
  19586. /**
  19587. * Creates a new MorphTargetManager
  19588. * @param scene defines the current scene
  19589. */
  19590. constructor(scene?: Nullable<Scene>);
  19591. /**
  19592. * Gets the unique ID of this manager
  19593. */
  19594. readonly uniqueId: number;
  19595. /**
  19596. * Gets the number of vertices handled by this manager
  19597. */
  19598. readonly vertexCount: number;
  19599. /**
  19600. * Gets a boolean indicating if this manager supports morphing of normals
  19601. */
  19602. readonly supportsNormals: boolean;
  19603. /**
  19604. * Gets a boolean indicating if this manager supports morphing of tangents
  19605. */
  19606. readonly supportsTangents: boolean;
  19607. /**
  19608. * Gets the number of targets stored in this manager
  19609. */
  19610. readonly numTargets: number;
  19611. /**
  19612. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19613. */
  19614. readonly numInfluencers: number;
  19615. /**
  19616. * Gets the list of influences (one per target)
  19617. */
  19618. readonly influences: Float32Array;
  19619. /**
  19620. * Gets the active target at specified index. An active target is a target with an influence > 0
  19621. * @param index defines the index to check
  19622. * @returns the requested target
  19623. */
  19624. getActiveTarget(index: number): MorphTarget;
  19625. /**
  19626. * Gets the target at specified index
  19627. * @param index defines the index to check
  19628. * @returns the requested target
  19629. */
  19630. getTarget(index: number): MorphTarget;
  19631. /**
  19632. * Add a new target to this manager
  19633. * @param target defines the target to add
  19634. */
  19635. addTarget(target: MorphTarget): void;
  19636. /**
  19637. * Removes a target from the manager
  19638. * @param target defines the target to remove
  19639. */
  19640. removeTarget(target: MorphTarget): void;
  19641. /**
  19642. * Serializes the current manager into a Serialization object
  19643. * @returns the serialized object
  19644. */
  19645. serialize(): any;
  19646. private _syncActiveTargets;
  19647. /**
  19648. * Syncrhonize the targets with all the meshes using this morph target manager
  19649. */
  19650. synchronize(): void;
  19651. /**
  19652. * Creates a new MorphTargetManager from serialized data
  19653. * @param serializationObject defines the serialized data
  19654. * @param scene defines the hosting scene
  19655. * @returns the new MorphTargetManager
  19656. */
  19657. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19658. }
  19659. }
  19660. declare module "babylonjs/Meshes/groundMesh" {
  19661. import { Scene } from "babylonjs/scene";
  19662. import { Vector3 } from "babylonjs/Maths/math";
  19663. import { Mesh } from "babylonjs/Meshes/mesh";
  19664. /**
  19665. * Mesh representing the gorund
  19666. */
  19667. export class GroundMesh extends Mesh {
  19668. /** If octree should be generated */
  19669. generateOctree: boolean;
  19670. private _heightQuads;
  19671. /** @hidden */
  19672. _subdivisionsX: number;
  19673. /** @hidden */
  19674. _subdivisionsY: number;
  19675. /** @hidden */
  19676. _width: number;
  19677. /** @hidden */
  19678. _height: number;
  19679. /** @hidden */
  19680. _minX: number;
  19681. /** @hidden */
  19682. _maxX: number;
  19683. /** @hidden */
  19684. _minZ: number;
  19685. /** @hidden */
  19686. _maxZ: number;
  19687. constructor(name: string, scene: Scene);
  19688. /**
  19689. * "GroundMesh"
  19690. * @returns "GroundMesh"
  19691. */
  19692. getClassName(): string;
  19693. /**
  19694. * The minimum of x and y subdivisions
  19695. */
  19696. readonly subdivisions: number;
  19697. /**
  19698. * X subdivisions
  19699. */
  19700. readonly subdivisionsX: number;
  19701. /**
  19702. * Y subdivisions
  19703. */
  19704. readonly subdivisionsY: number;
  19705. /**
  19706. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19707. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19708. * @param chunksCount the number of subdivisions for x and y
  19709. * @param octreeBlocksSize (Default: 32)
  19710. */
  19711. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19712. /**
  19713. * Returns a height (y) value in the Worl system :
  19714. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19715. * @param x x coordinate
  19716. * @param z z coordinate
  19717. * @returns the ground y position if (x, z) are outside the ground surface.
  19718. */
  19719. getHeightAtCoordinates(x: number, z: number): number;
  19720. /**
  19721. * Returns a normalized vector (Vector3) orthogonal to the ground
  19722. * at the ground coordinates (x, z) expressed in the World system.
  19723. * @param x x coordinate
  19724. * @param z z coordinate
  19725. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19726. */
  19727. getNormalAtCoordinates(x: number, z: number): Vector3;
  19728. /**
  19729. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19730. * at the ground coordinates (x, z) expressed in the World system.
  19731. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19732. * @param x x coordinate
  19733. * @param z z coordinate
  19734. * @param ref vector to store the result
  19735. * @returns the GroundMesh.
  19736. */
  19737. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19738. /**
  19739. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19740. * if the ground has been updated.
  19741. * This can be used in the render loop.
  19742. * @returns the GroundMesh.
  19743. */
  19744. updateCoordinateHeights(): GroundMesh;
  19745. private _getFacetAt;
  19746. private _initHeightQuads;
  19747. private _computeHeightQuads;
  19748. /**
  19749. * Serializes this ground mesh
  19750. * @param serializationObject object to write serialization to
  19751. */
  19752. serialize(serializationObject: any): void;
  19753. /**
  19754. * Parses a serialized ground mesh
  19755. * @param parsedMesh the serialized mesh
  19756. * @param scene the scene to create the ground mesh in
  19757. * @returns the created ground mesh
  19758. */
  19759. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19760. }
  19761. }
  19762. declare module "babylonjs/Physics/physicsJoint" {
  19763. import { Vector3 } from "babylonjs/Maths/math";
  19764. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19765. /**
  19766. * Interface for Physics-Joint data
  19767. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19768. */
  19769. export interface PhysicsJointData {
  19770. /**
  19771. * The main pivot of the joint
  19772. */
  19773. mainPivot?: Vector3;
  19774. /**
  19775. * The connected pivot of the joint
  19776. */
  19777. connectedPivot?: Vector3;
  19778. /**
  19779. * The main axis of the joint
  19780. */
  19781. mainAxis?: Vector3;
  19782. /**
  19783. * The connected axis of the joint
  19784. */
  19785. connectedAxis?: Vector3;
  19786. /**
  19787. * The collision of the joint
  19788. */
  19789. collision?: boolean;
  19790. /**
  19791. * Native Oimo/Cannon/Energy data
  19792. */
  19793. nativeParams?: any;
  19794. }
  19795. /**
  19796. * This is a holder class for the physics joint created by the physics plugin
  19797. * It holds a set of functions to control the underlying joint
  19798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19799. */
  19800. export class PhysicsJoint {
  19801. /**
  19802. * The type of the physics joint
  19803. */
  19804. type: number;
  19805. /**
  19806. * The data for the physics joint
  19807. */
  19808. jointData: PhysicsJointData;
  19809. private _physicsJoint;
  19810. protected _physicsPlugin: IPhysicsEnginePlugin;
  19811. /**
  19812. * Initializes the physics joint
  19813. * @param type The type of the physics joint
  19814. * @param jointData The data for the physics joint
  19815. */
  19816. constructor(
  19817. /**
  19818. * The type of the physics joint
  19819. */
  19820. type: number,
  19821. /**
  19822. * The data for the physics joint
  19823. */
  19824. jointData: PhysicsJointData);
  19825. /**
  19826. * Gets the physics joint
  19827. */
  19828. /**
  19829. * Sets the physics joint
  19830. */
  19831. physicsJoint: any;
  19832. /**
  19833. * Sets the physics plugin
  19834. */
  19835. physicsPlugin: IPhysicsEnginePlugin;
  19836. /**
  19837. * Execute a function that is physics-plugin specific.
  19838. * @param {Function} func the function that will be executed.
  19839. * It accepts two parameters: the physics world and the physics joint
  19840. */
  19841. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19842. /**
  19843. * Distance-Joint type
  19844. */
  19845. static DistanceJoint: number;
  19846. /**
  19847. * Hinge-Joint type
  19848. */
  19849. static HingeJoint: number;
  19850. /**
  19851. * Ball-and-Socket joint type
  19852. */
  19853. static BallAndSocketJoint: number;
  19854. /**
  19855. * Wheel-Joint type
  19856. */
  19857. static WheelJoint: number;
  19858. /**
  19859. * Slider-Joint type
  19860. */
  19861. static SliderJoint: number;
  19862. /**
  19863. * Prismatic-Joint type
  19864. */
  19865. static PrismaticJoint: number;
  19866. /**
  19867. * Universal-Joint type
  19868. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19869. */
  19870. static UniversalJoint: number;
  19871. /**
  19872. * Hinge-Joint 2 type
  19873. */
  19874. static Hinge2Joint: number;
  19875. /**
  19876. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19877. */
  19878. static PointToPointJoint: number;
  19879. /**
  19880. * Spring-Joint type
  19881. */
  19882. static SpringJoint: number;
  19883. /**
  19884. * Lock-Joint type
  19885. */
  19886. static LockJoint: number;
  19887. }
  19888. /**
  19889. * A class representing a physics distance joint
  19890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19891. */
  19892. export class DistanceJoint extends PhysicsJoint {
  19893. /**
  19894. *
  19895. * @param jointData The data for the Distance-Joint
  19896. */
  19897. constructor(jointData: DistanceJointData);
  19898. /**
  19899. * Update the predefined distance.
  19900. * @param maxDistance The maximum preferred distance
  19901. * @param minDistance The minimum preferred distance
  19902. */
  19903. updateDistance(maxDistance: number, minDistance?: number): void;
  19904. }
  19905. /**
  19906. * Represents a Motor-Enabled Joint
  19907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19908. */
  19909. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19910. /**
  19911. * Initializes the Motor-Enabled Joint
  19912. * @param type The type of the joint
  19913. * @param jointData The physica joint data for the joint
  19914. */
  19915. constructor(type: number, jointData: PhysicsJointData);
  19916. /**
  19917. * Set the motor values.
  19918. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19919. * @param force the force to apply
  19920. * @param maxForce max force for this motor.
  19921. */
  19922. setMotor(force?: number, maxForce?: number): void;
  19923. /**
  19924. * Set the motor's limits.
  19925. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19926. * @param upperLimit The upper limit of the motor
  19927. * @param lowerLimit The lower limit of the motor
  19928. */
  19929. setLimit(upperLimit: number, lowerLimit?: number): void;
  19930. }
  19931. /**
  19932. * This class represents a single physics Hinge-Joint
  19933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19934. */
  19935. export class HingeJoint extends MotorEnabledJoint {
  19936. /**
  19937. * Initializes the Hinge-Joint
  19938. * @param jointData The joint data for the Hinge-Joint
  19939. */
  19940. constructor(jointData: PhysicsJointData);
  19941. /**
  19942. * Set the motor values.
  19943. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19944. * @param {number} force the force to apply
  19945. * @param {number} maxForce max force for this motor.
  19946. */
  19947. setMotor(force?: number, maxForce?: number): void;
  19948. /**
  19949. * Set the motor's limits.
  19950. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19951. * @param upperLimit The upper limit of the motor
  19952. * @param lowerLimit The lower limit of the motor
  19953. */
  19954. setLimit(upperLimit: number, lowerLimit?: number): void;
  19955. }
  19956. /**
  19957. * This class represents a dual hinge physics joint (same as wheel joint)
  19958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19959. */
  19960. export class Hinge2Joint extends MotorEnabledJoint {
  19961. /**
  19962. * Initializes the Hinge2-Joint
  19963. * @param jointData The joint data for the Hinge2-Joint
  19964. */
  19965. constructor(jointData: PhysicsJointData);
  19966. /**
  19967. * Set the motor values.
  19968. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19969. * @param {number} targetSpeed the speed the motor is to reach
  19970. * @param {number} maxForce max force for this motor.
  19971. * @param {motorIndex} the motor's index, 0 or 1.
  19972. */
  19973. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19974. /**
  19975. * Set the motor limits.
  19976. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19977. * @param {number} upperLimit the upper limit
  19978. * @param {number} lowerLimit lower limit
  19979. * @param {motorIndex} the motor's index, 0 or 1.
  19980. */
  19981. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19982. }
  19983. /**
  19984. * Interface for a motor enabled joint
  19985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19986. */
  19987. export interface IMotorEnabledJoint {
  19988. /**
  19989. * Physics joint
  19990. */
  19991. physicsJoint: any;
  19992. /**
  19993. * Sets the motor of the motor-enabled joint
  19994. * @param force The force of the motor
  19995. * @param maxForce The maximum force of the motor
  19996. * @param motorIndex The index of the motor
  19997. */
  19998. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19999. /**
  20000. * Sets the limit of the motor
  20001. * @param upperLimit The upper limit of the motor
  20002. * @param lowerLimit The lower limit of the motor
  20003. * @param motorIndex The index of the motor
  20004. */
  20005. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20006. }
  20007. /**
  20008. * Joint data for a Distance-Joint
  20009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20010. */
  20011. export interface DistanceJointData extends PhysicsJointData {
  20012. /**
  20013. * Max distance the 2 joint objects can be apart
  20014. */
  20015. maxDistance: number;
  20016. }
  20017. /**
  20018. * Joint data from a spring joint
  20019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20020. */
  20021. export interface SpringJointData extends PhysicsJointData {
  20022. /**
  20023. * Length of the spring
  20024. */
  20025. length: number;
  20026. /**
  20027. * Stiffness of the spring
  20028. */
  20029. stiffness: number;
  20030. /**
  20031. * Damping of the spring
  20032. */
  20033. damping: number;
  20034. /** this callback will be called when applying the force to the impostors. */
  20035. forceApplicationCallback: () => void;
  20036. }
  20037. }
  20038. declare module "babylonjs/Physics/physicsRaycastResult" {
  20039. import { Vector3 } from "babylonjs/Maths/math";
  20040. /**
  20041. * Holds the data for the raycast result
  20042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20043. */
  20044. export class PhysicsRaycastResult {
  20045. private _hasHit;
  20046. private _hitDistance;
  20047. private _hitNormalWorld;
  20048. private _hitPointWorld;
  20049. private _rayFromWorld;
  20050. private _rayToWorld;
  20051. /**
  20052. * Gets if there was a hit
  20053. */
  20054. readonly hasHit: boolean;
  20055. /**
  20056. * Gets the distance from the hit
  20057. */
  20058. readonly hitDistance: number;
  20059. /**
  20060. * Gets the hit normal/direction in the world
  20061. */
  20062. readonly hitNormalWorld: Vector3;
  20063. /**
  20064. * Gets the hit point in the world
  20065. */
  20066. readonly hitPointWorld: Vector3;
  20067. /**
  20068. * Gets the ray "start point" of the ray in the world
  20069. */
  20070. readonly rayFromWorld: Vector3;
  20071. /**
  20072. * Gets the ray "end point" of the ray in the world
  20073. */
  20074. readonly rayToWorld: Vector3;
  20075. /**
  20076. * Sets the hit data (normal & point in world space)
  20077. * @param hitNormalWorld defines the normal in world space
  20078. * @param hitPointWorld defines the point in world space
  20079. */
  20080. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20081. /**
  20082. * Sets the distance from the start point to the hit point
  20083. * @param distance
  20084. */
  20085. setHitDistance(distance: number): void;
  20086. /**
  20087. * Calculates the distance manually
  20088. */
  20089. calculateHitDistance(): void;
  20090. /**
  20091. * Resets all the values to default
  20092. * @param from The from point on world space
  20093. * @param to The to point on world space
  20094. */
  20095. reset(from?: Vector3, to?: Vector3): void;
  20096. }
  20097. /**
  20098. * Interface for the size containing width and height
  20099. */
  20100. interface IXYZ {
  20101. /**
  20102. * X
  20103. */
  20104. x: number;
  20105. /**
  20106. * Y
  20107. */
  20108. y: number;
  20109. /**
  20110. * Z
  20111. */
  20112. z: number;
  20113. }
  20114. }
  20115. declare module "babylonjs/Physics/IPhysicsEngine" {
  20116. import { Nullable } from "babylonjs/types";
  20117. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20119. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20120. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20121. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20122. /**
  20123. * Interface used to describe a physics joint
  20124. */
  20125. export interface PhysicsImpostorJoint {
  20126. /** Defines the main impostor to which the joint is linked */
  20127. mainImpostor: PhysicsImpostor;
  20128. /** Defines the impostor that is connected to the main impostor using this joint */
  20129. connectedImpostor: PhysicsImpostor;
  20130. /** Defines the joint itself */
  20131. joint: PhysicsJoint;
  20132. }
  20133. /** @hidden */
  20134. export interface IPhysicsEnginePlugin {
  20135. world: any;
  20136. name: string;
  20137. setGravity(gravity: Vector3): void;
  20138. setTimeStep(timeStep: number): void;
  20139. getTimeStep(): number;
  20140. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20141. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20142. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20143. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20144. removePhysicsBody(impostor: PhysicsImpostor): void;
  20145. generateJoint(joint: PhysicsImpostorJoint): void;
  20146. removeJoint(joint: PhysicsImpostorJoint): void;
  20147. isSupported(): boolean;
  20148. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20149. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20150. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20151. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20152. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20153. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20154. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20155. getBodyMass(impostor: PhysicsImpostor): number;
  20156. getBodyFriction(impostor: PhysicsImpostor): number;
  20157. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20158. getBodyRestitution(impostor: PhysicsImpostor): number;
  20159. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20160. getBodyPressure?(impostor: PhysicsImpostor): number;
  20161. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20162. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20163. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20164. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20165. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20166. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20167. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20168. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20169. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20170. sleepBody(impostor: PhysicsImpostor): void;
  20171. wakeUpBody(impostor: PhysicsImpostor): void;
  20172. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20173. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20174. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20175. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20176. getRadius(impostor: PhysicsImpostor): number;
  20177. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20178. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20179. dispose(): void;
  20180. }
  20181. /**
  20182. * Interface used to define a physics engine
  20183. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20184. */
  20185. export interface IPhysicsEngine {
  20186. /**
  20187. * Gets the gravity vector used by the simulation
  20188. */
  20189. gravity: Vector3;
  20190. /**
  20191. * Sets the gravity vector used by the simulation
  20192. * @param gravity defines the gravity vector to use
  20193. */
  20194. setGravity(gravity: Vector3): void;
  20195. /**
  20196. * Set the time step of the physics engine.
  20197. * Default is 1/60.
  20198. * To slow it down, enter 1/600 for example.
  20199. * To speed it up, 1/30
  20200. * @param newTimeStep the new timestep to apply to this world.
  20201. */
  20202. setTimeStep(newTimeStep: number): void;
  20203. /**
  20204. * Get the time step of the physics engine.
  20205. * @returns the current time step
  20206. */
  20207. getTimeStep(): number;
  20208. /**
  20209. * Release all resources
  20210. */
  20211. dispose(): void;
  20212. /**
  20213. * Gets the name of the current physics plugin
  20214. * @returns the name of the plugin
  20215. */
  20216. getPhysicsPluginName(): string;
  20217. /**
  20218. * Adding a new impostor for the impostor tracking.
  20219. * This will be done by the impostor itself.
  20220. * @param impostor the impostor to add
  20221. */
  20222. addImpostor(impostor: PhysicsImpostor): void;
  20223. /**
  20224. * Remove an impostor from the engine.
  20225. * This impostor and its mesh will not longer be updated by the physics engine.
  20226. * @param impostor the impostor to remove
  20227. */
  20228. removeImpostor(impostor: PhysicsImpostor): void;
  20229. /**
  20230. * Add a joint to the physics engine
  20231. * @param mainImpostor defines the main impostor to which the joint is added.
  20232. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20233. * @param joint defines the joint that will connect both impostors.
  20234. */
  20235. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20236. /**
  20237. * Removes a joint from the simulation
  20238. * @param mainImpostor defines the impostor used with the joint
  20239. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20240. * @param joint defines the joint to remove
  20241. */
  20242. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20243. /**
  20244. * Gets the current plugin used to run the simulation
  20245. * @returns current plugin
  20246. */
  20247. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20248. /**
  20249. * Gets the list of physic impostors
  20250. * @returns an array of PhysicsImpostor
  20251. */
  20252. getImpostors(): Array<PhysicsImpostor>;
  20253. /**
  20254. * Gets the impostor for a physics enabled object
  20255. * @param object defines the object impersonated by the impostor
  20256. * @returns the PhysicsImpostor or null if not found
  20257. */
  20258. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20259. /**
  20260. * Gets the impostor for a physics body object
  20261. * @param body defines physics body used by the impostor
  20262. * @returns the PhysicsImpostor or null if not found
  20263. */
  20264. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20265. /**
  20266. * Does a raycast in the physics world
  20267. * @param from when should the ray start?
  20268. * @param to when should the ray end?
  20269. * @returns PhysicsRaycastResult
  20270. */
  20271. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20272. /**
  20273. * Called by the scene. No need to call it.
  20274. * @param delta defines the timespam between frames
  20275. */
  20276. _step(delta: number): void;
  20277. }
  20278. }
  20279. declare module "babylonjs/Physics/physicsImpostor" {
  20280. import { Nullable, IndicesArray } from "babylonjs/types";
  20281. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20282. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20284. import { Scene } from "babylonjs/scene";
  20285. import { Bone } from "babylonjs/Bones/bone";
  20286. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20287. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20288. /**
  20289. * The interface for the physics imposter parameters
  20290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20291. */
  20292. export interface PhysicsImpostorParameters {
  20293. /**
  20294. * The mass of the physics imposter
  20295. */
  20296. mass: number;
  20297. /**
  20298. * The friction of the physics imposter
  20299. */
  20300. friction?: number;
  20301. /**
  20302. * The coefficient of restitution of the physics imposter
  20303. */
  20304. restitution?: number;
  20305. /**
  20306. * The native options of the physics imposter
  20307. */
  20308. nativeOptions?: any;
  20309. /**
  20310. * Specifies if the parent should be ignored
  20311. */
  20312. ignoreParent?: boolean;
  20313. /**
  20314. * Specifies if bi-directional transformations should be disabled
  20315. */
  20316. disableBidirectionalTransformation?: boolean;
  20317. /**
  20318. * The pressure inside the physics imposter, soft object only
  20319. */
  20320. pressure?: number;
  20321. /**
  20322. * The stiffness the physics imposter, soft object only
  20323. */
  20324. stiffness?: number;
  20325. /**
  20326. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20327. */
  20328. velocityIterations?: number;
  20329. /**
  20330. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20331. */
  20332. positionIterations?: number;
  20333. /**
  20334. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20335. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20336. * Add to fix multiple points
  20337. */
  20338. fixedPoints?: number;
  20339. /**
  20340. * The collision margin around a soft object
  20341. */
  20342. margin?: number;
  20343. /**
  20344. * The collision margin around a soft object
  20345. */
  20346. damping?: number;
  20347. /**
  20348. * The path for a rope based on an extrusion
  20349. */
  20350. path?: any;
  20351. /**
  20352. * The shape of an extrusion used for a rope based on an extrusion
  20353. */
  20354. shape?: any;
  20355. }
  20356. /**
  20357. * Interface for a physics-enabled object
  20358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20359. */
  20360. export interface IPhysicsEnabledObject {
  20361. /**
  20362. * The position of the physics-enabled object
  20363. */
  20364. position: Vector3;
  20365. /**
  20366. * The rotation of the physics-enabled object
  20367. */
  20368. rotationQuaternion: Nullable<Quaternion>;
  20369. /**
  20370. * The scale of the physics-enabled object
  20371. */
  20372. scaling: Vector3;
  20373. /**
  20374. * The rotation of the physics-enabled object
  20375. */
  20376. rotation?: Vector3;
  20377. /**
  20378. * The parent of the physics-enabled object
  20379. */
  20380. parent?: any;
  20381. /**
  20382. * The bounding info of the physics-enabled object
  20383. * @returns The bounding info of the physics-enabled object
  20384. */
  20385. getBoundingInfo(): BoundingInfo;
  20386. /**
  20387. * Computes the world matrix
  20388. * @param force Specifies if the world matrix should be computed by force
  20389. * @returns A world matrix
  20390. */
  20391. computeWorldMatrix(force: boolean): Matrix;
  20392. /**
  20393. * Gets the world matrix
  20394. * @returns A world matrix
  20395. */
  20396. getWorldMatrix?(): Matrix;
  20397. /**
  20398. * Gets the child meshes
  20399. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20400. * @returns An array of abstract meshes
  20401. */
  20402. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20403. /**
  20404. * Gets the vertex data
  20405. * @param kind The type of vertex data
  20406. * @returns A nullable array of numbers, or a float32 array
  20407. */
  20408. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20409. /**
  20410. * Gets the indices from the mesh
  20411. * @returns A nullable array of index arrays
  20412. */
  20413. getIndices?(): Nullable<IndicesArray>;
  20414. /**
  20415. * Gets the scene from the mesh
  20416. * @returns the indices array or null
  20417. */
  20418. getScene?(): Scene;
  20419. /**
  20420. * Gets the absolute position from the mesh
  20421. * @returns the absolute position
  20422. */
  20423. getAbsolutePosition(): Vector3;
  20424. /**
  20425. * Gets the absolute pivot point from the mesh
  20426. * @returns the absolute pivot point
  20427. */
  20428. getAbsolutePivotPoint(): Vector3;
  20429. /**
  20430. * Rotates the mesh
  20431. * @param axis The axis of rotation
  20432. * @param amount The amount of rotation
  20433. * @param space The space of the rotation
  20434. * @returns The rotation transform node
  20435. */
  20436. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20437. /**
  20438. * Translates the mesh
  20439. * @param axis The axis of translation
  20440. * @param distance The distance of translation
  20441. * @param space The space of the translation
  20442. * @returns The transform node
  20443. */
  20444. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20445. /**
  20446. * Sets the absolute position of the mesh
  20447. * @param absolutePosition The absolute position of the mesh
  20448. * @returns The transform node
  20449. */
  20450. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20451. /**
  20452. * Gets the class name of the mesh
  20453. * @returns The class name
  20454. */
  20455. getClassName(): string;
  20456. }
  20457. /**
  20458. * Represents a physics imposter
  20459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20460. */
  20461. export class PhysicsImpostor {
  20462. /**
  20463. * The physics-enabled object used as the physics imposter
  20464. */
  20465. object: IPhysicsEnabledObject;
  20466. /**
  20467. * The type of the physics imposter
  20468. */
  20469. type: number;
  20470. private _options;
  20471. private _scene?;
  20472. /**
  20473. * The default object size of the imposter
  20474. */
  20475. static DEFAULT_OBJECT_SIZE: Vector3;
  20476. /**
  20477. * The identity quaternion of the imposter
  20478. */
  20479. static IDENTITY_QUATERNION: Quaternion;
  20480. /** @hidden */
  20481. _pluginData: any;
  20482. private _physicsEngine;
  20483. private _physicsBody;
  20484. private _bodyUpdateRequired;
  20485. private _onBeforePhysicsStepCallbacks;
  20486. private _onAfterPhysicsStepCallbacks;
  20487. /** @hidden */
  20488. _onPhysicsCollideCallbacks: Array<{
  20489. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20490. otherImpostors: Array<PhysicsImpostor>;
  20491. }>;
  20492. private _deltaPosition;
  20493. private _deltaRotation;
  20494. private _deltaRotationConjugated;
  20495. /** hidden */
  20496. _isFromLine: boolean;
  20497. private _parent;
  20498. private _isDisposed;
  20499. private static _tmpVecs;
  20500. private static _tmpQuat;
  20501. /**
  20502. * Specifies if the physics imposter is disposed
  20503. */
  20504. readonly isDisposed: boolean;
  20505. /**
  20506. * Gets the mass of the physics imposter
  20507. */
  20508. mass: number;
  20509. /**
  20510. * Gets the coefficient of friction
  20511. */
  20512. /**
  20513. * Sets the coefficient of friction
  20514. */
  20515. friction: number;
  20516. /**
  20517. * Gets the coefficient of restitution
  20518. */
  20519. /**
  20520. * Sets the coefficient of restitution
  20521. */
  20522. restitution: number;
  20523. /**
  20524. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20525. */
  20526. /**
  20527. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20528. */
  20529. pressure: number;
  20530. /**
  20531. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20532. */
  20533. /**
  20534. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20535. */
  20536. stiffness: number;
  20537. /**
  20538. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20539. */
  20540. /**
  20541. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20542. */
  20543. velocityIterations: number;
  20544. /**
  20545. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20546. */
  20547. /**
  20548. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20549. */
  20550. positionIterations: number;
  20551. /**
  20552. * The unique id of the physics imposter
  20553. * set by the physics engine when adding this impostor to the array
  20554. */
  20555. uniqueId: number;
  20556. /**
  20557. * @hidden
  20558. */
  20559. soft: boolean;
  20560. /**
  20561. * @hidden
  20562. */
  20563. segments: number;
  20564. private _joints;
  20565. /**
  20566. * Initializes the physics imposter
  20567. * @param object The physics-enabled object used as the physics imposter
  20568. * @param type The type of the physics imposter
  20569. * @param _options The options for the physics imposter
  20570. * @param _scene The Babylon scene
  20571. */
  20572. constructor(
  20573. /**
  20574. * The physics-enabled object used as the physics imposter
  20575. */
  20576. object: IPhysicsEnabledObject,
  20577. /**
  20578. * The type of the physics imposter
  20579. */
  20580. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20581. /**
  20582. * This function will completly initialize this impostor.
  20583. * It will create a new body - but only if this mesh has no parent.
  20584. * If it has, this impostor will not be used other than to define the impostor
  20585. * of the child mesh.
  20586. * @hidden
  20587. */
  20588. _init(): void;
  20589. private _getPhysicsParent;
  20590. /**
  20591. * Should a new body be generated.
  20592. * @returns boolean specifying if body initialization is required
  20593. */
  20594. isBodyInitRequired(): boolean;
  20595. /**
  20596. * Sets the updated scaling
  20597. * @param updated Specifies if the scaling is updated
  20598. */
  20599. setScalingUpdated(): void;
  20600. /**
  20601. * Force a regeneration of this or the parent's impostor's body.
  20602. * Use under cautious - This will remove all joints already implemented.
  20603. */
  20604. forceUpdate(): void;
  20605. /**
  20606. * Gets the body that holds this impostor. Either its own, or its parent.
  20607. */
  20608. /**
  20609. * Set the physics body. Used mainly by the physics engine/plugin
  20610. */
  20611. physicsBody: any;
  20612. /**
  20613. * Get the parent of the physics imposter
  20614. * @returns Physics imposter or null
  20615. */
  20616. /**
  20617. * Sets the parent of the physics imposter
  20618. */
  20619. parent: Nullable<PhysicsImpostor>;
  20620. /**
  20621. * Resets the update flags
  20622. */
  20623. resetUpdateFlags(): void;
  20624. /**
  20625. * Gets the object extend size
  20626. * @returns the object extend size
  20627. */
  20628. getObjectExtendSize(): Vector3;
  20629. /**
  20630. * Gets the object center
  20631. * @returns The object center
  20632. */
  20633. getObjectCenter(): Vector3;
  20634. /**
  20635. * Get a specific parametes from the options parameter
  20636. * @param paramName The object parameter name
  20637. * @returns The object parameter
  20638. */
  20639. getParam(paramName: string): any;
  20640. /**
  20641. * Sets a specific parameter in the options given to the physics plugin
  20642. * @param paramName The parameter name
  20643. * @param value The value of the parameter
  20644. */
  20645. setParam(paramName: string, value: number): void;
  20646. /**
  20647. * Specifically change the body's mass option. Won't recreate the physics body object
  20648. * @param mass The mass of the physics imposter
  20649. */
  20650. setMass(mass: number): void;
  20651. /**
  20652. * Gets the linear velocity
  20653. * @returns linear velocity or null
  20654. */
  20655. getLinearVelocity(): Nullable<Vector3>;
  20656. /**
  20657. * Sets the linear velocity
  20658. * @param velocity linear velocity or null
  20659. */
  20660. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20661. /**
  20662. * Gets the angular velocity
  20663. * @returns angular velocity or null
  20664. */
  20665. getAngularVelocity(): Nullable<Vector3>;
  20666. /**
  20667. * Sets the angular velocity
  20668. * @param velocity The velocity or null
  20669. */
  20670. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20671. /**
  20672. * Execute a function with the physics plugin native code
  20673. * Provide a function the will have two variables - the world object and the physics body object
  20674. * @param func The function to execute with the physics plugin native code
  20675. */
  20676. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20677. /**
  20678. * Register a function that will be executed before the physics world is stepping forward
  20679. * @param func The function to execute before the physics world is stepped forward
  20680. */
  20681. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20682. /**
  20683. * Unregister a function that will be executed before the physics world is stepping forward
  20684. * @param func The function to execute before the physics world is stepped forward
  20685. */
  20686. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20687. /**
  20688. * Register a function that will be executed after the physics step
  20689. * @param func The function to execute after physics step
  20690. */
  20691. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20692. /**
  20693. * Unregisters a function that will be executed after the physics step
  20694. * @param func The function to execute after physics step
  20695. */
  20696. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20697. /**
  20698. * register a function that will be executed when this impostor collides against a different body
  20699. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20700. * @param func Callback that is executed on collision
  20701. */
  20702. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20703. /**
  20704. * Unregisters the physics imposter on contact
  20705. * @param collideAgainst The physics object to collide against
  20706. * @param func Callback to execute on collision
  20707. */
  20708. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20709. private _tmpQuat;
  20710. private _tmpQuat2;
  20711. /**
  20712. * Get the parent rotation
  20713. * @returns The parent rotation
  20714. */
  20715. getParentsRotation(): Quaternion;
  20716. /**
  20717. * this function is executed by the physics engine.
  20718. */
  20719. beforeStep: () => void;
  20720. /**
  20721. * this function is executed by the physics engine
  20722. */
  20723. afterStep: () => void;
  20724. /**
  20725. * Legacy collision detection event support
  20726. */
  20727. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20728. /**
  20729. * event and body object due to cannon's event-based architecture.
  20730. */
  20731. onCollide: (e: {
  20732. body: any;
  20733. }) => void;
  20734. /**
  20735. * Apply a force
  20736. * @param force The force to apply
  20737. * @param contactPoint The contact point for the force
  20738. * @returns The physics imposter
  20739. */
  20740. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20741. /**
  20742. * Apply an impulse
  20743. * @param force The impulse force
  20744. * @param contactPoint The contact point for the impulse force
  20745. * @returns The physics imposter
  20746. */
  20747. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20748. /**
  20749. * A help function to create a joint
  20750. * @param otherImpostor A physics imposter used to create a joint
  20751. * @param jointType The type of joint
  20752. * @param jointData The data for the joint
  20753. * @returns The physics imposter
  20754. */
  20755. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20756. /**
  20757. * Add a joint to this impostor with a different impostor
  20758. * @param otherImpostor A physics imposter used to add a joint
  20759. * @param joint The joint to add
  20760. * @returns The physics imposter
  20761. */
  20762. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20763. /**
  20764. * Add an anchor to a cloth impostor
  20765. * @param otherImpostor rigid impostor to anchor to
  20766. * @param width ratio across width from 0 to 1
  20767. * @param height ratio up height from 0 to 1
  20768. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20769. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20770. * @returns impostor the soft imposter
  20771. */
  20772. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20773. /**
  20774. * Add a hook to a rope impostor
  20775. * @param otherImpostor rigid impostor to anchor to
  20776. * @param length ratio across rope from 0 to 1
  20777. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20778. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20779. * @returns impostor the rope imposter
  20780. */
  20781. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20782. /**
  20783. * Will keep this body still, in a sleep mode.
  20784. * @returns the physics imposter
  20785. */
  20786. sleep(): PhysicsImpostor;
  20787. /**
  20788. * Wake the body up.
  20789. * @returns The physics imposter
  20790. */
  20791. wakeUp(): PhysicsImpostor;
  20792. /**
  20793. * Clones the physics imposter
  20794. * @param newObject The physics imposter clones to this physics-enabled object
  20795. * @returns A nullable physics imposter
  20796. */
  20797. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20798. /**
  20799. * Disposes the physics imposter
  20800. */
  20801. dispose(): void;
  20802. /**
  20803. * Sets the delta position
  20804. * @param position The delta position amount
  20805. */
  20806. setDeltaPosition(position: Vector3): void;
  20807. /**
  20808. * Sets the delta rotation
  20809. * @param rotation The delta rotation amount
  20810. */
  20811. setDeltaRotation(rotation: Quaternion): void;
  20812. /**
  20813. * Gets the box size of the physics imposter and stores the result in the input parameter
  20814. * @param result Stores the box size
  20815. * @returns The physics imposter
  20816. */
  20817. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20818. /**
  20819. * Gets the radius of the physics imposter
  20820. * @returns Radius of the physics imposter
  20821. */
  20822. getRadius(): number;
  20823. /**
  20824. * Sync a bone with this impostor
  20825. * @param bone The bone to sync to the impostor.
  20826. * @param boneMesh The mesh that the bone is influencing.
  20827. * @param jointPivot The pivot of the joint / bone in local space.
  20828. * @param distToJoint Optional distance from the impostor to the joint.
  20829. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20830. */
  20831. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20832. /**
  20833. * Sync impostor to a bone
  20834. * @param bone The bone that the impostor will be synced to.
  20835. * @param boneMesh The mesh that the bone is influencing.
  20836. * @param jointPivot The pivot of the joint / bone in local space.
  20837. * @param distToJoint Optional distance from the impostor to the joint.
  20838. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20839. * @param boneAxis Optional vector3 axis the bone is aligned with
  20840. */
  20841. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20842. /**
  20843. * No-Imposter type
  20844. */
  20845. static NoImpostor: number;
  20846. /**
  20847. * Sphere-Imposter type
  20848. */
  20849. static SphereImpostor: number;
  20850. /**
  20851. * Box-Imposter type
  20852. */
  20853. static BoxImpostor: number;
  20854. /**
  20855. * Plane-Imposter type
  20856. */
  20857. static PlaneImpostor: number;
  20858. /**
  20859. * Mesh-imposter type
  20860. */
  20861. static MeshImpostor: number;
  20862. /**
  20863. * Cylinder-Imposter type
  20864. */
  20865. static CylinderImpostor: number;
  20866. /**
  20867. * Particle-Imposter type
  20868. */
  20869. static ParticleImpostor: number;
  20870. /**
  20871. * Heightmap-Imposter type
  20872. */
  20873. static HeightmapImpostor: number;
  20874. /**
  20875. * ConvexHull-Impostor type (Ammo.js plugin only)
  20876. */
  20877. static ConvexHullImpostor: number;
  20878. /**
  20879. * Rope-Imposter type
  20880. */
  20881. static RopeImpostor: number;
  20882. /**
  20883. * Cloth-Imposter type
  20884. */
  20885. static ClothImpostor: number;
  20886. /**
  20887. * Softbody-Imposter type
  20888. */
  20889. static SoftbodyImpostor: number;
  20890. }
  20891. }
  20892. declare module "babylonjs/Meshes/mesh" {
  20893. import { Observable } from "babylonjs/Misc/observable";
  20894. import { IAnimatable } from "babylonjs/Misc/tools";
  20895. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20896. import { Camera } from "babylonjs/Cameras/camera";
  20897. import { Scene } from "babylonjs/scene";
  20898. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20899. import { Engine } from "babylonjs/Engines/engine";
  20900. import { Node } from "babylonjs/node";
  20901. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20902. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20903. import { Buffer } from "babylonjs/Meshes/buffer";
  20904. import { Geometry } from "babylonjs/Meshes/geometry";
  20905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20906. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20907. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20908. import { Effect } from "babylonjs/Materials/effect";
  20909. import { Material } from "babylonjs/Materials/material";
  20910. import { Skeleton } from "babylonjs/Bones/skeleton";
  20911. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20912. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20913. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20914. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20915. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20916. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20917. /**
  20918. * Class used to represent a specific level of detail of a mesh
  20919. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20920. */
  20921. export class MeshLODLevel {
  20922. /** Defines the distance where this level should star being displayed */
  20923. distance: number;
  20924. /** Defines the mesh to use to render this level */
  20925. mesh: Nullable<Mesh>;
  20926. /**
  20927. * Creates a new LOD level
  20928. * @param distance defines the distance where this level should star being displayed
  20929. * @param mesh defines the mesh to use to render this level
  20930. */
  20931. constructor(
  20932. /** Defines the distance where this level should star being displayed */
  20933. distance: number,
  20934. /** Defines the mesh to use to render this level */
  20935. mesh: Nullable<Mesh>);
  20936. }
  20937. /**
  20938. * @hidden
  20939. **/
  20940. export class _CreationDataStorage {
  20941. closePath?: boolean;
  20942. closeArray?: boolean;
  20943. idx: number[];
  20944. dashSize: number;
  20945. gapSize: number;
  20946. path3D: Path3D;
  20947. pathArray: Vector3[][];
  20948. arc: number;
  20949. radius: number;
  20950. cap: number;
  20951. tessellation: number;
  20952. }
  20953. /**
  20954. * @hidden
  20955. **/
  20956. class _InstanceDataStorage {
  20957. visibleInstances: any;
  20958. renderIdForInstances: number[];
  20959. batchCache: _InstancesBatch;
  20960. instancesBufferSize: number;
  20961. instancesBuffer: Nullable<Buffer>;
  20962. instancesData: Float32Array;
  20963. overridenInstanceCount: number;
  20964. }
  20965. /**
  20966. * @hidden
  20967. **/
  20968. export class _InstancesBatch {
  20969. mustReturn: boolean;
  20970. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20971. renderSelf: boolean[];
  20972. }
  20973. /**
  20974. * Class used to represent renderable models
  20975. */
  20976. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20977. /**
  20978. * Mesh side orientation : usually the external or front surface
  20979. */
  20980. static readonly FRONTSIDE: number;
  20981. /**
  20982. * Mesh side orientation : usually the internal or back surface
  20983. */
  20984. static readonly BACKSIDE: number;
  20985. /**
  20986. * Mesh side orientation : both internal and external or front and back surfaces
  20987. */
  20988. static readonly DOUBLESIDE: number;
  20989. /**
  20990. * Mesh side orientation : by default, `FRONTSIDE`
  20991. */
  20992. static readonly DEFAULTSIDE: number;
  20993. /**
  20994. * Mesh cap setting : no cap
  20995. */
  20996. static readonly NO_CAP: number;
  20997. /**
  20998. * Mesh cap setting : one cap at the beginning of the mesh
  20999. */
  21000. static readonly CAP_START: number;
  21001. /**
  21002. * Mesh cap setting : one cap at the end of the mesh
  21003. */
  21004. static readonly CAP_END: number;
  21005. /**
  21006. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21007. */
  21008. static readonly CAP_ALL: number;
  21009. /**
  21010. * Gets the default side orientation.
  21011. * @param orientation the orientation to value to attempt to get
  21012. * @returns the default orientation
  21013. * @hidden
  21014. */
  21015. static _GetDefaultSideOrientation(orientation?: number): number;
  21016. private _onBeforeRenderObservable;
  21017. private _onBeforeBindObservable;
  21018. private _onAfterRenderObservable;
  21019. private _onBeforeDrawObservable;
  21020. /**
  21021. * An event triggered before rendering the mesh
  21022. */
  21023. readonly onBeforeRenderObservable: Observable<Mesh>;
  21024. /**
  21025. * An event triggered before binding the mesh
  21026. */
  21027. readonly onBeforeBindObservable: Observable<Mesh>;
  21028. /**
  21029. * An event triggered after rendering the mesh
  21030. */
  21031. readonly onAfterRenderObservable: Observable<Mesh>;
  21032. /**
  21033. * An event triggered before drawing the mesh
  21034. */
  21035. readonly onBeforeDrawObservable: Observable<Mesh>;
  21036. private _onBeforeDrawObserver;
  21037. /**
  21038. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21039. */
  21040. onBeforeDraw: () => void;
  21041. /**
  21042. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21043. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21044. */
  21045. delayLoadState: number;
  21046. /**
  21047. * Gets the list of instances created from this mesh
  21048. * it is not supposed to be modified manually.
  21049. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21050. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21051. */
  21052. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21053. /**
  21054. * Gets the file containing delay loading data for this mesh
  21055. */
  21056. delayLoadingFile: string;
  21057. /** @hidden */
  21058. _binaryInfo: any;
  21059. private _LODLevels;
  21060. /**
  21061. * User defined function used to change how LOD level selection is done
  21062. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21063. */
  21064. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21065. private _morphTargetManager;
  21066. /**
  21067. * Gets or sets the morph target manager
  21068. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21069. */
  21070. morphTargetManager: Nullable<MorphTargetManager>;
  21071. /** @hidden */
  21072. _creationDataStorage: Nullable<_CreationDataStorage>;
  21073. /** @hidden */
  21074. _geometry: Nullable<Geometry>;
  21075. /** @hidden */
  21076. _delayInfo: Array<string>;
  21077. /** @hidden */
  21078. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21079. /** @hidden */
  21080. _instanceDataStorage: _InstanceDataStorage;
  21081. private _effectiveMaterial;
  21082. /** @hidden */
  21083. _shouldGenerateFlatShading: boolean;
  21084. private _preActivateId;
  21085. /** @hidden */
  21086. _originalBuilderSideOrientation: number;
  21087. /**
  21088. * Use this property to change the original side orientation defined at construction time
  21089. */
  21090. overrideMaterialSideOrientation: Nullable<number>;
  21091. private _areNormalsFrozen;
  21092. private _sourcePositions;
  21093. private _sourceNormals;
  21094. private _source;
  21095. private meshMap;
  21096. /**
  21097. * Gets the source mesh (the one used to clone this one from)
  21098. */
  21099. readonly source: Nullable<Mesh>;
  21100. /**
  21101. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21102. */
  21103. isUnIndexed: boolean;
  21104. /**
  21105. * @constructor
  21106. * @param name The value used by scene.getMeshByName() to do a lookup.
  21107. * @param scene The scene to add this mesh to.
  21108. * @param parent The parent of this mesh, if it has one
  21109. * @param source An optional Mesh from which geometry is shared, cloned.
  21110. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21111. * When false, achieved by calling a clone(), also passing False.
  21112. * This will make creation of children, recursive.
  21113. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21114. */
  21115. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21116. /**
  21117. * Gets the class name
  21118. * @returns the string "Mesh".
  21119. */
  21120. getClassName(): string;
  21121. /** @hidden */
  21122. readonly _isMesh: boolean;
  21123. /**
  21124. * Returns a description of this mesh
  21125. * @param fullDetails define if full details about this mesh must be used
  21126. * @returns a descriptive string representing this mesh
  21127. */
  21128. toString(fullDetails?: boolean): string;
  21129. /** @hidden */
  21130. _unBindEffect(): void;
  21131. /**
  21132. * Gets a boolean indicating if this mesh has LOD
  21133. */
  21134. readonly hasLODLevels: boolean;
  21135. /**
  21136. * Gets the list of MeshLODLevel associated with the current mesh
  21137. * @returns an array of MeshLODLevel
  21138. */
  21139. getLODLevels(): MeshLODLevel[];
  21140. private _sortLODLevels;
  21141. /**
  21142. * Add a mesh as LOD level triggered at the given distance.
  21143. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21144. * @param distance The distance from the center of the object to show this level
  21145. * @param mesh The mesh to be added as LOD level (can be null)
  21146. * @return This mesh (for chaining)
  21147. */
  21148. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21149. /**
  21150. * Returns the LOD level mesh at the passed distance or null if not found.
  21151. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21152. * @param distance The distance from the center of the object to show this level
  21153. * @returns a Mesh or `null`
  21154. */
  21155. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21156. /**
  21157. * Remove a mesh from the LOD array
  21158. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21159. * @param mesh defines the mesh to be removed
  21160. * @return This mesh (for chaining)
  21161. */
  21162. removeLODLevel(mesh: Mesh): Mesh;
  21163. /**
  21164. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21165. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21166. * @param camera defines the camera to use to compute distance
  21167. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21168. * @return This mesh (for chaining)
  21169. */
  21170. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21171. /**
  21172. * Gets the mesh internal Geometry object
  21173. */
  21174. readonly geometry: Nullable<Geometry>;
  21175. /**
  21176. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21177. * @returns the total number of vertices
  21178. */
  21179. getTotalVertices(): number;
  21180. /**
  21181. * Returns the content of an associated vertex buffer
  21182. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21183. * - VertexBuffer.PositionKind
  21184. * - VertexBuffer.UVKind
  21185. * - VertexBuffer.UV2Kind
  21186. * - VertexBuffer.UV3Kind
  21187. * - VertexBuffer.UV4Kind
  21188. * - VertexBuffer.UV5Kind
  21189. * - VertexBuffer.UV6Kind
  21190. * - VertexBuffer.ColorKind
  21191. * - VertexBuffer.MatricesIndicesKind
  21192. * - VertexBuffer.MatricesIndicesExtraKind
  21193. * - VertexBuffer.MatricesWeightsKind
  21194. * - VertexBuffer.MatricesWeightsExtraKind
  21195. * @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
  21196. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21197. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21198. */
  21199. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21200. /**
  21201. * Returns the mesh VertexBuffer object from the requested `kind`
  21202. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21203. * - VertexBuffer.PositionKind
  21204. * - VertexBuffer.UVKind
  21205. * - VertexBuffer.UV2Kind
  21206. * - VertexBuffer.UV3Kind
  21207. * - VertexBuffer.UV4Kind
  21208. * - VertexBuffer.UV5Kind
  21209. * - VertexBuffer.UV6Kind
  21210. * - VertexBuffer.ColorKind
  21211. * - VertexBuffer.MatricesIndicesKind
  21212. * - VertexBuffer.MatricesIndicesExtraKind
  21213. * - VertexBuffer.MatricesWeightsKind
  21214. * - VertexBuffer.MatricesWeightsExtraKind
  21215. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21216. */
  21217. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21218. /**
  21219. * Tests if a specific vertex buffer is associated with this mesh
  21220. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21221. * - VertexBuffer.PositionKind
  21222. * - VertexBuffer.UVKind
  21223. * - VertexBuffer.UV2Kind
  21224. * - VertexBuffer.UV3Kind
  21225. * - VertexBuffer.UV4Kind
  21226. * - VertexBuffer.UV5Kind
  21227. * - VertexBuffer.UV6Kind
  21228. * - VertexBuffer.ColorKind
  21229. * - VertexBuffer.MatricesIndicesKind
  21230. * - VertexBuffer.MatricesIndicesExtraKind
  21231. * - VertexBuffer.MatricesWeightsKind
  21232. * - VertexBuffer.MatricesWeightsExtraKind
  21233. * @returns a boolean
  21234. */
  21235. isVerticesDataPresent(kind: string): boolean;
  21236. /**
  21237. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21238. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21239. * - VertexBuffer.PositionKind
  21240. * - VertexBuffer.UVKind
  21241. * - VertexBuffer.UV2Kind
  21242. * - VertexBuffer.UV3Kind
  21243. * - VertexBuffer.UV4Kind
  21244. * - VertexBuffer.UV5Kind
  21245. * - VertexBuffer.UV6Kind
  21246. * - VertexBuffer.ColorKind
  21247. * - VertexBuffer.MatricesIndicesKind
  21248. * - VertexBuffer.MatricesIndicesExtraKind
  21249. * - VertexBuffer.MatricesWeightsKind
  21250. * - VertexBuffer.MatricesWeightsExtraKind
  21251. * @returns a boolean
  21252. */
  21253. isVertexBufferUpdatable(kind: string): boolean;
  21254. /**
  21255. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21256. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21257. * - VertexBuffer.PositionKind
  21258. * - VertexBuffer.UVKind
  21259. * - VertexBuffer.UV2Kind
  21260. * - VertexBuffer.UV3Kind
  21261. * - VertexBuffer.UV4Kind
  21262. * - VertexBuffer.UV5Kind
  21263. * - VertexBuffer.UV6Kind
  21264. * - VertexBuffer.ColorKind
  21265. * - VertexBuffer.MatricesIndicesKind
  21266. * - VertexBuffer.MatricesIndicesExtraKind
  21267. * - VertexBuffer.MatricesWeightsKind
  21268. * - VertexBuffer.MatricesWeightsExtraKind
  21269. * @returns an array of strings
  21270. */
  21271. getVerticesDataKinds(): string[];
  21272. /**
  21273. * Returns a positive integer : the total number of indices in this mesh geometry.
  21274. * @returns the numner of indices or zero if the mesh has no geometry.
  21275. */
  21276. getTotalIndices(): number;
  21277. /**
  21278. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21279. * @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.
  21280. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21281. * @returns the indices array or an empty array if the mesh has no geometry
  21282. */
  21283. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21284. readonly isBlocked: boolean;
  21285. /**
  21286. * Determine if the current mesh is ready to be rendered
  21287. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21288. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21289. * @returns true if all associated assets are ready (material, textures, shaders)
  21290. */
  21291. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21292. /**
  21293. * 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.
  21294. */
  21295. readonly areNormalsFrozen: boolean;
  21296. /**
  21297. * 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.
  21298. * @returns the current mesh
  21299. */
  21300. freezeNormals(): Mesh;
  21301. /**
  21302. * 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
  21303. * @returns the current mesh
  21304. */
  21305. unfreezeNormals(): Mesh;
  21306. /**
  21307. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21308. */
  21309. overridenInstanceCount: number;
  21310. /** @hidden */
  21311. _preActivate(): Mesh;
  21312. /** @hidden */
  21313. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21314. /** @hidden */
  21315. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21316. /**
  21317. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21318. * This means the mesh underlying bounding box and sphere are recomputed.
  21319. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21320. * @returns the current mesh
  21321. */
  21322. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21323. /** @hidden */
  21324. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21325. /**
  21326. * This function will subdivide the mesh into multiple submeshes
  21327. * @param count defines the expected number of submeshes
  21328. */
  21329. subdivide(count: number): void;
  21330. /**
  21331. * Copy a FloatArray into a specific associated vertex buffer
  21332. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21333. * - VertexBuffer.PositionKind
  21334. * - VertexBuffer.UVKind
  21335. * - VertexBuffer.UV2Kind
  21336. * - VertexBuffer.UV3Kind
  21337. * - VertexBuffer.UV4Kind
  21338. * - VertexBuffer.UV5Kind
  21339. * - VertexBuffer.UV6Kind
  21340. * - VertexBuffer.ColorKind
  21341. * - VertexBuffer.MatricesIndicesKind
  21342. * - VertexBuffer.MatricesIndicesExtraKind
  21343. * - VertexBuffer.MatricesWeightsKind
  21344. * - VertexBuffer.MatricesWeightsExtraKind
  21345. * @param data defines the data source
  21346. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21347. * @param stride defines the data stride size (can be null)
  21348. * @returns the current mesh
  21349. */
  21350. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21351. /**
  21352. * Flags an associated vertex buffer as updatable
  21353. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21354. * - VertexBuffer.PositionKind
  21355. * - VertexBuffer.UVKind
  21356. * - VertexBuffer.UV2Kind
  21357. * - VertexBuffer.UV3Kind
  21358. * - VertexBuffer.UV4Kind
  21359. * - VertexBuffer.UV5Kind
  21360. * - VertexBuffer.UV6Kind
  21361. * - VertexBuffer.ColorKind
  21362. * - VertexBuffer.MatricesIndicesKind
  21363. * - VertexBuffer.MatricesIndicesExtraKind
  21364. * - VertexBuffer.MatricesWeightsKind
  21365. * - VertexBuffer.MatricesWeightsExtraKind
  21366. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21367. */
  21368. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21369. /**
  21370. * Sets the mesh global Vertex Buffer
  21371. * @param buffer defines the buffer to use
  21372. * @returns the current mesh
  21373. */
  21374. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21375. /**
  21376. * Update a specific associated vertex buffer
  21377. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21378. * - VertexBuffer.PositionKind
  21379. * - VertexBuffer.UVKind
  21380. * - VertexBuffer.UV2Kind
  21381. * - VertexBuffer.UV3Kind
  21382. * - VertexBuffer.UV4Kind
  21383. * - VertexBuffer.UV5Kind
  21384. * - VertexBuffer.UV6Kind
  21385. * - VertexBuffer.ColorKind
  21386. * - VertexBuffer.MatricesIndicesKind
  21387. * - VertexBuffer.MatricesIndicesExtraKind
  21388. * - VertexBuffer.MatricesWeightsKind
  21389. * - VertexBuffer.MatricesWeightsExtraKind
  21390. * @param data defines the data source
  21391. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21392. * @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)
  21393. * @returns the current mesh
  21394. */
  21395. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21396. /**
  21397. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21398. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21399. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21400. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21401. * @returns the current mesh
  21402. */
  21403. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21404. /**
  21405. * Creates a un-shared specific occurence of the geometry for the mesh.
  21406. * @returns the current mesh
  21407. */
  21408. makeGeometryUnique(): Mesh;
  21409. /**
  21410. * Set the index buffer of this mesh
  21411. * @param indices defines the source data
  21412. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21413. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21414. * @returns the current mesh
  21415. */
  21416. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21417. /**
  21418. * Update the current index buffer
  21419. * @param indices defines the source data
  21420. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21421. * @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)
  21422. * @returns the current mesh
  21423. */
  21424. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21425. /**
  21426. * Invert the geometry to move from a right handed system to a left handed one.
  21427. * @returns the current mesh
  21428. */
  21429. toLeftHanded(): Mesh;
  21430. /** @hidden */
  21431. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21432. /** @hidden */
  21433. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21434. /**
  21435. * Registers for this mesh a javascript function called just before the rendering process
  21436. * @param func defines the function to call before rendering this mesh
  21437. * @returns the current mesh
  21438. */
  21439. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21440. /**
  21441. * Disposes a previously registered javascript function called before the rendering
  21442. * @param func defines the function to remove
  21443. * @returns the current mesh
  21444. */
  21445. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21446. /**
  21447. * Registers for this mesh a javascript function called just after the rendering is complete
  21448. * @param func defines the function to call after rendering this mesh
  21449. * @returns the current mesh
  21450. */
  21451. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21452. /**
  21453. * Disposes a previously registered javascript function called after the rendering.
  21454. * @param func defines the function to remove
  21455. * @returns the current mesh
  21456. */
  21457. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21458. /** @hidden */
  21459. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21460. /** @hidden */
  21461. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21462. /** @hidden */
  21463. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21464. /**
  21465. * 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
  21466. * @param subMesh defines the subMesh to render
  21467. * @param enableAlphaMode defines if alpha mode can be changed
  21468. * @returns the current mesh
  21469. */
  21470. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21471. private _onBeforeDraw;
  21472. /**
  21473. * Renormalize the mesh and patch it up if there are no weights
  21474. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21475. * However in the case of zero weights then we set just a single influence to 1.
  21476. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21477. */
  21478. cleanMatrixWeights(): void;
  21479. private normalizeSkinFourWeights;
  21480. private normalizeSkinWeightsAndExtra;
  21481. /**
  21482. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21483. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21484. * the user know there was an issue with importing the mesh
  21485. * @returns a validation object with skinned, valid and report string
  21486. */
  21487. validateSkinning(): {
  21488. skinned: boolean;
  21489. valid: boolean;
  21490. report: string;
  21491. };
  21492. /** @hidden */
  21493. _checkDelayState(): Mesh;
  21494. private _queueLoad;
  21495. /**
  21496. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21497. * A mesh is in the frustum if its bounding box intersects the frustum
  21498. * @param frustumPlanes defines the frustum to test
  21499. * @returns true if the mesh is in the frustum planes
  21500. */
  21501. isInFrustum(frustumPlanes: Plane[]): boolean;
  21502. /**
  21503. * Sets the mesh material by the material or multiMaterial `id` property
  21504. * @param id is a string identifying the material or the multiMaterial
  21505. * @returns the current mesh
  21506. */
  21507. setMaterialByID(id: string): Mesh;
  21508. /**
  21509. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21510. * @returns an array of IAnimatable
  21511. */
  21512. getAnimatables(): IAnimatable[];
  21513. /**
  21514. * Modifies the mesh geometry according to the passed transformation matrix.
  21515. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21516. * The mesh normals are modified using the same transformation.
  21517. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21518. * @param transform defines the transform matrix to use
  21519. * @see http://doc.babylonjs.com/resources/baking_transformations
  21520. * @returns the current mesh
  21521. */
  21522. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21523. /**
  21524. * Modifies the mesh geometry according to its own current World Matrix.
  21525. * The mesh World Matrix is then reset.
  21526. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21527. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21528. * @see http://doc.babylonjs.com/resources/baking_transformations
  21529. * @returns the current mesh
  21530. */
  21531. bakeCurrentTransformIntoVertices(): Mesh;
  21532. /** @hidden */
  21533. readonly _positions: Nullable<Vector3[]>;
  21534. /** @hidden */
  21535. _resetPointsArrayCache(): Mesh;
  21536. /** @hidden */
  21537. _generatePointsArray(): boolean;
  21538. /**
  21539. * Returns a new Mesh object generated from the current mesh properties.
  21540. * This method must not get confused with createInstance()
  21541. * @param name is a string, the name given to the new mesh
  21542. * @param newParent can be any Node object (default `null`)
  21543. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21544. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21545. * @returns a new mesh
  21546. */
  21547. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21548. /**
  21549. * Releases resources associated with this mesh.
  21550. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21551. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21552. */
  21553. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21554. /**
  21555. * Modifies the mesh geometry according to a displacement map.
  21556. * 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.
  21557. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21558. * @param url is a string, the URL from the image file is to be downloaded.
  21559. * @param minHeight is the lower limit of the displacement.
  21560. * @param maxHeight is the upper limit of the displacement.
  21561. * @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.
  21562. * @param uvOffset is an optional vector2 used to offset UV.
  21563. * @param uvScale is an optional vector2 used to scale UV.
  21564. * @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.
  21565. * @returns the Mesh.
  21566. */
  21567. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21568. /**
  21569. * Modifies the mesh geometry according to a displacementMap buffer.
  21570. * 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.
  21571. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21572. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21573. * @param heightMapWidth is the width of the buffer image.
  21574. * @param heightMapHeight is the height of the buffer image.
  21575. * @param minHeight is the lower limit of the displacement.
  21576. * @param maxHeight is the upper limit of the displacement.
  21577. * @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.
  21578. * @param uvOffset is an optional vector2 used to offset UV.
  21579. * @param uvScale is an optional vector2 used to scale UV.
  21580. * @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.
  21581. * @returns the Mesh.
  21582. */
  21583. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21584. /**
  21585. * Modify the mesh to get a flat shading rendering.
  21586. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21587. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21588. * @returns current mesh
  21589. */
  21590. convertToFlatShadedMesh(): Mesh;
  21591. /**
  21592. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21593. * In other words, more vertices, no more indices and a single bigger VBO.
  21594. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21595. * @returns current mesh
  21596. */
  21597. convertToUnIndexedMesh(): Mesh;
  21598. /**
  21599. * Inverses facet orientations.
  21600. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21601. * @param flipNormals will also inverts the normals
  21602. * @returns current mesh
  21603. */
  21604. flipFaces(flipNormals?: boolean): Mesh;
  21605. /**
  21606. * Increase the number of facets and hence vertices in a mesh
  21607. * Vertex normals are interpolated from existing vertex normals
  21608. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21609. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21610. */
  21611. increaseVertices(numberPerEdge: number): void;
  21612. /**
  21613. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21614. * This will undo any application of covertToFlatShadedMesh
  21615. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21616. */
  21617. forceSharedVertices(): void;
  21618. /** @hidden */
  21619. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21620. /** @hidden */
  21621. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21622. /**
  21623. * Creates a new InstancedMesh object from the mesh model.
  21624. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21625. * @param name defines the name of the new instance
  21626. * @returns a new InstancedMesh
  21627. */
  21628. createInstance(name: string): InstancedMesh;
  21629. /**
  21630. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21631. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21632. * @returns the current mesh
  21633. */
  21634. synchronizeInstances(): Mesh;
  21635. /**
  21636. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21637. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21638. * This should be used together with the simplification to avoid disappearing triangles.
  21639. * @param successCallback an optional success callback to be called after the optimization finished.
  21640. * @returns the current mesh
  21641. */
  21642. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21643. /**
  21644. * Serialize current mesh
  21645. * @param serializationObject defines the object which will receive the serialization data
  21646. */
  21647. serialize(serializationObject: any): void;
  21648. /** @hidden */
  21649. _syncGeometryWithMorphTargetManager(): void;
  21650. /** @hidden */
  21651. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21652. /**
  21653. * Returns a new Mesh object parsed from the source provided.
  21654. * @param parsedMesh is the source
  21655. * @param scene defines the hosting scene
  21656. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21657. * @returns a new Mesh
  21658. */
  21659. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21660. /**
  21661. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21662. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21663. * @param name defines the name of the mesh to create
  21664. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21665. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21666. * @param closePath creates a seam between the first and the last points of each path of the path array
  21667. * @param offset is taken in account only if the `pathArray` is containing a single path
  21668. * @param scene defines the hosting scene
  21669. * @param updatable defines if the mesh must be flagged as updatable
  21670. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21671. * @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)
  21672. * @returns a new Mesh
  21673. */
  21674. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21675. /**
  21676. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21677. * @param name defines the name of the mesh to create
  21678. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21679. * @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
  21680. * @param scene defines the hosting scene
  21681. * @param updatable defines if the mesh must be flagged as updatable
  21682. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21683. * @returns a new Mesh
  21684. */
  21685. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21686. /**
  21687. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21688. * @param name defines the name of the mesh to create
  21689. * @param size sets the size (float) of each box side (default 1)
  21690. * @param scene defines the hosting scene
  21691. * @param updatable defines if the mesh must be flagged as updatable
  21692. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21693. * @returns a new Mesh
  21694. */
  21695. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21696. /**
  21697. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21698. * @param name defines the name of the mesh to create
  21699. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21700. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21701. * @param scene defines the hosting scene
  21702. * @param updatable defines if the mesh must be flagged as updatable
  21703. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21704. * @returns a new Mesh
  21705. */
  21706. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21707. /**
  21708. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21709. * @param name defines the name of the mesh to create
  21710. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21711. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21712. * @param scene defines the hosting scene
  21713. * @returns a new Mesh
  21714. */
  21715. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21716. /**
  21717. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21718. * @param name defines the name of the mesh to create
  21719. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21720. * @param diameterTop set the top cap diameter (floats, default 1)
  21721. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21722. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21723. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21724. * @param scene defines the hosting scene
  21725. * @param updatable defines if the mesh must be flagged as updatable
  21726. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21727. * @returns a new Mesh
  21728. */
  21729. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21730. /**
  21731. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21732. * @param name defines the name of the mesh to create
  21733. * @param diameter sets the diameter size (float) of the torus (default 1)
  21734. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21735. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21736. * @param scene defines the hosting scene
  21737. * @param updatable defines if the mesh must be flagged as updatable
  21738. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21739. * @returns a new Mesh
  21740. */
  21741. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21742. /**
  21743. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21744. * @param name defines the name of the mesh to create
  21745. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21746. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21747. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21748. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21749. * @param p the number of windings on X axis (positive integers, default 2)
  21750. * @param q the number of windings on Y axis (positive integers, default 3)
  21751. * @param scene defines the hosting scene
  21752. * @param updatable defines if the mesh must be flagged as updatable
  21753. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21754. * @returns a new Mesh
  21755. */
  21756. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21757. /**
  21758. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21759. * @param name defines the name of the mesh to create
  21760. * @param points is an array successive Vector3
  21761. * @param scene defines the hosting scene
  21762. * @param updatable defines if the mesh must be flagged as updatable
  21763. * @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).
  21764. * @returns a new Mesh
  21765. */
  21766. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21767. /**
  21768. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21769. * @param name defines the name of the mesh to create
  21770. * @param points is an array successive Vector3
  21771. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21772. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21773. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21774. * @param scene defines the hosting scene
  21775. * @param updatable defines if the mesh must be flagged as updatable
  21776. * @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)
  21777. * @returns a new Mesh
  21778. */
  21779. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21780. /**
  21781. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21782. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21783. * 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.
  21784. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21785. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21786. * Remember you can only change the shape positions, not their number when updating a polygon.
  21787. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21788. * @param name defines the name of the mesh to create
  21789. * @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
  21790. * @param scene defines the hosting scene
  21791. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21792. * @param updatable defines if the mesh must be flagged as updatable
  21793. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21794. * @param earcutInjection can be used to inject your own earcut reference
  21795. * @returns a new Mesh
  21796. */
  21797. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21798. /**
  21799. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21800. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21801. * @param name defines the name of the mesh to create
  21802. * @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
  21803. * @param depth defines the height of extrusion
  21804. * @param scene defines the hosting scene
  21805. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21806. * @param updatable defines if the mesh must be flagged as updatable
  21807. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21808. * @param earcutInjection can be used to inject your own earcut reference
  21809. * @returns a new Mesh
  21810. */
  21811. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21812. /**
  21813. * Creates an extruded shape mesh.
  21814. * 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
  21815. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21816. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21817. * @param name defines the name of the mesh to create
  21818. * @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
  21819. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21820. * @param scale is the value to scale the shape
  21821. * @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
  21822. * @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
  21823. * @param scene defines the hosting scene
  21824. * @param updatable defines if the mesh must be flagged as updatable
  21825. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21826. * @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)
  21827. * @returns a new Mesh
  21828. */
  21829. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21830. /**
  21831. * Creates an custom extruded shape mesh.
  21832. * The custom extrusion is a parametric shape.
  21833. * It has no predefined shape. Its final shape will depend on the input parameters.
  21834. * Please consider using the same method from the MeshBuilder class instead
  21835. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21836. * @param name defines the name of the mesh to create
  21837. * @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
  21838. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21839. * @param scaleFunction is a custom Javascript function called on each path point
  21840. * @param rotationFunction is a custom Javascript function called on each path point
  21841. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21842. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21843. * @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
  21844. * @param scene defines the hosting scene
  21845. * @param updatable defines if the mesh must be flagged as updatable
  21846. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21847. * @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)
  21848. * @returns a new Mesh
  21849. */
  21850. 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;
  21851. /**
  21852. * Creates lathe mesh.
  21853. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21854. * Please consider using the same method from the MeshBuilder class instead
  21855. * @param name defines the name of the mesh to create
  21856. * @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
  21857. * @param radius is the radius value of the lathe
  21858. * @param tessellation is the side number of the lathe.
  21859. * @param scene defines the hosting scene
  21860. * @param updatable defines if the mesh must be flagged as updatable
  21861. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21862. * @returns a new Mesh
  21863. */
  21864. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21865. /**
  21866. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21867. * @param name defines the name of the mesh to create
  21868. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21869. * @param scene defines the hosting scene
  21870. * @param updatable defines if the mesh must be flagged as updatable
  21871. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21872. * @returns a new Mesh
  21873. */
  21874. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21875. /**
  21876. * Creates a ground mesh.
  21877. * Please consider using the same method from the MeshBuilder class instead
  21878. * @param name defines the name of the mesh to create
  21879. * @param width set the width of the ground
  21880. * @param height set the height of the ground
  21881. * @param subdivisions sets the number of subdivisions per side
  21882. * @param scene defines the hosting scene
  21883. * @param updatable defines if the mesh must be flagged as updatable
  21884. * @returns a new Mesh
  21885. */
  21886. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21887. /**
  21888. * Creates a tiled ground mesh.
  21889. * Please consider using the same method from the MeshBuilder class instead
  21890. * @param name defines the name of the mesh to create
  21891. * @param xmin set the ground minimum X coordinate
  21892. * @param zmin set the ground minimum Y coordinate
  21893. * @param xmax set the ground maximum X coordinate
  21894. * @param zmax set the ground maximum Z coordinate
  21895. * @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
  21896. * @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
  21897. * @param scene defines the hosting scene
  21898. * @param updatable defines if the mesh must be flagged as updatable
  21899. * @returns a new Mesh
  21900. */
  21901. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21902. w: number;
  21903. h: number;
  21904. }, precision: {
  21905. w: number;
  21906. h: number;
  21907. }, scene: Scene, updatable?: boolean): Mesh;
  21908. /**
  21909. * Creates a ground mesh from a height map.
  21910. * Please consider using the same method from the MeshBuilder class instead
  21911. * @see http://doc.babylonjs.com/babylon101/height_map
  21912. * @param name defines the name of the mesh to create
  21913. * @param url sets the URL of the height map image resource
  21914. * @param width set the ground width size
  21915. * @param height set the ground height size
  21916. * @param subdivisions sets the number of subdivision per side
  21917. * @param minHeight is the minimum altitude on the ground
  21918. * @param maxHeight is the maximum altitude on the ground
  21919. * @param scene defines the hosting scene
  21920. * @param updatable defines if the mesh must be flagged as updatable
  21921. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21922. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21923. * @returns a new Mesh
  21924. */
  21925. 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;
  21926. /**
  21927. * Creates a tube mesh.
  21928. * The tube is a parametric shape.
  21929. * It has no predefined shape. Its final shape will depend on the input parameters.
  21930. * Please consider using the same method from the MeshBuilder class instead
  21931. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21932. * @param name defines the name of the mesh to create
  21933. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21934. * @param radius sets the tube radius size
  21935. * @param tessellation is the number of sides on the tubular surface
  21936. * @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
  21937. * @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
  21938. * @param scene defines the hosting scene
  21939. * @param updatable defines if the mesh must be flagged as updatable
  21940. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21941. * @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)
  21942. * @returns a new Mesh
  21943. */
  21944. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21945. (i: number, distance: number): number;
  21946. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21947. /**
  21948. * Creates a polyhedron mesh.
  21949. * Please consider using the same method from the MeshBuilder class instead.
  21950. * * 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
  21951. * * The parameter `size` (positive float, default 1) sets the polygon size
  21952. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21953. * * 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`
  21954. * * 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
  21955. * * 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)`)
  21956. * * 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
  21957. * * 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
  21958. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21959. * * If you create a double-sided mesh, you can choose what parts of 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
  21960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21961. * @param name defines the name of the mesh to create
  21962. * @param options defines the options used to create the mesh
  21963. * @param scene defines the hosting scene
  21964. * @returns a new Mesh
  21965. */
  21966. static CreatePolyhedron(name: string, options: {
  21967. type?: number;
  21968. size?: number;
  21969. sizeX?: number;
  21970. sizeY?: number;
  21971. sizeZ?: number;
  21972. custom?: any;
  21973. faceUV?: Vector4[];
  21974. faceColors?: Color4[];
  21975. updatable?: boolean;
  21976. sideOrientation?: number;
  21977. }, scene: Scene): Mesh;
  21978. /**
  21979. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21980. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21981. * * 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`)
  21982. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21983. * * 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
  21984. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21985. * * If you create a double-sided mesh, you can choose what parts of 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
  21986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21987. * @param name defines the name of the mesh
  21988. * @param options defines the options used to create the mesh
  21989. * @param scene defines the hosting scene
  21990. * @returns a new Mesh
  21991. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21992. */
  21993. static CreateIcoSphere(name: string, options: {
  21994. radius?: number;
  21995. flat?: boolean;
  21996. subdivisions?: number;
  21997. sideOrientation?: number;
  21998. updatable?: boolean;
  21999. }, scene: Scene): Mesh;
  22000. /**
  22001. * Creates a decal mesh.
  22002. * Please consider using the same method from the MeshBuilder class instead.
  22003. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22004. * @param name defines the name of the mesh
  22005. * @param sourceMesh defines the mesh receiving the decal
  22006. * @param position sets the position of the decal in world coordinates
  22007. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22008. * @param size sets the decal scaling
  22009. * @param angle sets the angle to rotate the decal
  22010. * @returns a new Mesh
  22011. */
  22012. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22013. /**
  22014. * Prepare internal position array for software CPU skinning
  22015. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22016. */
  22017. setPositionsForCPUSkinning(): Float32Array;
  22018. /**
  22019. * Prepare internal normal array for software CPU skinning
  22020. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22021. */
  22022. setNormalsForCPUSkinning(): Float32Array;
  22023. /**
  22024. * Updates the vertex buffer by applying transformation from the bones
  22025. * @param skeleton defines the skeleton to apply to current mesh
  22026. * @returns the current mesh
  22027. */
  22028. applySkeleton(skeleton: Skeleton): Mesh;
  22029. /**
  22030. * 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
  22031. * @param meshes defines the list of meshes to scan
  22032. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22033. */
  22034. static MinMax(meshes: AbstractMesh[]): {
  22035. min: Vector3;
  22036. max: Vector3;
  22037. };
  22038. /**
  22039. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22040. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22041. * @returns a vector3
  22042. */
  22043. static Center(meshesOrMinMaxVector: {
  22044. min: Vector3;
  22045. max: Vector3;
  22046. } | AbstractMesh[]): Vector3;
  22047. /**
  22048. * Merge the array of meshes into a single mesh for performance reasons.
  22049. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22050. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22051. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22052. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22053. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22054. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22055. * @returns a new mesh
  22056. */
  22057. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22058. /** @hidden */
  22059. addInstance(instance: InstancedMesh): void;
  22060. /** @hidden */
  22061. removeInstance(instance: InstancedMesh): void;
  22062. }
  22063. }
  22064. declare module "babylonjs/Materials/material" {
  22065. import { IAnimatable } from "babylonjs/Misc/tools";
  22066. import { SmartArray } from "babylonjs/Misc/smartArray";
  22067. import { Observable } from "babylonjs/Misc/observable";
  22068. import { Nullable } from "babylonjs/types";
  22069. import { Scene } from "babylonjs/scene";
  22070. import { Matrix } from "babylonjs/Maths/math";
  22071. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22073. import { Mesh } from "babylonjs/Meshes/mesh";
  22074. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22075. import { Effect } from "babylonjs/Materials/effect";
  22076. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22077. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22078. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22079. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22080. import { Animation } from "babylonjs/Animations/animation";
  22081. /**
  22082. * Base class for the main features of a material in Babylon.js
  22083. */
  22084. export class Material implements IAnimatable {
  22085. /**
  22086. * Returns the triangle fill mode
  22087. */
  22088. static readonly TriangleFillMode: number;
  22089. /**
  22090. * Returns the wireframe mode
  22091. */
  22092. static readonly WireFrameFillMode: number;
  22093. /**
  22094. * Returns the point fill mode
  22095. */
  22096. static readonly PointFillMode: number;
  22097. /**
  22098. * Returns the point list draw mode
  22099. */
  22100. static readonly PointListDrawMode: number;
  22101. /**
  22102. * Returns the line list draw mode
  22103. */
  22104. static readonly LineListDrawMode: number;
  22105. /**
  22106. * Returns the line loop draw mode
  22107. */
  22108. static readonly LineLoopDrawMode: number;
  22109. /**
  22110. * Returns the line strip draw mode
  22111. */
  22112. static readonly LineStripDrawMode: number;
  22113. /**
  22114. * Returns the triangle strip draw mode
  22115. */
  22116. static readonly TriangleStripDrawMode: number;
  22117. /**
  22118. * Returns the triangle fan draw mode
  22119. */
  22120. static readonly TriangleFanDrawMode: number;
  22121. /**
  22122. * Stores the clock-wise side orientation
  22123. */
  22124. static readonly ClockWiseSideOrientation: number;
  22125. /**
  22126. * Stores the counter clock-wise side orientation
  22127. */
  22128. static readonly CounterClockWiseSideOrientation: number;
  22129. /**
  22130. * The dirty texture flag value
  22131. */
  22132. static readonly TextureDirtyFlag: number;
  22133. /**
  22134. * The dirty light flag value
  22135. */
  22136. static readonly LightDirtyFlag: number;
  22137. /**
  22138. * The dirty fresnel flag value
  22139. */
  22140. static readonly FresnelDirtyFlag: number;
  22141. /**
  22142. * The dirty attribute flag value
  22143. */
  22144. static readonly AttributesDirtyFlag: number;
  22145. /**
  22146. * The dirty misc flag value
  22147. */
  22148. static readonly MiscDirtyFlag: number;
  22149. /**
  22150. * The all dirty flag value
  22151. */
  22152. static readonly AllDirtyFlag: number;
  22153. /**
  22154. * The ID of the material
  22155. */
  22156. id: string;
  22157. /**
  22158. * Gets or sets the unique id of the material
  22159. */
  22160. uniqueId: number;
  22161. /**
  22162. * The name of the material
  22163. */
  22164. name: string;
  22165. /**
  22166. * Gets or sets user defined metadata
  22167. */
  22168. metadata: any;
  22169. /**
  22170. * For internal use only. Please do not use.
  22171. */
  22172. reservedDataStore: any;
  22173. /**
  22174. * Specifies if the ready state should be checked on each call
  22175. */
  22176. checkReadyOnEveryCall: boolean;
  22177. /**
  22178. * Specifies if the ready state should be checked once
  22179. */
  22180. checkReadyOnlyOnce: boolean;
  22181. /**
  22182. * The state of the material
  22183. */
  22184. state: string;
  22185. /**
  22186. * The alpha value of the material
  22187. */
  22188. protected _alpha: number;
  22189. /**
  22190. * List of inspectable custom properties (used by the Inspector)
  22191. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22192. */
  22193. inspectableCustomProperties: IInspectable[];
  22194. /**
  22195. * Sets the alpha value of the material
  22196. */
  22197. /**
  22198. * Gets the alpha value of the material
  22199. */
  22200. alpha: number;
  22201. /**
  22202. * Specifies if back face culling is enabled
  22203. */
  22204. protected _backFaceCulling: boolean;
  22205. /**
  22206. * Sets the back-face culling state
  22207. */
  22208. /**
  22209. * Gets the back-face culling state
  22210. */
  22211. backFaceCulling: boolean;
  22212. /**
  22213. * Stores the value for side orientation
  22214. */
  22215. sideOrientation: number;
  22216. /**
  22217. * Callback triggered when the material is compiled
  22218. */
  22219. onCompiled: (effect: Effect) => void;
  22220. /**
  22221. * Callback triggered when an error occurs
  22222. */
  22223. onError: (effect: Effect, errors: string) => void;
  22224. /**
  22225. * Callback triggered to get the render target textures
  22226. */
  22227. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22228. /**
  22229. * Gets a boolean indicating that current material needs to register RTT
  22230. */
  22231. readonly hasRenderTargetTextures: boolean;
  22232. /**
  22233. * Specifies if the material should be serialized
  22234. */
  22235. doNotSerialize: boolean;
  22236. /**
  22237. * @hidden
  22238. */
  22239. _storeEffectOnSubMeshes: boolean;
  22240. /**
  22241. * Stores the animations for the material
  22242. */
  22243. animations: Array<Animation>;
  22244. /**
  22245. * An event triggered when the material is disposed
  22246. */
  22247. onDisposeObservable: Observable<Material>;
  22248. /**
  22249. * An observer which watches for dispose events
  22250. */
  22251. private _onDisposeObserver;
  22252. private _onUnBindObservable;
  22253. /**
  22254. * Called during a dispose event
  22255. */
  22256. onDispose: () => void;
  22257. private _onBindObservable;
  22258. /**
  22259. * An event triggered when the material is bound
  22260. */
  22261. readonly onBindObservable: Observable<AbstractMesh>;
  22262. /**
  22263. * An observer which watches for bind events
  22264. */
  22265. private _onBindObserver;
  22266. /**
  22267. * Called during a bind event
  22268. */
  22269. onBind: (Mesh: AbstractMesh) => void;
  22270. /**
  22271. * An event triggered when the material is unbound
  22272. */
  22273. readonly onUnBindObservable: Observable<Material>;
  22274. /**
  22275. * Stores the value of the alpha mode
  22276. */
  22277. private _alphaMode;
  22278. /**
  22279. * Sets the value of the alpha mode.
  22280. *
  22281. * | Value | Type | Description |
  22282. * | --- | --- | --- |
  22283. * | 0 | ALPHA_DISABLE | |
  22284. * | 1 | ALPHA_ADD | |
  22285. * | 2 | ALPHA_COMBINE | |
  22286. * | 3 | ALPHA_SUBTRACT | |
  22287. * | 4 | ALPHA_MULTIPLY | |
  22288. * | 5 | ALPHA_MAXIMIZED | |
  22289. * | 6 | ALPHA_ONEONE | |
  22290. * | 7 | ALPHA_PREMULTIPLIED | |
  22291. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22292. * | 9 | ALPHA_INTERPOLATE | |
  22293. * | 10 | ALPHA_SCREENMODE | |
  22294. *
  22295. */
  22296. /**
  22297. * Gets the value of the alpha mode
  22298. */
  22299. alphaMode: number;
  22300. /**
  22301. * Stores the state of the need depth pre-pass value
  22302. */
  22303. private _needDepthPrePass;
  22304. /**
  22305. * Sets the need depth pre-pass value
  22306. */
  22307. /**
  22308. * Gets the depth pre-pass value
  22309. */
  22310. needDepthPrePass: boolean;
  22311. /**
  22312. * Specifies if depth writing should be disabled
  22313. */
  22314. disableDepthWrite: boolean;
  22315. /**
  22316. * Specifies if depth writing should be forced
  22317. */
  22318. forceDepthWrite: boolean;
  22319. /**
  22320. * Specifies if there should be a separate pass for culling
  22321. */
  22322. separateCullingPass: boolean;
  22323. /**
  22324. * Stores the state specifing if fog should be enabled
  22325. */
  22326. private _fogEnabled;
  22327. /**
  22328. * Sets the state for enabling fog
  22329. */
  22330. /**
  22331. * Gets the value of the fog enabled state
  22332. */
  22333. fogEnabled: boolean;
  22334. /**
  22335. * Stores the size of points
  22336. */
  22337. pointSize: number;
  22338. /**
  22339. * Stores the z offset value
  22340. */
  22341. zOffset: number;
  22342. /**
  22343. * Gets a value specifying if wireframe mode is enabled
  22344. */
  22345. /**
  22346. * Sets the state of wireframe mode
  22347. */
  22348. wireframe: boolean;
  22349. /**
  22350. * Gets the value specifying if point clouds are enabled
  22351. */
  22352. /**
  22353. * Sets the state of point cloud mode
  22354. */
  22355. pointsCloud: boolean;
  22356. /**
  22357. * Gets the material fill mode
  22358. */
  22359. /**
  22360. * Sets the material fill mode
  22361. */
  22362. fillMode: number;
  22363. /**
  22364. * @hidden
  22365. * Stores the effects for the material
  22366. */
  22367. _effect: Nullable<Effect>;
  22368. /**
  22369. * @hidden
  22370. * Specifies if the material was previously ready
  22371. */
  22372. _wasPreviouslyReady: boolean;
  22373. /**
  22374. * Specifies if uniform buffers should be used
  22375. */
  22376. private _useUBO;
  22377. /**
  22378. * Stores a reference to the scene
  22379. */
  22380. private _scene;
  22381. /**
  22382. * Stores the fill mode state
  22383. */
  22384. private _fillMode;
  22385. /**
  22386. * Specifies if the depth write state should be cached
  22387. */
  22388. private _cachedDepthWriteState;
  22389. /**
  22390. * Stores the uniform buffer
  22391. */
  22392. protected _uniformBuffer: UniformBuffer;
  22393. /** @hidden */
  22394. _indexInSceneMaterialArray: number;
  22395. /** @hidden */
  22396. meshMap: Nullable<{
  22397. [id: string]: AbstractMesh | undefined;
  22398. }>;
  22399. /**
  22400. * Creates a material instance
  22401. * @param name defines the name of the material
  22402. * @param scene defines the scene to reference
  22403. * @param doNotAdd specifies if the material should be added to the scene
  22404. */
  22405. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22406. /**
  22407. * Returns a string representation of the current material
  22408. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22409. * @returns a string with material information
  22410. */
  22411. toString(fullDetails?: boolean): string;
  22412. /**
  22413. * Gets the class name of the material
  22414. * @returns a string with the class name of the material
  22415. */
  22416. getClassName(): string;
  22417. /**
  22418. * Specifies if updates for the material been locked
  22419. */
  22420. readonly isFrozen: boolean;
  22421. /**
  22422. * Locks updates for the material
  22423. */
  22424. freeze(): void;
  22425. /**
  22426. * Unlocks updates for the material
  22427. */
  22428. unfreeze(): void;
  22429. /**
  22430. * Specifies if the material is ready to be used
  22431. * @param mesh defines the mesh to check
  22432. * @param useInstances specifies if instances should be used
  22433. * @returns a boolean indicating if the material is ready to be used
  22434. */
  22435. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22436. /**
  22437. * Specifies that the submesh is ready to be used
  22438. * @param mesh defines the mesh to check
  22439. * @param subMesh defines which submesh to check
  22440. * @param useInstances specifies that instances should be used
  22441. * @returns a boolean indicating that the submesh is ready or not
  22442. */
  22443. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22444. /**
  22445. * Returns the material effect
  22446. * @returns the effect associated with the material
  22447. */
  22448. getEffect(): Nullable<Effect>;
  22449. /**
  22450. * Returns the current scene
  22451. * @returns a Scene
  22452. */
  22453. getScene(): Scene;
  22454. /**
  22455. * Specifies if the material will require alpha blending
  22456. * @returns a boolean specifying if alpha blending is needed
  22457. */
  22458. needAlphaBlending(): boolean;
  22459. /**
  22460. * Specifies if the mesh will require alpha blending
  22461. * @param mesh defines the mesh to check
  22462. * @returns a boolean specifying if alpha blending is needed for the mesh
  22463. */
  22464. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22465. /**
  22466. * Specifies if this material should be rendered in alpha test mode
  22467. * @returns a boolean specifying if an alpha test is needed.
  22468. */
  22469. needAlphaTesting(): boolean;
  22470. /**
  22471. * Gets the texture used for the alpha test
  22472. * @returns the texture to use for alpha testing
  22473. */
  22474. getAlphaTestTexture(): Nullable<BaseTexture>;
  22475. /**
  22476. * Marks the material to indicate that it needs to be re-calculated
  22477. */
  22478. markDirty(): void;
  22479. /** @hidden */
  22480. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22481. /**
  22482. * Binds the material to the mesh
  22483. * @param world defines the world transformation matrix
  22484. * @param mesh defines the mesh to bind the material to
  22485. */
  22486. bind(world: Matrix, mesh?: Mesh): void;
  22487. /**
  22488. * Binds the submesh to the material
  22489. * @param world defines the world transformation matrix
  22490. * @param mesh defines the mesh containing the submesh
  22491. * @param subMesh defines the submesh to bind the material to
  22492. */
  22493. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22494. /**
  22495. * Binds the world matrix to the material
  22496. * @param world defines the world transformation matrix
  22497. */
  22498. bindOnlyWorldMatrix(world: Matrix): void;
  22499. /**
  22500. * Binds the scene's uniform buffer to the effect.
  22501. * @param effect defines the effect to bind to the scene uniform buffer
  22502. * @param sceneUbo defines the uniform buffer storing scene data
  22503. */
  22504. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22505. /**
  22506. * Binds the view matrix to the effect
  22507. * @param effect defines the effect to bind the view matrix to
  22508. */
  22509. bindView(effect: Effect): void;
  22510. /**
  22511. * Binds the view projection matrix to the effect
  22512. * @param effect defines the effect to bind the view projection matrix to
  22513. */
  22514. bindViewProjection(effect: Effect): void;
  22515. /**
  22516. * Specifies if material alpha testing should be turned on for the mesh
  22517. * @param mesh defines the mesh to check
  22518. */
  22519. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22520. /**
  22521. * Processes to execute after binding the material to a mesh
  22522. * @param mesh defines the rendered mesh
  22523. */
  22524. protected _afterBind(mesh?: Mesh): void;
  22525. /**
  22526. * Unbinds the material from the mesh
  22527. */
  22528. unbind(): void;
  22529. /**
  22530. * Gets the active textures from the material
  22531. * @returns an array of textures
  22532. */
  22533. getActiveTextures(): BaseTexture[];
  22534. /**
  22535. * Specifies if the material uses a texture
  22536. * @param texture defines the texture to check against the material
  22537. * @returns a boolean specifying if the material uses the texture
  22538. */
  22539. hasTexture(texture: BaseTexture): boolean;
  22540. /**
  22541. * Makes a duplicate of the material, and gives it a new name
  22542. * @param name defines the new name for the duplicated material
  22543. * @returns the cloned material
  22544. */
  22545. clone(name: string): Nullable<Material>;
  22546. /**
  22547. * Gets the meshes bound to the material
  22548. * @returns an array of meshes bound to the material
  22549. */
  22550. getBindedMeshes(): AbstractMesh[];
  22551. /**
  22552. * Force shader compilation
  22553. * @param mesh defines the mesh associated with this material
  22554. * @param onCompiled defines a function to execute once the material is compiled
  22555. * @param options defines the options to configure the compilation
  22556. */
  22557. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22558. clipPlane: boolean;
  22559. }>): void;
  22560. /**
  22561. * Force shader compilation
  22562. * @param mesh defines the mesh that will use this material
  22563. * @param options defines additional options for compiling the shaders
  22564. * @returns a promise that resolves when the compilation completes
  22565. */
  22566. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22567. clipPlane: boolean;
  22568. }>): Promise<void>;
  22569. private static readonly _ImageProcessingDirtyCallBack;
  22570. private static readonly _TextureDirtyCallBack;
  22571. private static readonly _FresnelDirtyCallBack;
  22572. private static readonly _MiscDirtyCallBack;
  22573. private static readonly _LightsDirtyCallBack;
  22574. private static readonly _AttributeDirtyCallBack;
  22575. private static _FresnelAndMiscDirtyCallBack;
  22576. private static _TextureAndMiscDirtyCallBack;
  22577. private static readonly _DirtyCallbackArray;
  22578. private static readonly _RunDirtyCallBacks;
  22579. /**
  22580. * Marks a define in the material to indicate that it needs to be re-computed
  22581. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22582. */
  22583. markAsDirty(flag: number): void;
  22584. /**
  22585. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22586. * @param func defines a function which checks material defines against the submeshes
  22587. */
  22588. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22589. /**
  22590. * Indicates that image processing needs to be re-calculated for all submeshes
  22591. */
  22592. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22593. /**
  22594. * Indicates that textures need to be re-calculated for all submeshes
  22595. */
  22596. protected _markAllSubMeshesAsTexturesDirty(): void;
  22597. /**
  22598. * Indicates that fresnel needs to be re-calculated for all submeshes
  22599. */
  22600. protected _markAllSubMeshesAsFresnelDirty(): void;
  22601. /**
  22602. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22603. */
  22604. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22605. /**
  22606. * Indicates that lights need to be re-calculated for all submeshes
  22607. */
  22608. protected _markAllSubMeshesAsLightsDirty(): void;
  22609. /**
  22610. * Indicates that attributes need to be re-calculated for all submeshes
  22611. */
  22612. protected _markAllSubMeshesAsAttributesDirty(): void;
  22613. /**
  22614. * Indicates that misc needs to be re-calculated for all submeshes
  22615. */
  22616. protected _markAllSubMeshesAsMiscDirty(): void;
  22617. /**
  22618. * Indicates that textures and misc need to be re-calculated for all submeshes
  22619. */
  22620. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22621. /**
  22622. * Disposes the material
  22623. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22624. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22625. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22626. */
  22627. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22628. /** @hidden */
  22629. private releaseVertexArrayObject;
  22630. /**
  22631. * Serializes this material
  22632. * @returns the serialized material object
  22633. */
  22634. serialize(): any;
  22635. /**
  22636. * Creates a material from parsed material data
  22637. * @param parsedMaterial defines parsed material data
  22638. * @param scene defines the hosting scene
  22639. * @param rootUrl defines the root URL to use to load textures
  22640. * @returns a new material
  22641. */
  22642. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22643. }
  22644. }
  22645. declare module "babylonjs/Meshes/subMesh" {
  22646. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22647. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22648. import { Engine } from "babylonjs/Engines/engine";
  22649. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22650. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22651. import { Effect } from "babylonjs/Materials/effect";
  22652. import { Collider } from "babylonjs/Collisions/collider";
  22653. import { Material } from "babylonjs/Materials/material";
  22654. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22656. import { Mesh } from "babylonjs/Meshes/mesh";
  22657. import { Ray } from "babylonjs/Culling/ray";
  22658. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22659. /**
  22660. * Base class for submeshes
  22661. */
  22662. export class BaseSubMesh {
  22663. /** @hidden */
  22664. _materialDefines: Nullable<MaterialDefines>;
  22665. /** @hidden */
  22666. _materialEffect: Nullable<Effect>;
  22667. /**
  22668. * Gets associated effect
  22669. */
  22670. readonly effect: Nullable<Effect>;
  22671. /**
  22672. * Sets associated effect (effect used to render this submesh)
  22673. * @param effect defines the effect to associate with
  22674. * @param defines defines the set of defines used to compile this effect
  22675. */
  22676. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22677. }
  22678. /**
  22679. * Defines a subdivision inside a mesh
  22680. */
  22681. export class SubMesh extends BaseSubMesh implements ICullable {
  22682. /** the material index to use */
  22683. materialIndex: number;
  22684. /** vertex index start */
  22685. verticesStart: number;
  22686. /** vertices count */
  22687. verticesCount: number;
  22688. /** index start */
  22689. indexStart: number;
  22690. /** indices count */
  22691. indexCount: number;
  22692. /** @hidden */
  22693. _linesIndexCount: number;
  22694. private _mesh;
  22695. private _renderingMesh;
  22696. private _boundingInfo;
  22697. private _linesIndexBuffer;
  22698. /** @hidden */
  22699. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22700. /** @hidden */
  22701. _trianglePlanes: Plane[];
  22702. /** @hidden */
  22703. _lastColliderTransformMatrix: Matrix;
  22704. /** @hidden */
  22705. _renderId: number;
  22706. /** @hidden */
  22707. _alphaIndex: number;
  22708. /** @hidden */
  22709. _distanceToCamera: number;
  22710. /** @hidden */
  22711. _id: number;
  22712. private _currentMaterial;
  22713. /**
  22714. * Add a new submesh to a mesh
  22715. * @param materialIndex defines the material index to use
  22716. * @param verticesStart defines vertex index start
  22717. * @param verticesCount defines vertices count
  22718. * @param indexStart defines index start
  22719. * @param indexCount defines indices count
  22720. * @param mesh defines the parent mesh
  22721. * @param renderingMesh defines an optional rendering mesh
  22722. * @param createBoundingBox defines if bounding box should be created for this submesh
  22723. * @returns the new submesh
  22724. */
  22725. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22726. /**
  22727. * Creates a new submesh
  22728. * @param materialIndex defines the material index to use
  22729. * @param verticesStart defines vertex index start
  22730. * @param verticesCount defines vertices count
  22731. * @param indexStart defines index start
  22732. * @param indexCount defines indices count
  22733. * @param mesh defines the parent mesh
  22734. * @param renderingMesh defines an optional rendering mesh
  22735. * @param createBoundingBox defines if bounding box should be created for this submesh
  22736. */
  22737. constructor(
  22738. /** the material index to use */
  22739. materialIndex: number,
  22740. /** vertex index start */
  22741. verticesStart: number,
  22742. /** vertices count */
  22743. verticesCount: number,
  22744. /** index start */
  22745. indexStart: number,
  22746. /** indices count */
  22747. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22748. /**
  22749. * Returns true if this submesh covers the entire parent mesh
  22750. * @ignorenaming
  22751. */
  22752. readonly IsGlobal: boolean;
  22753. /**
  22754. * Returns the submesh BoudingInfo object
  22755. * @returns current bounding info (or mesh's one if the submesh is global)
  22756. */
  22757. getBoundingInfo(): BoundingInfo;
  22758. /**
  22759. * Sets the submesh BoundingInfo
  22760. * @param boundingInfo defines the new bounding info to use
  22761. * @returns the SubMesh
  22762. */
  22763. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22764. /**
  22765. * Returns the mesh of the current submesh
  22766. * @return the parent mesh
  22767. */
  22768. getMesh(): AbstractMesh;
  22769. /**
  22770. * Returns the rendering mesh of the submesh
  22771. * @returns the rendering mesh (could be different from parent mesh)
  22772. */
  22773. getRenderingMesh(): Mesh;
  22774. /**
  22775. * Returns the submesh material
  22776. * @returns null or the current material
  22777. */
  22778. getMaterial(): Nullable<Material>;
  22779. /**
  22780. * Sets a new updated BoundingInfo object to the submesh
  22781. * @returns the SubMesh
  22782. */
  22783. refreshBoundingInfo(): SubMesh;
  22784. /** @hidden */
  22785. _checkCollision(collider: Collider): boolean;
  22786. /**
  22787. * Updates the submesh BoundingInfo
  22788. * @param world defines the world matrix to use to update the bounding info
  22789. * @returns the submesh
  22790. */
  22791. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22792. /**
  22793. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22794. * @param frustumPlanes defines the frustum planes
  22795. * @returns true if the submesh is intersecting with the frustum
  22796. */
  22797. isInFrustum(frustumPlanes: Plane[]): boolean;
  22798. /**
  22799. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22800. * @param frustumPlanes defines the frustum planes
  22801. * @returns true if the submesh is inside the frustum
  22802. */
  22803. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22804. /**
  22805. * Renders the submesh
  22806. * @param enableAlphaMode defines if alpha needs to be used
  22807. * @returns the submesh
  22808. */
  22809. render(enableAlphaMode: boolean): SubMesh;
  22810. /**
  22811. * @hidden
  22812. */
  22813. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22814. /**
  22815. * Checks if the submesh intersects with a ray
  22816. * @param ray defines the ray to test
  22817. * @returns true is the passed ray intersects the submesh bounding box
  22818. */
  22819. canIntersects(ray: Ray): boolean;
  22820. /**
  22821. * Intersects current submesh with a ray
  22822. * @param ray defines the ray to test
  22823. * @param positions defines mesh's positions array
  22824. * @param indices defines mesh's indices array
  22825. * @param fastCheck defines if only bounding info should be used
  22826. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22827. * @returns intersection info or null if no intersection
  22828. */
  22829. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22830. /** @hidden */
  22831. private _intersectLines;
  22832. /** @hidden */
  22833. private _intersectTriangles;
  22834. /** @hidden */
  22835. _rebuild(): void;
  22836. /**
  22837. * Creates a new submesh from the passed mesh
  22838. * @param newMesh defines the new hosting mesh
  22839. * @param newRenderingMesh defines an optional rendering mesh
  22840. * @returns the new submesh
  22841. */
  22842. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22843. /**
  22844. * Release associated resources
  22845. */
  22846. dispose(): void;
  22847. /**
  22848. * Gets the class name
  22849. * @returns the string "SubMesh".
  22850. */
  22851. getClassName(): string;
  22852. /**
  22853. * Creates a new submesh from indices data
  22854. * @param materialIndex the index of the main mesh material
  22855. * @param startIndex the index where to start the copy in the mesh indices array
  22856. * @param indexCount the number of indices to copy then from the startIndex
  22857. * @param mesh the main mesh to create the submesh from
  22858. * @param renderingMesh the optional rendering mesh
  22859. * @returns a new submesh
  22860. */
  22861. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22862. }
  22863. }
  22864. declare module "babylonjs/Meshes/geometry" {
  22865. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22866. import { Scene } from "babylonjs/scene";
  22867. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22868. import { Engine } from "babylonjs/Engines/engine";
  22869. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22870. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22871. import { Effect } from "babylonjs/Materials/effect";
  22872. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22873. import { Mesh } from "babylonjs/Meshes/mesh";
  22874. /**
  22875. * Class used to store geometry data (vertex buffers + index buffer)
  22876. */
  22877. export class Geometry implements IGetSetVerticesData {
  22878. /**
  22879. * Gets or sets the ID of the geometry
  22880. */
  22881. id: string;
  22882. /**
  22883. * Gets or sets the unique ID of the geometry
  22884. */
  22885. uniqueId: number;
  22886. /**
  22887. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22888. */
  22889. delayLoadState: number;
  22890. /**
  22891. * Gets the file containing the data to load when running in delay load state
  22892. */
  22893. delayLoadingFile: Nullable<string>;
  22894. /**
  22895. * Callback called when the geometry is updated
  22896. */
  22897. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22898. private _scene;
  22899. private _engine;
  22900. private _meshes;
  22901. private _totalVertices;
  22902. /** @hidden */
  22903. _indices: IndicesArray;
  22904. /** @hidden */
  22905. _vertexBuffers: {
  22906. [key: string]: VertexBuffer;
  22907. };
  22908. private _isDisposed;
  22909. private _extend;
  22910. private _boundingBias;
  22911. /** @hidden */
  22912. _delayInfo: Array<string>;
  22913. private _indexBuffer;
  22914. private _indexBufferIsUpdatable;
  22915. /** @hidden */
  22916. _boundingInfo: Nullable<BoundingInfo>;
  22917. /** @hidden */
  22918. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22919. /** @hidden */
  22920. _softwareSkinningFrameId: number;
  22921. private _vertexArrayObjects;
  22922. private _updatable;
  22923. /** @hidden */
  22924. _positions: Nullable<Vector3[]>;
  22925. /**
  22926. * 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
  22927. */
  22928. /**
  22929. * 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
  22930. */
  22931. boundingBias: Vector2;
  22932. /**
  22933. * Static function used to attach a new empty geometry to a mesh
  22934. * @param mesh defines the mesh to attach the geometry to
  22935. * @returns the new Geometry
  22936. */
  22937. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22938. /**
  22939. * Creates a new geometry
  22940. * @param id defines the unique ID
  22941. * @param scene defines the hosting scene
  22942. * @param vertexData defines the VertexData used to get geometry data
  22943. * @param updatable defines if geometry must be updatable (false by default)
  22944. * @param mesh defines the mesh that will be associated with the geometry
  22945. */
  22946. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22947. /**
  22948. * Gets the current extend of the geometry
  22949. */
  22950. readonly extend: {
  22951. minimum: Vector3;
  22952. maximum: Vector3;
  22953. };
  22954. /**
  22955. * Gets the hosting scene
  22956. * @returns the hosting Scene
  22957. */
  22958. getScene(): Scene;
  22959. /**
  22960. * Gets the hosting engine
  22961. * @returns the hosting Engine
  22962. */
  22963. getEngine(): Engine;
  22964. /**
  22965. * Defines if the geometry is ready to use
  22966. * @returns true if the geometry is ready to be used
  22967. */
  22968. isReady(): boolean;
  22969. /**
  22970. * Gets a value indicating that the geometry should not be serialized
  22971. */
  22972. readonly doNotSerialize: boolean;
  22973. /** @hidden */
  22974. _rebuild(): void;
  22975. /**
  22976. * Affects all geometry data in one call
  22977. * @param vertexData defines the geometry data
  22978. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22979. */
  22980. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22981. /**
  22982. * Set specific vertex data
  22983. * @param kind defines the data kind (Position, normal, etc...)
  22984. * @param data defines the vertex data to use
  22985. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22986. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22987. */
  22988. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22989. /**
  22990. * Removes a specific vertex data
  22991. * @param kind defines the data kind (Position, normal, etc...)
  22992. */
  22993. removeVerticesData(kind: string): void;
  22994. /**
  22995. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22996. * @param buffer defines the vertex buffer to use
  22997. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22998. */
  22999. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23000. /**
  23001. * Update a specific vertex buffer
  23002. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  23003. * It will do nothing if the buffer is not updatable
  23004. * @param kind defines the data kind (Position, normal, etc...)
  23005. * @param data defines the data to use
  23006. * @param offset defines the offset in the target buffer where to store the data
  23007. * @param useBytes set to true if the offset is in bytes
  23008. */
  23009. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23010. /**
  23011. * Update a specific vertex buffer
  23012. * This function will create a new buffer if the current one is not updatable
  23013. * @param kind defines the data kind (Position, normal, etc...)
  23014. * @param data defines the data to use
  23015. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23016. */
  23017. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23018. private _updateBoundingInfo;
  23019. /** @hidden */
  23020. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  23021. /**
  23022. * Gets total number of vertices
  23023. * @returns the total number of vertices
  23024. */
  23025. getTotalVertices(): number;
  23026. /**
  23027. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23028. * @param kind defines the data kind (Position, normal, etc...)
  23029. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23030. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23031. * @returns a float array containing vertex data
  23032. */
  23033. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23034. /**
  23035. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23036. * @param kind defines the data kind (Position, normal, etc...)
  23037. * @returns true if the vertex buffer with the specified kind is updatable
  23038. */
  23039. isVertexBufferUpdatable(kind: string): boolean;
  23040. /**
  23041. * Gets a specific vertex buffer
  23042. * @param kind defines the data kind (Position, normal, etc...)
  23043. * @returns a VertexBuffer
  23044. */
  23045. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23046. /**
  23047. * Returns all vertex buffers
  23048. * @return an object holding all vertex buffers indexed by kind
  23049. */
  23050. getVertexBuffers(): Nullable<{
  23051. [key: string]: VertexBuffer;
  23052. }>;
  23053. /**
  23054. * Gets a boolean indicating if specific vertex buffer is present
  23055. * @param kind defines the data kind (Position, normal, etc...)
  23056. * @returns true if data is present
  23057. */
  23058. isVerticesDataPresent(kind: string): boolean;
  23059. /**
  23060. * Gets a list of all attached data kinds (Position, normal, etc...)
  23061. * @returns a list of string containing all kinds
  23062. */
  23063. getVerticesDataKinds(): string[];
  23064. /**
  23065. * Update index buffer
  23066. * @param indices defines the indices to store in the index buffer
  23067. * @param offset defines the offset in the target buffer where to store the data
  23068. * @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)
  23069. */
  23070. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23071. /**
  23072. * Creates a new index buffer
  23073. * @param indices defines the indices to store in the index buffer
  23074. * @param totalVertices defines the total number of vertices (could be null)
  23075. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23076. */
  23077. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23078. /**
  23079. * Return the total number of indices
  23080. * @returns the total number of indices
  23081. */
  23082. getTotalIndices(): number;
  23083. /**
  23084. * Gets the index buffer array
  23085. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23086. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23087. * @returns the index buffer array
  23088. */
  23089. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23090. /**
  23091. * Gets the index buffer
  23092. * @return the index buffer
  23093. */
  23094. getIndexBuffer(): Nullable<WebGLBuffer>;
  23095. /** @hidden */
  23096. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23097. /**
  23098. * Release the associated resources for a specific mesh
  23099. * @param mesh defines the source mesh
  23100. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23101. */
  23102. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23103. /**
  23104. * Apply current geometry to a given mesh
  23105. * @param mesh defines the mesh to apply geometry to
  23106. */
  23107. applyToMesh(mesh: Mesh): void;
  23108. private _updateExtend;
  23109. private _applyToMesh;
  23110. private notifyUpdate;
  23111. /**
  23112. * Load the geometry if it was flagged as delay loaded
  23113. * @param scene defines the hosting scene
  23114. * @param onLoaded defines a callback called when the geometry is loaded
  23115. */
  23116. load(scene: Scene, onLoaded?: () => void): void;
  23117. private _queueLoad;
  23118. /**
  23119. * Invert the geometry to move from a right handed system to a left handed one.
  23120. */
  23121. toLeftHanded(): void;
  23122. /** @hidden */
  23123. _resetPointsArrayCache(): void;
  23124. /** @hidden */
  23125. _generatePointsArray(): boolean;
  23126. /**
  23127. * Gets a value indicating if the geometry is disposed
  23128. * @returns true if the geometry was disposed
  23129. */
  23130. isDisposed(): boolean;
  23131. private _disposeVertexArrayObjects;
  23132. /**
  23133. * Free all associated resources
  23134. */
  23135. dispose(): void;
  23136. /**
  23137. * Clone the current geometry into a new geometry
  23138. * @param id defines the unique ID of the new geometry
  23139. * @returns a new geometry object
  23140. */
  23141. copy(id: string): Geometry;
  23142. /**
  23143. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23144. * @return a JSON representation of the current geometry data (without the vertices data)
  23145. */
  23146. serialize(): any;
  23147. private toNumberArray;
  23148. /**
  23149. * Serialize all vertices data into a JSON oject
  23150. * @returns a JSON representation of the current geometry data
  23151. */
  23152. serializeVerticeData(): any;
  23153. /**
  23154. * Extracts a clone of a mesh geometry
  23155. * @param mesh defines the source mesh
  23156. * @param id defines the unique ID of the new geometry object
  23157. * @returns the new geometry object
  23158. */
  23159. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23160. /**
  23161. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23162. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23163. * Be aware Math.random() could cause collisions, but:
  23164. * "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"
  23165. * @returns a string containing a new GUID
  23166. */
  23167. static RandomId(): string;
  23168. /** @hidden */
  23169. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23170. private static _CleanMatricesWeights;
  23171. /**
  23172. * Create a new geometry from persisted data (Using .babylon file format)
  23173. * @param parsedVertexData defines the persisted data
  23174. * @param scene defines the hosting scene
  23175. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23176. * @returns the new geometry object
  23177. */
  23178. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23179. }
  23180. }
  23181. declare module "babylonjs/Meshes/mesh.vertexData" {
  23182. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23183. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23184. import { Geometry } from "babylonjs/Meshes/geometry";
  23185. import { Mesh } from "babylonjs/Meshes/mesh";
  23186. /**
  23187. * Define an interface for all classes that will get and set the data on vertices
  23188. */
  23189. export interface IGetSetVerticesData {
  23190. /**
  23191. * Gets a boolean indicating if specific vertex data is present
  23192. * @param kind defines the vertex data kind to use
  23193. * @returns true is data kind is present
  23194. */
  23195. isVerticesDataPresent(kind: string): boolean;
  23196. /**
  23197. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23198. * @param kind defines the data kind (Position, normal, etc...)
  23199. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23200. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23201. * @returns a float array containing vertex data
  23202. */
  23203. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23204. /**
  23205. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23206. * @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.
  23207. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23208. * @returns the indices array or an empty array if the mesh has no geometry
  23209. */
  23210. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23211. /**
  23212. * Set specific vertex data
  23213. * @param kind defines the data kind (Position, normal, etc...)
  23214. * @param data defines the vertex data to use
  23215. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23216. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23217. */
  23218. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23219. /**
  23220. * Update a specific associated vertex buffer
  23221. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23222. * - VertexBuffer.PositionKind
  23223. * - VertexBuffer.UVKind
  23224. * - VertexBuffer.UV2Kind
  23225. * - VertexBuffer.UV3Kind
  23226. * - VertexBuffer.UV4Kind
  23227. * - VertexBuffer.UV5Kind
  23228. * - VertexBuffer.UV6Kind
  23229. * - VertexBuffer.ColorKind
  23230. * - VertexBuffer.MatricesIndicesKind
  23231. * - VertexBuffer.MatricesIndicesExtraKind
  23232. * - VertexBuffer.MatricesWeightsKind
  23233. * - VertexBuffer.MatricesWeightsExtraKind
  23234. * @param data defines the data source
  23235. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23236. * @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)
  23237. */
  23238. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23239. /**
  23240. * Creates a new index buffer
  23241. * @param indices defines the indices to store in the index buffer
  23242. * @param totalVertices defines the total number of vertices (could be null)
  23243. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23244. */
  23245. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23246. }
  23247. /**
  23248. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23249. */
  23250. export class VertexData {
  23251. /**
  23252. * Mesh side orientation : usually the external or front surface
  23253. */
  23254. static readonly FRONTSIDE: number;
  23255. /**
  23256. * Mesh side orientation : usually the internal or back surface
  23257. */
  23258. static readonly BACKSIDE: number;
  23259. /**
  23260. * Mesh side orientation : both internal and external or front and back surfaces
  23261. */
  23262. static readonly DOUBLESIDE: number;
  23263. /**
  23264. * Mesh side orientation : by default, `FRONTSIDE`
  23265. */
  23266. static readonly DEFAULTSIDE: number;
  23267. /**
  23268. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23269. */
  23270. positions: Nullable<FloatArray>;
  23271. /**
  23272. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23273. */
  23274. normals: Nullable<FloatArray>;
  23275. /**
  23276. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23277. */
  23278. tangents: Nullable<FloatArray>;
  23279. /**
  23280. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23281. */
  23282. uvs: Nullable<FloatArray>;
  23283. /**
  23284. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23285. */
  23286. uvs2: Nullable<FloatArray>;
  23287. /**
  23288. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23289. */
  23290. uvs3: Nullable<FloatArray>;
  23291. /**
  23292. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23293. */
  23294. uvs4: Nullable<FloatArray>;
  23295. /**
  23296. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23297. */
  23298. uvs5: Nullable<FloatArray>;
  23299. /**
  23300. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23301. */
  23302. uvs6: Nullable<FloatArray>;
  23303. /**
  23304. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23305. */
  23306. colors: Nullable<FloatArray>;
  23307. /**
  23308. * 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).
  23309. */
  23310. matricesIndices: Nullable<FloatArray>;
  23311. /**
  23312. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23313. */
  23314. matricesWeights: Nullable<FloatArray>;
  23315. /**
  23316. * An array extending the number of possible indices
  23317. */
  23318. matricesIndicesExtra: Nullable<FloatArray>;
  23319. /**
  23320. * An array extending the number of possible weights when the number of indices is extended
  23321. */
  23322. matricesWeightsExtra: Nullable<FloatArray>;
  23323. /**
  23324. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23325. */
  23326. indices: Nullable<IndicesArray>;
  23327. /**
  23328. * Uses the passed data array to set the set the values for the specified kind of data
  23329. * @param data a linear array of floating numbers
  23330. * @param kind the type of data that is being set, eg positions, colors etc
  23331. */
  23332. set(data: FloatArray, kind: string): void;
  23333. /**
  23334. * Associates the vertexData to the passed Mesh.
  23335. * Sets it as updatable or not (default `false`)
  23336. * @param mesh the mesh the vertexData is applied to
  23337. * @param updatable when used and having the value true allows new data to update the vertexData
  23338. * @returns the VertexData
  23339. */
  23340. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23341. /**
  23342. * Associates the vertexData to the passed Geometry.
  23343. * Sets it as updatable or not (default `false`)
  23344. * @param geometry the geometry the vertexData is applied to
  23345. * @param updatable when used and having the value true allows new data to update the vertexData
  23346. * @returns VertexData
  23347. */
  23348. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23349. /**
  23350. * Updates the associated mesh
  23351. * @param mesh the mesh to be updated
  23352. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23353. * @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
  23354. * @returns VertexData
  23355. */
  23356. updateMesh(mesh: Mesh): VertexData;
  23357. /**
  23358. * Updates the associated geometry
  23359. * @param geometry the geometry to be updated
  23360. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23361. * @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
  23362. * @returns VertexData.
  23363. */
  23364. updateGeometry(geometry: Geometry): VertexData;
  23365. private _applyTo;
  23366. private _update;
  23367. /**
  23368. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23369. * @param matrix the transforming matrix
  23370. * @returns the VertexData
  23371. */
  23372. transform(matrix: Matrix): VertexData;
  23373. /**
  23374. * Merges the passed VertexData into the current one
  23375. * @param other the VertexData to be merged into the current one
  23376. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23377. * @returns the modified VertexData
  23378. */
  23379. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23380. private _mergeElement;
  23381. private _validate;
  23382. /**
  23383. * Serializes the VertexData
  23384. * @returns a serialized object
  23385. */
  23386. serialize(): any;
  23387. /**
  23388. * Extracts the vertexData from a mesh
  23389. * @param mesh the mesh from which to extract the VertexData
  23390. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23391. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23392. * @returns the object VertexData associated to the passed mesh
  23393. */
  23394. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23395. /**
  23396. * Extracts the vertexData from the geometry
  23397. * @param geometry the geometry from which to extract the VertexData
  23398. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23399. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23400. * @returns the object VertexData associated to the passed mesh
  23401. */
  23402. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23403. private static _ExtractFrom;
  23404. /**
  23405. * Creates the VertexData for a Ribbon
  23406. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23407. * * pathArray array of paths, each of which an array of successive Vector3
  23408. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23409. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23410. * * 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
  23411. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23412. * * 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)
  23413. * * 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)
  23414. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23415. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23416. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23417. * @returns the VertexData of the ribbon
  23418. */
  23419. static CreateRibbon(options: {
  23420. pathArray: Vector3[][];
  23421. closeArray?: boolean;
  23422. closePath?: boolean;
  23423. offset?: number;
  23424. sideOrientation?: number;
  23425. frontUVs?: Vector4;
  23426. backUVs?: Vector4;
  23427. invertUV?: boolean;
  23428. uvs?: Vector2[];
  23429. colors?: Color4[];
  23430. }): VertexData;
  23431. /**
  23432. * Creates the VertexData for a box
  23433. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23434. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23435. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23436. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23437. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23438. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23439. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23440. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23441. * * 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)
  23442. * * 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)
  23443. * @returns the VertexData of the box
  23444. */
  23445. static CreateBox(options: {
  23446. size?: number;
  23447. width?: number;
  23448. height?: number;
  23449. depth?: number;
  23450. faceUV?: Vector4[];
  23451. faceColors?: Color4[];
  23452. sideOrientation?: number;
  23453. frontUVs?: Vector4;
  23454. backUVs?: Vector4;
  23455. }): VertexData;
  23456. /**
  23457. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23458. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23459. * * segments sets the number of horizontal strips optional, default 32
  23460. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23461. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23462. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23463. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23464. * * 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
  23465. * * 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
  23466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23467. * * 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)
  23468. * * 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)
  23469. * @returns the VertexData of the ellipsoid
  23470. */
  23471. static CreateSphere(options: {
  23472. segments?: number;
  23473. diameter?: number;
  23474. diameterX?: number;
  23475. diameterY?: number;
  23476. diameterZ?: number;
  23477. arc?: number;
  23478. slice?: number;
  23479. sideOrientation?: number;
  23480. frontUVs?: Vector4;
  23481. backUVs?: Vector4;
  23482. }): VertexData;
  23483. /**
  23484. * Creates the VertexData for a cylinder, cone or prism
  23485. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23486. * * height sets the height (y direction) of the cylinder, optional, default 2
  23487. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23488. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23489. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23490. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23491. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23492. * * 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
  23493. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23494. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23495. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23496. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23498. * * 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)
  23499. * * 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)
  23500. * @returns the VertexData of the cylinder, cone or prism
  23501. */
  23502. static CreateCylinder(options: {
  23503. height?: number;
  23504. diameterTop?: number;
  23505. diameterBottom?: number;
  23506. diameter?: number;
  23507. tessellation?: number;
  23508. subdivisions?: number;
  23509. arc?: number;
  23510. faceColors?: Color4[];
  23511. faceUV?: Vector4[];
  23512. hasRings?: boolean;
  23513. enclose?: boolean;
  23514. sideOrientation?: number;
  23515. frontUVs?: Vector4;
  23516. backUVs?: Vector4;
  23517. }): VertexData;
  23518. /**
  23519. * Creates the VertexData for a torus
  23520. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23521. * * diameter the diameter of the torus, optional default 1
  23522. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23523. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23524. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23525. * * 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)
  23526. * * 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)
  23527. * @returns the VertexData of the torus
  23528. */
  23529. static CreateTorus(options: {
  23530. diameter?: number;
  23531. thickness?: number;
  23532. tessellation?: number;
  23533. sideOrientation?: number;
  23534. frontUVs?: Vector4;
  23535. backUVs?: Vector4;
  23536. }): VertexData;
  23537. /**
  23538. * Creates the VertexData of the LineSystem
  23539. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23540. * - lines an array of lines, each line being an array of successive Vector3
  23541. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23542. * @returns the VertexData of the LineSystem
  23543. */
  23544. static CreateLineSystem(options: {
  23545. lines: Vector3[][];
  23546. colors?: Nullable<Color4[][]>;
  23547. }): VertexData;
  23548. /**
  23549. * Create the VertexData for a DashedLines
  23550. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23551. * - points an array successive Vector3
  23552. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23553. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23554. * - dashNb the intended total number of dashes, optional, default 200
  23555. * @returns the VertexData for the DashedLines
  23556. */
  23557. static CreateDashedLines(options: {
  23558. points: Vector3[];
  23559. dashSize?: number;
  23560. gapSize?: number;
  23561. dashNb?: number;
  23562. }): VertexData;
  23563. /**
  23564. * Creates the VertexData for a Ground
  23565. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23566. * - width the width (x direction) of the ground, optional, default 1
  23567. * - height the height (z direction) of the ground, optional, default 1
  23568. * - subdivisions the number of subdivisions per side, optional, default 1
  23569. * @returns the VertexData of the Ground
  23570. */
  23571. static CreateGround(options: {
  23572. width?: number;
  23573. height?: number;
  23574. subdivisions?: number;
  23575. subdivisionsX?: number;
  23576. subdivisionsY?: number;
  23577. }): VertexData;
  23578. /**
  23579. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23580. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23581. * * xmin the ground minimum X coordinate, optional, default -1
  23582. * * zmin the ground minimum Z coordinate, optional, default -1
  23583. * * xmax the ground maximum X coordinate, optional, default 1
  23584. * * zmax the ground maximum Z coordinate, optional, default 1
  23585. * * 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}
  23586. * * 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}
  23587. * @returns the VertexData of the TiledGround
  23588. */
  23589. static CreateTiledGround(options: {
  23590. xmin: number;
  23591. zmin: number;
  23592. xmax: number;
  23593. zmax: number;
  23594. subdivisions?: {
  23595. w: number;
  23596. h: number;
  23597. };
  23598. precision?: {
  23599. w: number;
  23600. h: number;
  23601. };
  23602. }): VertexData;
  23603. /**
  23604. * Creates the VertexData of the Ground designed from a heightmap
  23605. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23606. * * width the width (x direction) of the ground
  23607. * * height the height (z direction) of the ground
  23608. * * subdivisions the number of subdivisions per side
  23609. * * minHeight the minimum altitude on the ground, optional, default 0
  23610. * * maxHeight the maximum altitude on the ground, optional default 1
  23611. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23612. * * buffer the array holding the image color data
  23613. * * bufferWidth the width of image
  23614. * * bufferHeight the height of image
  23615. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23616. * @returns the VertexData of the Ground designed from a heightmap
  23617. */
  23618. static CreateGroundFromHeightMap(options: {
  23619. width: number;
  23620. height: number;
  23621. subdivisions: number;
  23622. minHeight: number;
  23623. maxHeight: number;
  23624. colorFilter: Color3;
  23625. buffer: Uint8Array;
  23626. bufferWidth: number;
  23627. bufferHeight: number;
  23628. alphaFilter: number;
  23629. }): VertexData;
  23630. /**
  23631. * Creates the VertexData for a Plane
  23632. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23633. * * size sets the width and height of the plane to the value of size, optional default 1
  23634. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23635. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23636. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23637. * * 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)
  23638. * * 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)
  23639. * @returns the VertexData of the box
  23640. */
  23641. static CreatePlane(options: {
  23642. size?: number;
  23643. width?: number;
  23644. height?: number;
  23645. sideOrientation?: number;
  23646. frontUVs?: Vector4;
  23647. backUVs?: Vector4;
  23648. }): VertexData;
  23649. /**
  23650. * Creates the VertexData of the Disc or regular Polygon
  23651. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23652. * * radius the radius of the disc, optional default 0.5
  23653. * * tessellation the number of polygon sides, optional, default 64
  23654. * * 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
  23655. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23656. * * 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)
  23657. * * 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)
  23658. * @returns the VertexData of the box
  23659. */
  23660. static CreateDisc(options: {
  23661. radius?: number;
  23662. tessellation?: number;
  23663. arc?: number;
  23664. sideOrientation?: number;
  23665. frontUVs?: Vector4;
  23666. backUVs?: Vector4;
  23667. }): VertexData;
  23668. /**
  23669. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23670. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23671. * @param polygon a mesh built from polygonTriangulation.build()
  23672. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23673. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23674. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23675. * @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)
  23676. * @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)
  23677. * @returns the VertexData of the Polygon
  23678. */
  23679. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23680. /**
  23681. * Creates the VertexData of the IcoSphere
  23682. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23683. * * radius the radius of the IcoSphere, optional default 1
  23684. * * radiusX allows stretching in the x direction, optional, default radius
  23685. * * radiusY allows stretching in the y direction, optional, default radius
  23686. * * radiusZ allows stretching in the z direction, optional, default radius
  23687. * * flat when true creates a flat shaded mesh, optional, default true
  23688. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23689. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23690. * * 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)
  23691. * * 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)
  23692. * @returns the VertexData of the IcoSphere
  23693. */
  23694. static CreateIcoSphere(options: {
  23695. radius?: number;
  23696. radiusX?: number;
  23697. radiusY?: number;
  23698. radiusZ?: number;
  23699. flat?: boolean;
  23700. subdivisions?: number;
  23701. sideOrientation?: number;
  23702. frontUVs?: Vector4;
  23703. backUVs?: Vector4;
  23704. }): VertexData;
  23705. /**
  23706. * Creates the VertexData for a Polyhedron
  23707. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23708. * * type provided types are:
  23709. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23710. * * 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)
  23711. * * size the size of the IcoSphere, optional default 1
  23712. * * sizeX allows stretching in the x direction, optional, default size
  23713. * * sizeY allows stretching in the y direction, optional, default size
  23714. * * sizeZ allows stretching in the z direction, optional, default size
  23715. * * 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
  23716. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23717. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23718. * * flat when true creates a flat shaded mesh, optional, default true
  23719. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23720. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23721. * * 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)
  23722. * * 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)
  23723. * @returns the VertexData of the Polyhedron
  23724. */
  23725. static CreatePolyhedron(options: {
  23726. type?: number;
  23727. size?: number;
  23728. sizeX?: number;
  23729. sizeY?: number;
  23730. sizeZ?: number;
  23731. custom?: any;
  23732. faceUV?: Vector4[];
  23733. faceColors?: Color4[];
  23734. flat?: boolean;
  23735. sideOrientation?: number;
  23736. frontUVs?: Vector4;
  23737. backUVs?: Vector4;
  23738. }): VertexData;
  23739. /**
  23740. * Creates the VertexData for a TorusKnot
  23741. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23742. * * radius the radius of the torus knot, optional, default 2
  23743. * * tube the thickness of the tube, optional, default 0.5
  23744. * * radialSegments the number of sides on each tube segments, optional, default 32
  23745. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23746. * * p the number of windings around the z axis, optional, default 2
  23747. * * q the number of windings around the x axis, optional, default 3
  23748. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23749. * * 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)
  23750. * * 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)
  23751. * @returns the VertexData of the Torus Knot
  23752. */
  23753. static CreateTorusKnot(options: {
  23754. radius?: number;
  23755. tube?: number;
  23756. radialSegments?: number;
  23757. tubularSegments?: number;
  23758. p?: number;
  23759. q?: number;
  23760. sideOrientation?: number;
  23761. frontUVs?: Vector4;
  23762. backUVs?: Vector4;
  23763. }): VertexData;
  23764. /**
  23765. * Compute normals for given positions and indices
  23766. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23767. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23768. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23769. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23770. * * facetNormals : optional array of facet normals (vector3)
  23771. * * facetPositions : optional array of facet positions (vector3)
  23772. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23773. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23774. * * bInfo : optional bounding info, required for facetPartitioning computation
  23775. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23776. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23777. * * useRightHandedSystem: optional boolean to for right handed system computation
  23778. * * depthSort : optional boolean to enable the facet depth sort computation
  23779. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23780. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23781. */
  23782. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23783. facetNormals?: any;
  23784. facetPositions?: any;
  23785. facetPartitioning?: any;
  23786. ratio?: number;
  23787. bInfo?: any;
  23788. bbSize?: Vector3;
  23789. subDiv?: any;
  23790. useRightHandedSystem?: boolean;
  23791. depthSort?: boolean;
  23792. distanceTo?: Vector3;
  23793. depthSortedFacets?: any;
  23794. }): void;
  23795. /** @hidden */
  23796. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23797. /**
  23798. * Applies VertexData created from the imported parameters to the geometry
  23799. * @param parsedVertexData the parsed data from an imported file
  23800. * @param geometry the geometry to apply the VertexData to
  23801. */
  23802. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23803. }
  23804. }
  23805. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23806. import { Nullable } from "babylonjs/types";
  23807. import { Scene } from "babylonjs/scene";
  23808. import { Vector4 } from "babylonjs/Maths/math";
  23809. import { Mesh } from "babylonjs/Meshes/mesh";
  23810. /**
  23811. * Class containing static functions to help procedurally build meshes
  23812. */
  23813. export class DiscBuilder {
  23814. /**
  23815. * Creates a plane polygonal mesh. By default, this is a disc
  23816. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23817. * * 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
  23818. * * 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
  23819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23822. * @param name defines the name of the mesh
  23823. * @param options defines the options used to create the mesh
  23824. * @param scene defines the hosting scene
  23825. * @returns the plane polygonal mesh
  23826. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23827. */
  23828. static CreateDisc(name: string, options: {
  23829. radius?: number;
  23830. tessellation?: number;
  23831. arc?: number;
  23832. updatable?: boolean;
  23833. sideOrientation?: number;
  23834. frontUVs?: Vector4;
  23835. backUVs?: Vector4;
  23836. }, scene?: Nullable<Scene>): Mesh;
  23837. }
  23838. }
  23839. declare module "babylonjs/Particles/solidParticleSystem" {
  23840. import { Vector3 } from "babylonjs/Maths/math";
  23841. import { Mesh } from "babylonjs/Meshes/mesh";
  23842. import { Scene, IDisposable } from "babylonjs/scene";
  23843. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23844. /**
  23845. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23846. *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.
  23847. * The SPS is also a particle system. It provides some methods to manage the particles.
  23848. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23849. *
  23850. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23851. */
  23852. export class SolidParticleSystem implements IDisposable {
  23853. /**
  23854. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23855. * Example : var p = SPS.particles[i];
  23856. */
  23857. particles: SolidParticle[];
  23858. /**
  23859. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23860. */
  23861. nbParticles: number;
  23862. /**
  23863. * If the particles must ever face the camera (default false). Useful for planar particles.
  23864. */
  23865. billboard: boolean;
  23866. /**
  23867. * Recompute normals when adding a shape
  23868. */
  23869. recomputeNormals: boolean;
  23870. /**
  23871. * This a counter ofr your own usage. It's not set by any SPS functions.
  23872. */
  23873. counter: number;
  23874. /**
  23875. * The SPS name. This name is also given to the underlying mesh.
  23876. */
  23877. name: string;
  23878. /**
  23879. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23880. */
  23881. mesh: Mesh;
  23882. /**
  23883. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23884. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23885. */
  23886. vars: any;
  23887. /**
  23888. * This array is populated when the SPS is set as 'pickable'.
  23889. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23890. * Each element of this array is an object `{idx: int, faceId: int}`.
  23891. * `idx` is the picked particle index in the `SPS.particles` array
  23892. * `faceId` is the picked face index counted within this particle.
  23893. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23894. */
  23895. pickedParticles: {
  23896. idx: number;
  23897. faceId: number;
  23898. }[];
  23899. /**
  23900. * This array is populated when `enableDepthSort` is set to true.
  23901. * Each element of this array is an instance of the class DepthSortedParticle.
  23902. */
  23903. depthSortedParticles: DepthSortedParticle[];
  23904. /**
  23905. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23906. * @hidden
  23907. */
  23908. _bSphereOnly: boolean;
  23909. /**
  23910. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23911. * @hidden
  23912. */
  23913. _bSphereRadiusFactor: number;
  23914. private _scene;
  23915. private _positions;
  23916. private _indices;
  23917. private _normals;
  23918. private _colors;
  23919. private _uvs;
  23920. private _indices32;
  23921. private _positions32;
  23922. private _normals32;
  23923. private _fixedNormal32;
  23924. private _colors32;
  23925. private _uvs32;
  23926. private _index;
  23927. private _updatable;
  23928. private _pickable;
  23929. private _isVisibilityBoxLocked;
  23930. private _alwaysVisible;
  23931. private _depthSort;
  23932. private _shapeCounter;
  23933. private _copy;
  23934. private _color;
  23935. private _computeParticleColor;
  23936. private _computeParticleTexture;
  23937. private _computeParticleRotation;
  23938. private _computeParticleVertex;
  23939. private _computeBoundingBox;
  23940. private _depthSortParticles;
  23941. private _camera;
  23942. private _mustUnrotateFixedNormals;
  23943. private _particlesIntersect;
  23944. private _needs32Bits;
  23945. /**
  23946. * Creates a SPS (Solid Particle System) object.
  23947. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23948. * @param scene (Scene) is the scene in which the SPS is added.
  23949. * @param options defines the options of the sps e.g.
  23950. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23951. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23952. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23953. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23954. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23955. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23956. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23957. */
  23958. constructor(name: string, scene: Scene, options?: {
  23959. updatable?: boolean;
  23960. isPickable?: boolean;
  23961. enableDepthSort?: boolean;
  23962. particleIntersection?: boolean;
  23963. boundingSphereOnly?: boolean;
  23964. bSphereRadiusFactor?: number;
  23965. });
  23966. /**
  23967. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23968. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23969. * @returns the created mesh
  23970. */
  23971. buildMesh(): Mesh;
  23972. /**
  23973. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23974. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23975. * Thus the particles generated from `digest()` have their property `position` set yet.
  23976. * @param mesh ( Mesh ) is the mesh to be digested
  23977. * @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
  23978. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23979. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23980. * @returns the current SPS
  23981. */
  23982. digest(mesh: Mesh, options?: {
  23983. facetNb?: number;
  23984. number?: number;
  23985. delta?: number;
  23986. }): SolidParticleSystem;
  23987. private _unrotateFixedNormals;
  23988. private _resetCopy;
  23989. private _meshBuilder;
  23990. private _posToShape;
  23991. private _uvsToShapeUV;
  23992. private _addParticle;
  23993. /**
  23994. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23995. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23996. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23997. * @param nb (positive integer) the number of particles to be created from this model
  23998. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23999. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24000. * @returns the number of shapes in the system
  24001. */
  24002. addShape(mesh: Mesh, nb: number, options?: {
  24003. positionFunction?: any;
  24004. vertexFunction?: any;
  24005. }): number;
  24006. private _rebuildParticle;
  24007. /**
  24008. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24009. * @returns the SPS.
  24010. */
  24011. rebuildMesh(): SolidParticleSystem;
  24012. /**
  24013. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24014. * This method calls `updateParticle()` for each particle of the SPS.
  24015. * For an animated SPS, it is usually called within the render loop.
  24016. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24017. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24018. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24019. * @returns the SPS.
  24020. */
  24021. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24022. /**
  24023. * Disposes the SPS.
  24024. */
  24025. dispose(): void;
  24026. /**
  24027. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24028. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24029. * @returns the SPS.
  24030. */
  24031. refreshVisibleSize(): SolidParticleSystem;
  24032. /**
  24033. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24034. * @param size the size (float) of the visibility box
  24035. * note : this doesn't lock the SPS mesh bounding box.
  24036. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24037. */
  24038. setVisibilityBox(size: number): void;
  24039. /**
  24040. * Gets whether the SPS as always visible or not
  24041. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24042. */
  24043. /**
  24044. * Sets the SPS as always visible or not
  24045. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24046. */
  24047. isAlwaysVisible: boolean;
  24048. /**
  24049. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24050. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24051. */
  24052. /**
  24053. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24054. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24055. */
  24056. isVisibilityBoxLocked: boolean;
  24057. /**
  24058. * Tells to `setParticles()` to compute the particle rotations or not.
  24059. * Default value : true. The SPS is faster when it's set to false.
  24060. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24061. */
  24062. /**
  24063. * Gets if `setParticles()` computes the particle rotations or not.
  24064. * Default value : true. The SPS is faster when it's set to false.
  24065. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24066. */
  24067. computeParticleRotation: boolean;
  24068. /**
  24069. * Tells to `setParticles()` to compute the particle colors or not.
  24070. * Default value : true. The SPS is faster when it's set to false.
  24071. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24072. */
  24073. /**
  24074. * Gets if `setParticles()` computes the particle colors or not.
  24075. * Default value : true. The SPS is faster when it's set to false.
  24076. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24077. */
  24078. computeParticleColor: boolean;
  24079. /**
  24080. * Gets if `setParticles()` computes the particle textures or not.
  24081. * Default value : true. The SPS is faster when it's set to false.
  24082. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24083. */
  24084. computeParticleTexture: boolean;
  24085. /**
  24086. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24087. * Default value : false. The SPS is faster when it's set to false.
  24088. * Note : the particle custom vertex positions aren't stored values.
  24089. */
  24090. /**
  24091. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24092. * Default value : false. The SPS is faster when it's set to false.
  24093. * Note : the particle custom vertex positions aren't stored values.
  24094. */
  24095. computeParticleVertex: boolean;
  24096. /**
  24097. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24098. */
  24099. /**
  24100. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24101. */
  24102. computeBoundingBox: boolean;
  24103. /**
  24104. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24105. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24106. * Default : `true`
  24107. */
  24108. /**
  24109. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24110. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24111. * Default : `true`
  24112. */
  24113. depthSortParticles: boolean;
  24114. /**
  24115. * This function does nothing. It may be overwritten to set all the particle first values.
  24116. * The SPS doesn't call this function, you may have to call it by your own.
  24117. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24118. */
  24119. initParticles(): void;
  24120. /**
  24121. * This function does nothing. It may be overwritten to recycle a particle.
  24122. * The SPS doesn't call this function, you may have to call it by your own.
  24123. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24124. * @param particle The particle to recycle
  24125. * @returns the recycled particle
  24126. */
  24127. recycleParticle(particle: SolidParticle): SolidParticle;
  24128. /**
  24129. * Updates a particle : this function should be overwritten by the user.
  24130. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24131. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24132. * @example : just set a particle position or velocity and recycle conditions
  24133. * @param particle The particle to update
  24134. * @returns the updated particle
  24135. */
  24136. updateParticle(particle: SolidParticle): SolidParticle;
  24137. /**
  24138. * Updates a vertex of a particle : it can be overwritten by the user.
  24139. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24140. * @param particle the current particle
  24141. * @param vertex the current index of the current particle
  24142. * @param pt the index of the current vertex in the particle shape
  24143. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24144. * @example : just set a vertex particle position
  24145. * @returns the updated vertex
  24146. */
  24147. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24148. /**
  24149. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24150. * This does nothing and may be overwritten by the user.
  24151. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24152. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24153. * @param update the boolean update value actually passed to setParticles()
  24154. */
  24155. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24156. /**
  24157. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24158. * This will be passed three parameters.
  24159. * This does nothing and may be overwritten by the user.
  24160. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24161. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24162. * @param update the boolean update value actually passed to setParticles()
  24163. */
  24164. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24165. }
  24166. }
  24167. declare module "babylonjs/Particles/solidParticle" {
  24168. import { Nullable } from "babylonjs/types";
  24169. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24170. import { Mesh } from "babylonjs/Meshes/mesh";
  24171. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24172. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24173. /**
  24174. * Represents one particle of a solid particle system.
  24175. */
  24176. export class SolidParticle {
  24177. /**
  24178. * particle global index
  24179. */
  24180. idx: number;
  24181. /**
  24182. * The color of the particle
  24183. */
  24184. color: Nullable<Color4>;
  24185. /**
  24186. * The world space position of the particle.
  24187. */
  24188. position: Vector3;
  24189. /**
  24190. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24191. */
  24192. rotation: Vector3;
  24193. /**
  24194. * The world space rotation quaternion of the particle.
  24195. */
  24196. rotationQuaternion: Nullable<Quaternion>;
  24197. /**
  24198. * The scaling of the particle.
  24199. */
  24200. scaling: Vector3;
  24201. /**
  24202. * The uvs of the particle.
  24203. */
  24204. uvs: Vector4;
  24205. /**
  24206. * The current speed of the particle.
  24207. */
  24208. velocity: Vector3;
  24209. /**
  24210. * The pivot point in the particle local space.
  24211. */
  24212. pivot: Vector3;
  24213. /**
  24214. * Must the particle be translated from its pivot point in its local space ?
  24215. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24216. * Default : false
  24217. */
  24218. translateFromPivot: boolean;
  24219. /**
  24220. * Is the particle active or not ?
  24221. */
  24222. alive: boolean;
  24223. /**
  24224. * Is the particle visible or not ?
  24225. */
  24226. isVisible: boolean;
  24227. /**
  24228. * Index of this particle in the global "positions" array (Internal use)
  24229. * @hidden
  24230. */
  24231. _pos: number;
  24232. /**
  24233. * @hidden Index of this particle in the global "indices" array (Internal use)
  24234. */
  24235. _ind: number;
  24236. /**
  24237. * @hidden ModelShape of this particle (Internal use)
  24238. */
  24239. _model: ModelShape;
  24240. /**
  24241. * ModelShape id of this particle
  24242. */
  24243. shapeId: number;
  24244. /**
  24245. * Index of the particle in its shape id (Internal use)
  24246. */
  24247. idxInShape: number;
  24248. /**
  24249. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24250. */
  24251. _modelBoundingInfo: BoundingInfo;
  24252. /**
  24253. * @hidden Particle BoundingInfo object (Internal use)
  24254. */
  24255. _boundingInfo: BoundingInfo;
  24256. /**
  24257. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24258. */
  24259. _sps: SolidParticleSystem;
  24260. /**
  24261. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24262. */
  24263. _stillInvisible: boolean;
  24264. /**
  24265. * @hidden Last computed particle rotation matrix
  24266. */
  24267. _rotationMatrix: number[];
  24268. /**
  24269. * Parent particle Id, if any.
  24270. * Default null.
  24271. */
  24272. parentId: Nullable<number>;
  24273. /**
  24274. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24275. * The possible values are :
  24276. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24277. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24278. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24279. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24280. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24281. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24282. * */
  24283. cullingStrategy: number;
  24284. /**
  24285. * @hidden Internal global position in the SPS.
  24286. */
  24287. _globalPosition: Vector3;
  24288. /**
  24289. * Creates a Solid Particle object.
  24290. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24291. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24292. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24293. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24294. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24295. * @param shapeId (integer) is the model shape identifier in the SPS.
  24296. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24297. * @param sps defines the sps it is associated to
  24298. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24299. */
  24300. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24301. /**
  24302. * Legacy support, changed scale to scaling
  24303. */
  24304. /**
  24305. * Legacy support, changed scale to scaling
  24306. */
  24307. scale: Vector3;
  24308. /**
  24309. * Legacy support, changed quaternion to rotationQuaternion
  24310. */
  24311. /**
  24312. * Legacy support, changed quaternion to rotationQuaternion
  24313. */
  24314. quaternion: Nullable<Quaternion>;
  24315. /**
  24316. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24317. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24318. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24319. * @returns true if it intersects
  24320. */
  24321. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24322. /**
  24323. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24324. * A particle is in the frustum if its bounding box intersects the frustum
  24325. * @param frustumPlanes defines the frustum to test
  24326. * @returns true if the particle is in the frustum planes
  24327. */
  24328. isInFrustum(frustumPlanes: Plane[]): boolean;
  24329. /**
  24330. * get the rotation matrix of the particle
  24331. * @hidden
  24332. */
  24333. getRotationMatrix(m: Matrix): void;
  24334. }
  24335. /**
  24336. * Represents the shape of the model used by one particle of a solid particle system.
  24337. * SPS internal tool, don't use it manually.
  24338. */
  24339. export class ModelShape {
  24340. /**
  24341. * The shape id
  24342. * @hidden
  24343. */
  24344. shapeID: number;
  24345. /**
  24346. * flat array of model positions (internal use)
  24347. * @hidden
  24348. */
  24349. _shape: Vector3[];
  24350. /**
  24351. * flat array of model UVs (internal use)
  24352. * @hidden
  24353. */
  24354. _shapeUV: number[];
  24355. /**
  24356. * length of the shape in the model indices array (internal use)
  24357. * @hidden
  24358. */
  24359. _indicesLength: number;
  24360. /**
  24361. * Custom position function (internal use)
  24362. * @hidden
  24363. */
  24364. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24365. /**
  24366. * Custom vertex function (internal use)
  24367. * @hidden
  24368. */
  24369. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24370. /**
  24371. * 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.
  24372. * SPS internal tool, don't use it manually.
  24373. * @hidden
  24374. */
  24375. 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>);
  24376. }
  24377. /**
  24378. * Represents a Depth Sorted Particle in the solid particle system.
  24379. */
  24380. export class DepthSortedParticle {
  24381. /**
  24382. * Index of the particle in the "indices" array
  24383. */
  24384. ind: number;
  24385. /**
  24386. * Length of the particle shape in the "indices" array
  24387. */
  24388. indicesLength: number;
  24389. /**
  24390. * Squared distance from the particle to the camera
  24391. */
  24392. sqDistance: number;
  24393. }
  24394. }
  24395. declare module "babylonjs/Meshes/abstractMesh" {
  24396. import { Observable } from "babylonjs/Misc/observable";
  24397. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24398. import { Camera } from "babylonjs/Cameras/camera";
  24399. import { Scene, IDisposable } from "babylonjs/scene";
  24400. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24401. import { Node } from "babylonjs/node";
  24402. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24403. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24404. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24405. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24406. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24407. import { Material } from "babylonjs/Materials/material";
  24408. import { Light } from "babylonjs/Lights/light";
  24409. import { Skeleton } from "babylonjs/Bones/skeleton";
  24410. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24411. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24412. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24413. import { Ray } from "babylonjs/Culling/ray";
  24414. import { Collider } from "babylonjs/Collisions/collider";
  24415. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24416. /**
  24417. * Class used to store all common mesh properties
  24418. */
  24419. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24420. /** No occlusion */
  24421. static OCCLUSION_TYPE_NONE: number;
  24422. /** Occlusion set to optimisitic */
  24423. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24424. /** Occlusion set to strict */
  24425. static OCCLUSION_TYPE_STRICT: number;
  24426. /** Use an accurante occlusion algorithm */
  24427. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24428. /** Use a conservative occlusion algorithm */
  24429. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24430. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24431. * Test order :
  24432. * Is the bounding sphere outside the frustum ?
  24433. * If not, are the bounding box vertices outside the frustum ?
  24434. * It not, then the cullable object is in the frustum.
  24435. */
  24436. static readonly CULLINGSTRATEGY_STANDARD: number;
  24437. /** Culling strategy : Bounding Sphere Only.
  24438. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24439. * It's also less accurate than the standard because some not visible objects can still be selected.
  24440. * Test : is the bounding sphere outside the frustum ?
  24441. * If not, then the cullable object is in the frustum.
  24442. */
  24443. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24444. /** Culling strategy : Optimistic Inclusion.
  24445. * This in an inclusion test first, then the standard exclusion test.
  24446. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24447. * 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.
  24448. * Anyway, it's as accurate as the standard strategy.
  24449. * Test :
  24450. * Is the cullable object bounding sphere center in the frustum ?
  24451. * If not, apply the default culling strategy.
  24452. */
  24453. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24454. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24455. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24456. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24457. * 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.
  24458. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24459. * Test :
  24460. * Is the cullable object bounding sphere center in the frustum ?
  24461. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24462. */
  24463. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24464. /**
  24465. * No billboard
  24466. */
  24467. static readonly BILLBOARDMODE_NONE: number;
  24468. /** Billboard on X axis */
  24469. static readonly BILLBOARDMODE_X: number;
  24470. /** Billboard on Y axis */
  24471. static readonly BILLBOARDMODE_Y: number;
  24472. /** Billboard on Z axis */
  24473. static readonly BILLBOARDMODE_Z: number;
  24474. /** Billboard on all axes */
  24475. static readonly BILLBOARDMODE_ALL: number;
  24476. private _facetData;
  24477. /**
  24478. * The culling strategy to use to check whether the mesh must be rendered or not.
  24479. * This value can be changed at any time and will be used on the next render mesh selection.
  24480. * The possible values are :
  24481. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24482. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24483. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24484. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24485. * Please read each static variable documentation to get details about the culling process.
  24486. * */
  24487. cullingStrategy: number;
  24488. /**
  24489. * Gets the number of facets in the mesh
  24490. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24491. */
  24492. readonly facetNb: number;
  24493. /**
  24494. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24495. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24496. */
  24497. partitioningSubdivisions: number;
  24498. /**
  24499. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24500. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24501. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24502. */
  24503. partitioningBBoxRatio: number;
  24504. /**
  24505. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24506. * Works only for updatable meshes.
  24507. * Doesn't work with multi-materials
  24508. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24509. */
  24510. mustDepthSortFacets: boolean;
  24511. /**
  24512. * The location (Vector3) where the facet depth sort must be computed from.
  24513. * By default, the active camera position.
  24514. * Used only when facet depth sort is enabled
  24515. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24516. */
  24517. facetDepthSortFrom: Vector3;
  24518. /**
  24519. * gets a boolean indicating if facetData is enabled
  24520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24521. */
  24522. readonly isFacetDataEnabled: boolean;
  24523. /** @hidden */
  24524. _updateNonUniformScalingState(value: boolean): boolean;
  24525. /**
  24526. * An event triggered when this mesh collides with another one
  24527. */
  24528. onCollideObservable: Observable<AbstractMesh>;
  24529. private _onCollideObserver;
  24530. /** Set a function to call when this mesh collides with another one */
  24531. onCollide: () => void;
  24532. /**
  24533. * An event triggered when the collision's position changes
  24534. */
  24535. onCollisionPositionChangeObservable: Observable<Vector3>;
  24536. private _onCollisionPositionChangeObserver;
  24537. /** Set a function to call when the collision's position changes */
  24538. onCollisionPositionChange: () => void;
  24539. /**
  24540. * An event triggered when material is changed
  24541. */
  24542. onMaterialChangedObservable: Observable<AbstractMesh>;
  24543. /**
  24544. * Gets or sets the orientation for POV movement & rotation
  24545. */
  24546. definedFacingForward: boolean;
  24547. /** @hidden */
  24548. _occlusionQuery: Nullable<WebGLQuery>;
  24549. private _visibility;
  24550. /**
  24551. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24552. */
  24553. /**
  24554. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24555. */
  24556. visibility: number;
  24557. /** Gets or sets the alpha index used to sort transparent meshes
  24558. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24559. */
  24560. alphaIndex: number;
  24561. /**
  24562. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24563. */
  24564. isVisible: boolean;
  24565. /**
  24566. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24567. */
  24568. isPickable: boolean;
  24569. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24570. showSubMeshesBoundingBox: boolean;
  24571. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24572. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24573. */
  24574. isBlocker: boolean;
  24575. /**
  24576. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24577. */
  24578. enablePointerMoveEvents: boolean;
  24579. /**
  24580. * Specifies the rendering group id for this mesh (0 by default)
  24581. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24582. */
  24583. renderingGroupId: number;
  24584. private _material;
  24585. /** Gets or sets current material */
  24586. material: Nullable<Material>;
  24587. private _receiveShadows;
  24588. /**
  24589. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24590. * @see http://doc.babylonjs.com/babylon101/shadows
  24591. */
  24592. receiveShadows: boolean;
  24593. /** Defines color to use when rendering outline */
  24594. outlineColor: Color3;
  24595. /** Define width to use when rendering outline */
  24596. outlineWidth: number;
  24597. /** Defines color to use when rendering overlay */
  24598. overlayColor: Color3;
  24599. /** Defines alpha to use when rendering overlay */
  24600. overlayAlpha: number;
  24601. private _hasVertexAlpha;
  24602. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24603. hasVertexAlpha: boolean;
  24604. private _useVertexColors;
  24605. /** 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) */
  24606. useVertexColors: boolean;
  24607. private _computeBonesUsingShaders;
  24608. /**
  24609. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24610. */
  24611. computeBonesUsingShaders: boolean;
  24612. private _numBoneInfluencers;
  24613. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24614. numBoneInfluencers: number;
  24615. private _applyFog;
  24616. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24617. applyFog: boolean;
  24618. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24619. useOctreeForRenderingSelection: boolean;
  24620. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24621. useOctreeForPicking: boolean;
  24622. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24623. useOctreeForCollisions: boolean;
  24624. private _layerMask;
  24625. /**
  24626. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24627. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24628. */
  24629. layerMask: number;
  24630. /**
  24631. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24632. */
  24633. alwaysSelectAsActiveMesh: boolean;
  24634. /**
  24635. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24636. */
  24637. doNotSyncBoundingInfo: boolean;
  24638. /**
  24639. * Gets or sets the current action manager
  24640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24641. */
  24642. actionManager: Nullable<AbstractActionManager>;
  24643. private _checkCollisions;
  24644. private _collisionMask;
  24645. private _collisionGroup;
  24646. /**
  24647. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24648. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24649. */
  24650. ellipsoid: Vector3;
  24651. /**
  24652. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24653. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24654. */
  24655. ellipsoidOffset: Vector3;
  24656. private _collider;
  24657. private _oldPositionForCollisions;
  24658. private _diffPositionForCollisions;
  24659. /**
  24660. * Gets or sets a collision mask used to mask collisions (default is -1).
  24661. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24662. */
  24663. collisionMask: number;
  24664. /**
  24665. * Gets or sets the current collision group mask (-1 by default).
  24666. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24667. */
  24668. collisionGroup: number;
  24669. /**
  24670. * Defines edge width used when edgesRenderer is enabled
  24671. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24672. */
  24673. edgesWidth: number;
  24674. /**
  24675. * Defines edge color used when edgesRenderer is enabled
  24676. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24677. */
  24678. edgesColor: Color4;
  24679. /** @hidden */
  24680. _edgesRenderer: Nullable<IEdgesRenderer>;
  24681. /** @hidden */
  24682. _masterMesh: Nullable<AbstractMesh>;
  24683. /** @hidden */
  24684. _boundingInfo: Nullable<BoundingInfo>;
  24685. /** @hidden */
  24686. _renderId: number;
  24687. /**
  24688. * Gets or sets the list of subMeshes
  24689. * @see http://doc.babylonjs.com/how_to/multi_materials
  24690. */
  24691. subMeshes: SubMesh[];
  24692. /** @hidden */
  24693. _intersectionsInProgress: AbstractMesh[];
  24694. /** @hidden */
  24695. _unIndexed: boolean;
  24696. /** @hidden */
  24697. _lightSources: Light[];
  24698. /** @hidden */
  24699. readonly _positions: Nullable<Vector3[]>;
  24700. /** @hidden */
  24701. _waitingActions: any;
  24702. /** @hidden */
  24703. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24704. private _skeleton;
  24705. /** @hidden */
  24706. _bonesTransformMatrices: Nullable<Float32Array>;
  24707. /**
  24708. * Gets or sets a skeleton to apply skining transformations
  24709. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24710. */
  24711. skeleton: Nullable<Skeleton>;
  24712. /**
  24713. * An event triggered when the mesh is rebuilt.
  24714. */
  24715. onRebuildObservable: Observable<AbstractMesh>;
  24716. /**
  24717. * Creates a new AbstractMesh
  24718. * @param name defines the name of the mesh
  24719. * @param scene defines the hosting scene
  24720. */
  24721. constructor(name: string, scene?: Nullable<Scene>);
  24722. /**
  24723. * Returns the string "AbstractMesh"
  24724. * @returns "AbstractMesh"
  24725. */
  24726. getClassName(): string;
  24727. /**
  24728. * Gets a string representation of the current mesh
  24729. * @param fullDetails defines a boolean indicating if full details must be included
  24730. * @returns a string representation of the current mesh
  24731. */
  24732. toString(fullDetails?: boolean): string;
  24733. /**
  24734. * @hidden
  24735. */
  24736. protected _getEffectiveParent(): Nullable<Node>;
  24737. /** @hidden */
  24738. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24739. /** @hidden */
  24740. _rebuild(): void;
  24741. /** @hidden */
  24742. _resyncLightSources(): void;
  24743. /** @hidden */
  24744. _resyncLighSource(light: Light): void;
  24745. /** @hidden */
  24746. _unBindEffect(): void;
  24747. /** @hidden */
  24748. _removeLightSource(light: Light): void;
  24749. private _markSubMeshesAsDirty;
  24750. /** @hidden */
  24751. _markSubMeshesAsLightDirty(): void;
  24752. /** @hidden */
  24753. _markSubMeshesAsAttributesDirty(): void;
  24754. /** @hidden */
  24755. _markSubMeshesAsMiscDirty(): void;
  24756. /**
  24757. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24758. */
  24759. scaling: Vector3;
  24760. /**
  24761. * Returns true if the mesh is blocked. Implemented by child classes
  24762. */
  24763. readonly isBlocked: boolean;
  24764. /**
  24765. * Returns the mesh itself by default. Implemented by child classes
  24766. * @param camera defines the camera to use to pick the right LOD level
  24767. * @returns the currentAbstractMesh
  24768. */
  24769. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24770. /**
  24771. * Returns 0 by default. Implemented by child classes
  24772. * @returns an integer
  24773. */
  24774. getTotalVertices(): number;
  24775. /**
  24776. * Returns a positive integer : the total number of indices in this mesh geometry.
  24777. * @returns the numner of indices or zero if the mesh has no geometry.
  24778. */
  24779. getTotalIndices(): number;
  24780. /**
  24781. * Returns null by default. Implemented by child classes
  24782. * @returns null
  24783. */
  24784. getIndices(): Nullable<IndicesArray>;
  24785. /**
  24786. * Returns the array of the requested vertex data kind. Implemented by child classes
  24787. * @param kind defines the vertex data kind to use
  24788. * @returns null
  24789. */
  24790. getVerticesData(kind: string): Nullable<FloatArray>;
  24791. /**
  24792. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24793. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24794. * Note that a new underlying VertexBuffer object is created each call.
  24795. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24796. * @param kind defines vertex data kind:
  24797. * * VertexBuffer.PositionKind
  24798. * * VertexBuffer.UVKind
  24799. * * VertexBuffer.UV2Kind
  24800. * * VertexBuffer.UV3Kind
  24801. * * VertexBuffer.UV4Kind
  24802. * * VertexBuffer.UV5Kind
  24803. * * VertexBuffer.UV6Kind
  24804. * * VertexBuffer.ColorKind
  24805. * * VertexBuffer.MatricesIndicesKind
  24806. * * VertexBuffer.MatricesIndicesExtraKind
  24807. * * VertexBuffer.MatricesWeightsKind
  24808. * * VertexBuffer.MatricesWeightsExtraKind
  24809. * @param data defines the data source
  24810. * @param updatable defines if the data must be flagged as updatable (or static)
  24811. * @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
  24812. * @returns the current mesh
  24813. */
  24814. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24815. /**
  24816. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24817. * If the mesh has no geometry, it is simply returned as it is.
  24818. * @param kind defines vertex data kind:
  24819. * * VertexBuffer.PositionKind
  24820. * * VertexBuffer.UVKind
  24821. * * VertexBuffer.UV2Kind
  24822. * * VertexBuffer.UV3Kind
  24823. * * VertexBuffer.UV4Kind
  24824. * * VertexBuffer.UV5Kind
  24825. * * VertexBuffer.UV6Kind
  24826. * * VertexBuffer.ColorKind
  24827. * * VertexBuffer.MatricesIndicesKind
  24828. * * VertexBuffer.MatricesIndicesExtraKind
  24829. * * VertexBuffer.MatricesWeightsKind
  24830. * * VertexBuffer.MatricesWeightsExtraKind
  24831. * @param data defines the data source
  24832. * @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
  24833. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24834. * @returns the current mesh
  24835. */
  24836. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24837. /**
  24838. * Sets the mesh indices,
  24839. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24840. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24841. * @param totalVertices Defines the total number of vertices
  24842. * @returns the current mesh
  24843. */
  24844. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24845. /**
  24846. * Gets a boolean indicating if specific vertex data is present
  24847. * @param kind defines the vertex data kind to use
  24848. * @returns true is data kind is present
  24849. */
  24850. isVerticesDataPresent(kind: string): boolean;
  24851. /**
  24852. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24853. * @returns a BoundingInfo
  24854. */
  24855. getBoundingInfo(): BoundingInfo;
  24856. /**
  24857. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24858. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24859. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24860. * @returns the current mesh
  24861. */
  24862. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24863. /**
  24864. * Overwrite the current bounding info
  24865. * @param boundingInfo defines the new bounding info
  24866. * @returns the current mesh
  24867. */
  24868. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24869. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24870. readonly useBones: boolean;
  24871. /** @hidden */
  24872. _preActivate(): void;
  24873. /** @hidden */
  24874. _preActivateForIntermediateRendering(renderId: number): void;
  24875. /** @hidden */
  24876. _activate(renderId: number): void;
  24877. /**
  24878. * Gets the current world matrix
  24879. * @returns a Matrix
  24880. */
  24881. getWorldMatrix(): Matrix;
  24882. /** @hidden */
  24883. _getWorldMatrixDeterminant(): number;
  24884. /**
  24885. * Perform relative position change from the point of view of behind the front of the mesh.
  24886. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24887. * Supports definition of mesh facing forward or backward
  24888. * @param amountRight defines the distance on the right axis
  24889. * @param amountUp defines the distance on the up axis
  24890. * @param amountForward defines the distance on the forward axis
  24891. * @returns the current mesh
  24892. */
  24893. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24894. /**
  24895. * Calculate relative position change from the point of view of behind the front of the mesh.
  24896. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24897. * Supports definition of mesh facing forward or backward
  24898. * @param amountRight defines the distance on the right axis
  24899. * @param amountUp defines the distance on the up axis
  24900. * @param amountForward defines the distance on the forward axis
  24901. * @returns the new displacement vector
  24902. */
  24903. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24904. /**
  24905. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24906. * Supports definition of mesh facing forward or backward
  24907. * @param flipBack defines the flip
  24908. * @param twirlClockwise defines the twirl
  24909. * @param tiltRight defines the tilt
  24910. * @returns the current mesh
  24911. */
  24912. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24913. /**
  24914. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24915. * Supports definition of mesh facing forward or backward.
  24916. * @param flipBack defines the flip
  24917. * @param twirlClockwise defines the twirl
  24918. * @param tiltRight defines the tilt
  24919. * @returns the new rotation vector
  24920. */
  24921. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24922. /**
  24923. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24924. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24925. * @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
  24926. * @returns the new bounding vectors
  24927. */
  24928. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24929. min: Vector3;
  24930. max: Vector3;
  24931. };
  24932. /**
  24933. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24934. * This means the mesh underlying bounding box and sphere are recomputed.
  24935. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24936. * @returns the current mesh
  24937. */
  24938. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24939. /** @hidden */
  24940. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24941. /** @hidden */
  24942. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24943. /** @hidden */
  24944. _updateBoundingInfo(): AbstractMesh;
  24945. /** @hidden */
  24946. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24947. /** @hidden */
  24948. protected _afterComputeWorldMatrix(): void;
  24949. /** @hidden */
  24950. readonly _effectiveMesh: AbstractMesh;
  24951. /**
  24952. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24953. * A mesh is in the frustum if its bounding box intersects the frustum
  24954. * @param frustumPlanes defines the frustum to test
  24955. * @returns true if the mesh is in the frustum planes
  24956. */
  24957. isInFrustum(frustumPlanes: Plane[]): boolean;
  24958. /**
  24959. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24960. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24961. * @param frustumPlanes defines the frustum to test
  24962. * @returns true if the mesh is completely in the frustum planes
  24963. */
  24964. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24965. /**
  24966. * True if the mesh intersects another mesh or a SolidParticle object
  24967. * @param mesh defines a target mesh or SolidParticle to test
  24968. * @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)
  24969. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24970. * @returns true if there is an intersection
  24971. */
  24972. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24973. /**
  24974. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24975. * @param point defines the point to test
  24976. * @returns true if there is an intersection
  24977. */
  24978. intersectsPoint(point: Vector3): boolean;
  24979. /**
  24980. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24981. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24982. */
  24983. checkCollisions: boolean;
  24984. /**
  24985. * Gets Collider object used to compute collisions (not physics)
  24986. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24987. */
  24988. readonly collider: Collider;
  24989. /**
  24990. * Move the mesh using collision engine
  24991. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24992. * @param displacement defines the requested displacement vector
  24993. * @returns the current mesh
  24994. */
  24995. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24996. private _onCollisionPositionChange;
  24997. /** @hidden */
  24998. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24999. /** @hidden */
  25000. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25001. /** @hidden */
  25002. _checkCollision(collider: Collider): AbstractMesh;
  25003. /** @hidden */
  25004. _generatePointsArray(): boolean;
  25005. /**
  25006. * Checks if the passed Ray intersects with the mesh
  25007. * @param ray defines the ray to use
  25008. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25009. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25010. * @returns the picking info
  25011. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25012. */
  25013. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25014. /**
  25015. * Clones the current mesh
  25016. * @param name defines the mesh name
  25017. * @param newParent defines the new mesh parent
  25018. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25019. * @returns the new mesh
  25020. */
  25021. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25022. /**
  25023. * Disposes all the submeshes of the current meshnp
  25024. * @returns the current mesh
  25025. */
  25026. releaseSubMeshes(): AbstractMesh;
  25027. /**
  25028. * Releases resources associated with this abstract mesh.
  25029. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25030. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25031. */
  25032. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25033. /**
  25034. * Adds the passed mesh as a child to the current mesh
  25035. * @param mesh defines the child mesh
  25036. * @returns the current mesh
  25037. */
  25038. addChild(mesh: AbstractMesh): AbstractMesh;
  25039. /**
  25040. * Removes the passed mesh from the current mesh children list
  25041. * @param mesh defines the child mesh
  25042. * @returns the current mesh
  25043. */
  25044. removeChild(mesh: AbstractMesh): AbstractMesh;
  25045. /** @hidden */
  25046. private _initFacetData;
  25047. /**
  25048. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25049. * This method can be called within the render loop.
  25050. * 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
  25051. * @returns the current mesh
  25052. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25053. */
  25054. updateFacetData(): AbstractMesh;
  25055. /**
  25056. * Returns the facetLocalNormals array.
  25057. * The normals are expressed in the mesh local spac
  25058. * @returns an array of Vector3
  25059. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25060. */
  25061. getFacetLocalNormals(): Vector3[];
  25062. /**
  25063. * Returns the facetLocalPositions array.
  25064. * The facet positions are expressed in the mesh local space
  25065. * @returns an array of Vector3
  25066. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25067. */
  25068. getFacetLocalPositions(): Vector3[];
  25069. /**
  25070. * Returns the facetLocalPartioning array
  25071. * @returns an array of array of numbers
  25072. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25073. */
  25074. getFacetLocalPartitioning(): number[][];
  25075. /**
  25076. * Returns the i-th facet position in the world system.
  25077. * This method allocates a new Vector3 per call
  25078. * @param i defines the facet index
  25079. * @returns a new Vector3
  25080. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25081. */
  25082. getFacetPosition(i: number): Vector3;
  25083. /**
  25084. * Sets the reference Vector3 with the i-th facet position in the world system
  25085. * @param i defines the facet index
  25086. * @param ref defines the target vector
  25087. * @returns the current mesh
  25088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25089. */
  25090. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25091. /**
  25092. * Returns the i-th facet normal in the world system.
  25093. * This method allocates a new Vector3 per call
  25094. * @param i defines the facet index
  25095. * @returns a new Vector3
  25096. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25097. */
  25098. getFacetNormal(i: number): Vector3;
  25099. /**
  25100. * Sets the reference Vector3 with the i-th facet normal in the world system
  25101. * @param i defines the facet index
  25102. * @param ref defines the target vector
  25103. * @returns the current mesh
  25104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25105. */
  25106. getFacetNormalToRef(i: number, ref: Vector3): this;
  25107. /**
  25108. * 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)
  25109. * @param x defines x coordinate
  25110. * @param y defines y coordinate
  25111. * @param z defines z coordinate
  25112. * @returns the array of facet indexes
  25113. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25114. */
  25115. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25116. /**
  25117. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25118. * @param projected sets as the (x,y,z) world projection on the facet
  25119. * @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
  25120. * @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
  25121. * @param x defines x coordinate
  25122. * @param y defines y coordinate
  25123. * @param z defines z coordinate
  25124. * @returns the face index if found (or null instead)
  25125. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25126. */
  25127. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25128. /**
  25129. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25130. * @param projected sets as the (x,y,z) local projection on the facet
  25131. * @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
  25132. * @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
  25133. * @param x defines x coordinate
  25134. * @param y defines y coordinate
  25135. * @param z defines z coordinate
  25136. * @returns the face index if found (or null instead)
  25137. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25138. */
  25139. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25140. /**
  25141. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25142. * @returns the parameters
  25143. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25144. */
  25145. getFacetDataParameters(): any;
  25146. /**
  25147. * Disables the feature FacetData and frees the related memory
  25148. * @returns the current mesh
  25149. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25150. */
  25151. disableFacetData(): AbstractMesh;
  25152. /**
  25153. * Updates the AbstractMesh indices array
  25154. * @param indices defines the data source
  25155. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25156. * @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)
  25157. * @returns the current mesh
  25158. */
  25159. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25160. /**
  25161. * Creates new normals data for the mesh
  25162. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25163. * @returns the current mesh
  25164. */
  25165. createNormals(updatable: boolean): AbstractMesh;
  25166. /**
  25167. * Align the mesh with a normal
  25168. * @param normal defines the normal to use
  25169. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25170. * @returns the current mesh
  25171. */
  25172. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25173. /** @hidden */
  25174. _checkOcclusionQuery(): boolean;
  25175. }
  25176. }
  25177. declare module "babylonjs/Actions/actionEvent" {
  25178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25179. import { Nullable } from "babylonjs/types";
  25180. import { Sprite } from "babylonjs/Sprites/sprite";
  25181. import { Scene } from "babylonjs/scene";
  25182. import { Vector2 } from "babylonjs/Maths/math";
  25183. /**
  25184. * Interface used to define ActionEvent
  25185. */
  25186. export interface IActionEvent {
  25187. /** The mesh or sprite that triggered the action */
  25188. source: any;
  25189. /** The X mouse cursor position at the time of the event */
  25190. pointerX: number;
  25191. /** The Y mouse cursor position at the time of the event */
  25192. pointerY: number;
  25193. /** The mesh that is currently pointed at (can be null) */
  25194. meshUnderPointer: Nullable<AbstractMesh>;
  25195. /** the original (browser) event that triggered the ActionEvent */
  25196. sourceEvent?: any;
  25197. /** additional data for the event */
  25198. additionalData?: any;
  25199. }
  25200. /**
  25201. * ActionEvent is the event being sent when an action is triggered.
  25202. */
  25203. export class ActionEvent implements IActionEvent {
  25204. /** The mesh or sprite that triggered the action */
  25205. source: any;
  25206. /** The X mouse cursor position at the time of the event */
  25207. pointerX: number;
  25208. /** The Y mouse cursor position at the time of the event */
  25209. pointerY: number;
  25210. /** The mesh that is currently pointed at (can be null) */
  25211. meshUnderPointer: Nullable<AbstractMesh>;
  25212. /** the original (browser) event that triggered the ActionEvent */
  25213. sourceEvent?: any;
  25214. /** additional data for the event */
  25215. additionalData?: any;
  25216. /**
  25217. * Creates a new ActionEvent
  25218. * @param source The mesh or sprite that triggered the action
  25219. * @param pointerX The X mouse cursor position at the time of the event
  25220. * @param pointerY The Y mouse cursor position at the time of the event
  25221. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25222. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25223. * @param additionalData additional data for the event
  25224. */
  25225. constructor(
  25226. /** The mesh or sprite that triggered the action */
  25227. source: any,
  25228. /** The X mouse cursor position at the time of the event */
  25229. pointerX: number,
  25230. /** The Y mouse cursor position at the time of the event */
  25231. pointerY: number,
  25232. /** The mesh that is currently pointed at (can be null) */
  25233. meshUnderPointer: Nullable<AbstractMesh>,
  25234. /** the original (browser) event that triggered the ActionEvent */
  25235. sourceEvent?: any,
  25236. /** additional data for the event */
  25237. additionalData?: any);
  25238. /**
  25239. * Helper function to auto-create an ActionEvent from a source mesh.
  25240. * @param source The source mesh that triggered the event
  25241. * @param evt The original (browser) event
  25242. * @param additionalData additional data for the event
  25243. * @returns the new ActionEvent
  25244. */
  25245. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25246. /**
  25247. * Helper function to auto-create an ActionEvent from a source sprite
  25248. * @param source The source sprite that triggered the event
  25249. * @param scene Scene associated with the sprite
  25250. * @param evt The original (browser) event
  25251. * @param additionalData additional data for the event
  25252. * @returns the new ActionEvent
  25253. */
  25254. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25255. /**
  25256. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25257. * @param scene the scene where the event occurred
  25258. * @param evt The original (browser) event
  25259. * @returns the new ActionEvent
  25260. */
  25261. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25262. /**
  25263. * Helper function to auto-create an ActionEvent from a primitive
  25264. * @param prim defines the target primitive
  25265. * @param pointerPos defines the pointer position
  25266. * @param evt The original (browser) event
  25267. * @param additionalData additional data for the event
  25268. * @returns the new ActionEvent
  25269. */
  25270. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25271. }
  25272. }
  25273. declare module "babylonjs/Actions/abstractActionManager" {
  25274. import { IDisposable } from "babylonjs/scene";
  25275. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25276. import { IAction } from "babylonjs/Actions/action";
  25277. import { Nullable } from "babylonjs/types";
  25278. /**
  25279. * Abstract class used to decouple action Manager from scene and meshes.
  25280. * Do not instantiate.
  25281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25282. */
  25283. export abstract class AbstractActionManager implements IDisposable {
  25284. /** Gets the list of active triggers */
  25285. static Triggers: {
  25286. [key: string]: number;
  25287. };
  25288. /** Gets the cursor to use when hovering items */
  25289. hoverCursor: string;
  25290. /** Gets the list of actions */
  25291. actions: IAction[];
  25292. /**
  25293. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25294. */
  25295. isRecursive: boolean;
  25296. /**
  25297. * Releases all associated resources
  25298. */
  25299. abstract dispose(): void;
  25300. /**
  25301. * Does this action manager has pointer triggers
  25302. */
  25303. abstract readonly hasPointerTriggers: boolean;
  25304. /**
  25305. * Does this action manager has pick triggers
  25306. */
  25307. abstract readonly hasPickTriggers: boolean;
  25308. /**
  25309. * Process a specific trigger
  25310. * @param trigger defines the trigger to process
  25311. * @param evt defines the event details to be processed
  25312. */
  25313. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25314. /**
  25315. * Does this action manager handles actions of any of the given triggers
  25316. * @param triggers defines the triggers to be tested
  25317. * @return a boolean indicating whether one (or more) of the triggers is handled
  25318. */
  25319. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25320. /**
  25321. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25322. * speed.
  25323. * @param triggerA defines the trigger to be tested
  25324. * @param triggerB defines the trigger to be tested
  25325. * @return a boolean indicating whether one (or more) of the triggers is handled
  25326. */
  25327. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25328. /**
  25329. * Does this action manager handles actions of a given trigger
  25330. * @param trigger defines the trigger to be tested
  25331. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25332. * @return whether the trigger is handled
  25333. */
  25334. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25335. /**
  25336. * Serialize this manager to a JSON object
  25337. * @param name defines the property name to store this manager
  25338. * @returns a JSON representation of this manager
  25339. */
  25340. abstract serialize(name: string): any;
  25341. /**
  25342. * Registers an action to this action manager
  25343. * @param action defines the action to be registered
  25344. * @return the action amended (prepared) after registration
  25345. */
  25346. abstract registerAction(action: IAction): Nullable<IAction>;
  25347. /**
  25348. * Unregisters an action to this action manager
  25349. * @param action defines the action to be unregistered
  25350. * @return a boolean indicating whether the action has been unregistered
  25351. */
  25352. abstract unregisterAction(action: IAction): Boolean;
  25353. /**
  25354. * Does exist one action manager with at least one trigger
  25355. **/
  25356. static readonly HasTriggers: boolean;
  25357. /**
  25358. * Does exist one action manager with at least one pick trigger
  25359. **/
  25360. static readonly HasPickTriggers: boolean;
  25361. /**
  25362. * Does exist one action manager that handles actions of a given trigger
  25363. * @param trigger defines the trigger to be tested
  25364. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25365. **/
  25366. static HasSpecificTrigger(trigger: number): boolean;
  25367. }
  25368. }
  25369. declare module "babylonjs/node" {
  25370. import { Scene } from "babylonjs/scene";
  25371. import { Nullable } from "babylonjs/types";
  25372. import { Matrix } from "babylonjs/Maths/math";
  25373. import { Engine } from "babylonjs/Engines/engine";
  25374. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25375. import { Observable } from "babylonjs/Misc/observable";
  25376. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25377. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25378. import { Animatable } from "babylonjs/Animations/animatable";
  25379. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25380. import { Animation } from "babylonjs/Animations/animation";
  25381. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25383. /**
  25384. * Defines how a node can be built from a string name.
  25385. */
  25386. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25387. /**
  25388. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25389. */
  25390. export class Node implements IBehaviorAware<Node> {
  25391. /** @hidden */
  25392. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25393. private static _NodeConstructors;
  25394. /**
  25395. * Add a new node constructor
  25396. * @param type defines the type name of the node to construct
  25397. * @param constructorFunc defines the constructor function
  25398. */
  25399. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25400. /**
  25401. * Returns a node constructor based on type name
  25402. * @param type defines the type name
  25403. * @param name defines the new node name
  25404. * @param scene defines the hosting scene
  25405. * @param options defines optional options to transmit to constructors
  25406. * @returns the new constructor or null
  25407. */
  25408. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25409. /**
  25410. * Gets or sets the name of the node
  25411. */
  25412. name: string;
  25413. /**
  25414. * Gets or sets the id of the node
  25415. */
  25416. id: string;
  25417. /**
  25418. * Gets or sets the unique id of the node
  25419. */
  25420. uniqueId: number;
  25421. /**
  25422. * Gets or sets a string used to store user defined state for the node
  25423. */
  25424. state: string;
  25425. /**
  25426. * Gets or sets an object used to store user defined information for the node
  25427. */
  25428. metadata: any;
  25429. /**
  25430. * For internal use only. Please do not use.
  25431. */
  25432. reservedDataStore: any;
  25433. /**
  25434. * List of inspectable custom properties (used by the Inspector)
  25435. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25436. */
  25437. inspectableCustomProperties: IInspectable[];
  25438. /**
  25439. * Gets or sets a boolean used to define if the node must be serialized
  25440. */
  25441. doNotSerialize: boolean;
  25442. /** @hidden */
  25443. _isDisposed: boolean;
  25444. /**
  25445. * Gets a list of Animations associated with the node
  25446. */
  25447. animations: import("babylonjs/Animations/animation").Animation[];
  25448. protected _ranges: {
  25449. [name: string]: Nullable<AnimationRange>;
  25450. };
  25451. /**
  25452. * Callback raised when the node is ready to be used
  25453. */
  25454. onReady: (node: Node) => void;
  25455. private _isEnabled;
  25456. private _isParentEnabled;
  25457. private _isReady;
  25458. /** @hidden */
  25459. _currentRenderId: number;
  25460. private _parentUpdateId;
  25461. protected _childUpdateId: number;
  25462. /** @hidden */
  25463. _waitingParentId: Nullable<string>;
  25464. /** @hidden */
  25465. _scene: Scene;
  25466. /** @hidden */
  25467. _cache: any;
  25468. private _parentNode;
  25469. private _children;
  25470. /** @hidden */
  25471. _worldMatrix: Matrix;
  25472. /** @hidden */
  25473. _worldMatrixDeterminant: number;
  25474. /** @hidden */
  25475. private _sceneRootNodesIndex;
  25476. /**
  25477. * Gets a boolean indicating if the node has been disposed
  25478. * @returns true if the node was disposed
  25479. */
  25480. isDisposed(): boolean;
  25481. /**
  25482. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25483. * @see https://doc.babylonjs.com/how_to/parenting
  25484. */
  25485. parent: Nullable<Node>;
  25486. private addToSceneRootNodes;
  25487. private removeFromSceneRootNodes;
  25488. private _animationPropertiesOverride;
  25489. /**
  25490. * Gets or sets the animation properties override
  25491. */
  25492. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25493. /**
  25494. * Gets a string idenfifying the name of the class
  25495. * @returns "Node" string
  25496. */
  25497. getClassName(): string;
  25498. /** @hidden */
  25499. readonly _isNode: boolean;
  25500. /**
  25501. * An event triggered when the mesh is disposed
  25502. */
  25503. onDisposeObservable: Observable<Node>;
  25504. private _onDisposeObserver;
  25505. /**
  25506. * Sets a callback that will be raised when the node will be disposed
  25507. */
  25508. onDispose: () => void;
  25509. /**
  25510. * Creates a new Node
  25511. * @param name the name and id to be given to this node
  25512. * @param scene the scene this node will be added to
  25513. * @param addToRootNodes the node will be added to scene.rootNodes
  25514. */
  25515. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25516. /**
  25517. * Gets the scene of the node
  25518. * @returns a scene
  25519. */
  25520. getScene(): Scene;
  25521. /**
  25522. * Gets the engine of the node
  25523. * @returns a Engine
  25524. */
  25525. getEngine(): Engine;
  25526. private _behaviors;
  25527. /**
  25528. * Attach a behavior to the node
  25529. * @see http://doc.babylonjs.com/features/behaviour
  25530. * @param behavior defines the behavior to attach
  25531. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25532. * @returns the current Node
  25533. */
  25534. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25535. /**
  25536. * Remove an attached behavior
  25537. * @see http://doc.babylonjs.com/features/behaviour
  25538. * @param behavior defines the behavior to attach
  25539. * @returns the current Node
  25540. */
  25541. removeBehavior(behavior: Behavior<Node>): Node;
  25542. /**
  25543. * Gets the list of attached behaviors
  25544. * @see http://doc.babylonjs.com/features/behaviour
  25545. */
  25546. readonly behaviors: Behavior<Node>[];
  25547. /**
  25548. * Gets an attached behavior by name
  25549. * @param name defines the name of the behavior to look for
  25550. * @see http://doc.babylonjs.com/features/behaviour
  25551. * @returns null if behavior was not found else the requested behavior
  25552. */
  25553. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25554. /**
  25555. * Returns the latest update of the World matrix
  25556. * @returns a Matrix
  25557. */
  25558. getWorldMatrix(): Matrix;
  25559. /** @hidden */
  25560. _getWorldMatrixDeterminant(): number;
  25561. /**
  25562. * Returns directly the latest state of the mesh World matrix.
  25563. * A Matrix is returned.
  25564. */
  25565. readonly worldMatrixFromCache: Matrix;
  25566. /** @hidden */
  25567. _initCache(): void;
  25568. /** @hidden */
  25569. updateCache(force?: boolean): void;
  25570. /** @hidden */
  25571. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25572. /** @hidden */
  25573. _updateCache(ignoreParentClass?: boolean): void;
  25574. /** @hidden */
  25575. _isSynchronized(): boolean;
  25576. /** @hidden */
  25577. _markSyncedWithParent(): void;
  25578. /** @hidden */
  25579. isSynchronizedWithParent(): boolean;
  25580. /** @hidden */
  25581. isSynchronized(): boolean;
  25582. /**
  25583. * Is this node ready to be used/rendered
  25584. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25585. * @return true if the node is ready
  25586. */
  25587. isReady(completeCheck?: boolean): boolean;
  25588. /**
  25589. * Is this node enabled?
  25590. * 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
  25591. * @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
  25592. * @return whether this node (and its parent) is enabled
  25593. */
  25594. isEnabled(checkAncestors?: boolean): boolean;
  25595. /** @hidden */
  25596. protected _syncParentEnabledState(): void;
  25597. /**
  25598. * Set the enabled state of this node
  25599. * @param value defines the new enabled state
  25600. */
  25601. setEnabled(value: boolean): void;
  25602. /**
  25603. * Is this node a descendant of the given node?
  25604. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25605. * @param ancestor defines the parent node to inspect
  25606. * @returns a boolean indicating if this node is a descendant of the given node
  25607. */
  25608. isDescendantOf(ancestor: Node): boolean;
  25609. /** @hidden */
  25610. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25611. /**
  25612. * Will return all nodes that have this node as ascendant
  25613. * @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
  25614. * @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
  25615. * @return all children nodes of all types
  25616. */
  25617. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25618. /**
  25619. * Get all child-meshes of this node
  25620. * @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)
  25621. * @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
  25622. * @returns an array of AbstractMesh
  25623. */
  25624. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25625. /**
  25626. * Get all direct children of this node
  25627. * @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
  25628. * @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)
  25629. * @returns an array of Node
  25630. */
  25631. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25632. /** @hidden */
  25633. _setReady(state: boolean): void;
  25634. /**
  25635. * Get an animation by name
  25636. * @param name defines the name of the animation to look for
  25637. * @returns null if not found else the requested animation
  25638. */
  25639. getAnimationByName(name: string): Nullable<Animation>;
  25640. /**
  25641. * Creates an animation range for this node
  25642. * @param name defines the name of the range
  25643. * @param from defines the starting key
  25644. * @param to defines the end key
  25645. */
  25646. createAnimationRange(name: string, from: number, to: number): void;
  25647. /**
  25648. * Delete a specific animation range
  25649. * @param name defines the name of the range to delete
  25650. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25651. */
  25652. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25653. /**
  25654. * Get an animation range by name
  25655. * @param name defines the name of the animation range to look for
  25656. * @returns null if not found else the requested animation range
  25657. */
  25658. getAnimationRange(name: string): Nullable<AnimationRange>;
  25659. /**
  25660. * Gets the list of all animation ranges defined on this node
  25661. * @returns an array
  25662. */
  25663. getAnimationRanges(): Nullable<AnimationRange>[];
  25664. /**
  25665. * Will start the animation sequence
  25666. * @param name defines the range frames for animation sequence
  25667. * @param loop defines if the animation should loop (false by default)
  25668. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25669. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25670. * @returns the object created for this animation. If range does not exist, it will return null
  25671. */
  25672. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25673. /**
  25674. * Serialize animation ranges into a JSON compatible object
  25675. * @returns serialization object
  25676. */
  25677. serializeAnimationRanges(): any;
  25678. /**
  25679. * Computes the world matrix of the node
  25680. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25681. * @returns the world matrix
  25682. */
  25683. computeWorldMatrix(force?: boolean): Matrix;
  25684. /**
  25685. * Releases resources associated with this node.
  25686. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25687. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25688. */
  25689. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25690. /**
  25691. * Parse animation range data from a serialization object and store them into a given node
  25692. * @param node defines where to store the animation ranges
  25693. * @param parsedNode defines the serialization object to read data from
  25694. * @param scene defines the hosting scene
  25695. */
  25696. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25697. }
  25698. }
  25699. declare module "babylonjs/Animations/animation" {
  25700. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25701. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25702. import { Nullable } from "babylonjs/types";
  25703. import { Scene } from "babylonjs/scene";
  25704. import { IAnimatable } from "babylonjs/Misc/tools";
  25705. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25706. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25707. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25708. import { Node } from "babylonjs/node";
  25709. import { Animatable } from "babylonjs/Animations/animatable";
  25710. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25711. /**
  25712. * Class used to store any kind of animation
  25713. */
  25714. export class Animation {
  25715. /**Name of the animation */
  25716. name: string;
  25717. /**Property to animate */
  25718. targetProperty: string;
  25719. /**The frames per second of the animation */
  25720. framePerSecond: number;
  25721. /**The data type of the animation */
  25722. dataType: number;
  25723. /**The loop mode of the animation */
  25724. loopMode?: number | undefined;
  25725. /**Specifies if blending should be enabled */
  25726. enableBlending?: boolean | undefined;
  25727. /**
  25728. * Use matrix interpolation instead of using direct key value when animating matrices
  25729. */
  25730. static AllowMatricesInterpolation: boolean;
  25731. /**
  25732. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25733. */
  25734. static AllowMatrixDecomposeForInterpolation: boolean;
  25735. /**
  25736. * Stores the key frames of the animation
  25737. */
  25738. private _keys;
  25739. /**
  25740. * Stores the easing function of the animation
  25741. */
  25742. private _easingFunction;
  25743. /**
  25744. * @hidden Internal use only
  25745. */
  25746. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25747. /**
  25748. * The set of event that will be linked to this animation
  25749. */
  25750. private _events;
  25751. /**
  25752. * Stores an array of target property paths
  25753. */
  25754. targetPropertyPath: string[];
  25755. /**
  25756. * Stores the blending speed of the animation
  25757. */
  25758. blendingSpeed: number;
  25759. /**
  25760. * Stores the animation ranges for the animation
  25761. */
  25762. private _ranges;
  25763. /**
  25764. * @hidden Internal use
  25765. */
  25766. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25767. /**
  25768. * Sets up an animation
  25769. * @param property The property to animate
  25770. * @param animationType The animation type to apply
  25771. * @param framePerSecond The frames per second of the animation
  25772. * @param easingFunction The easing function used in the animation
  25773. * @returns The created animation
  25774. */
  25775. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25776. /**
  25777. * Create and start an animation on a node
  25778. * @param name defines the name of the global animation that will be run on all nodes
  25779. * @param node defines the root node where the animation will take place
  25780. * @param targetProperty defines property to animate
  25781. * @param framePerSecond defines the number of frame per second yo use
  25782. * @param totalFrame defines the number of frames in total
  25783. * @param from defines the initial value
  25784. * @param to defines the final value
  25785. * @param loopMode defines which loop mode you want to use (off by default)
  25786. * @param easingFunction defines the easing function to use (linear by default)
  25787. * @param onAnimationEnd defines the callback to call when animation end
  25788. * @returns the animatable created for this animation
  25789. */
  25790. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25791. /**
  25792. * Create and start an animation on a node and its descendants
  25793. * @param name defines the name of the global animation that will be run on all nodes
  25794. * @param node defines the root node where the animation will take place
  25795. * @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
  25796. * @param targetProperty defines property to animate
  25797. * @param framePerSecond defines the number of frame per second to use
  25798. * @param totalFrame defines the number of frames in total
  25799. * @param from defines the initial value
  25800. * @param to defines the final value
  25801. * @param loopMode defines which loop mode you want to use (off by default)
  25802. * @param easingFunction defines the easing function to use (linear by default)
  25803. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25804. * @returns the list of animatables created for all nodes
  25805. * @example https://www.babylonjs-playground.com/#MH0VLI
  25806. */
  25807. 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[]>;
  25808. /**
  25809. * Creates a new animation, merges it with the existing animations and starts it
  25810. * @param name Name of the animation
  25811. * @param node Node which contains the scene that begins the animations
  25812. * @param targetProperty Specifies which property to animate
  25813. * @param framePerSecond The frames per second of the animation
  25814. * @param totalFrame The total number of frames
  25815. * @param from The frame at the beginning of the animation
  25816. * @param to The frame at the end of the animation
  25817. * @param loopMode Specifies the loop mode of the animation
  25818. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25819. * @param onAnimationEnd Callback to run once the animation is complete
  25820. * @returns Nullable animation
  25821. */
  25822. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25823. /**
  25824. * Transition property of an host to the target Value
  25825. * @param property The property to transition
  25826. * @param targetValue The target Value of the property
  25827. * @param host The object where the property to animate belongs
  25828. * @param scene Scene used to run the animation
  25829. * @param frameRate Framerate (in frame/s) to use
  25830. * @param transition The transition type we want to use
  25831. * @param duration The duration of the animation, in milliseconds
  25832. * @param onAnimationEnd Callback trigger at the end of the animation
  25833. * @returns Nullable animation
  25834. */
  25835. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25836. /**
  25837. * Return the array of runtime animations currently using this animation
  25838. */
  25839. readonly runtimeAnimations: RuntimeAnimation[];
  25840. /**
  25841. * Specifies if any of the runtime animations are currently running
  25842. */
  25843. readonly hasRunningRuntimeAnimations: boolean;
  25844. /**
  25845. * Initializes the animation
  25846. * @param name Name of the animation
  25847. * @param targetProperty Property to animate
  25848. * @param framePerSecond The frames per second of the animation
  25849. * @param dataType The data type of the animation
  25850. * @param loopMode The loop mode of the animation
  25851. * @param enableBlending Specifies if blending should be enabled
  25852. */
  25853. constructor(
  25854. /**Name of the animation */
  25855. name: string,
  25856. /**Property to animate */
  25857. targetProperty: string,
  25858. /**The frames per second of the animation */
  25859. framePerSecond: number,
  25860. /**The data type of the animation */
  25861. dataType: number,
  25862. /**The loop mode of the animation */
  25863. loopMode?: number | undefined,
  25864. /**Specifies if blending should be enabled */
  25865. enableBlending?: boolean | undefined);
  25866. /**
  25867. * Converts the animation to a string
  25868. * @param fullDetails support for multiple levels of logging within scene loading
  25869. * @returns String form of the animation
  25870. */
  25871. toString(fullDetails?: boolean): string;
  25872. /**
  25873. * Add an event to this animation
  25874. * @param event Event to add
  25875. */
  25876. addEvent(event: AnimationEvent): void;
  25877. /**
  25878. * Remove all events found at the given frame
  25879. * @param frame The frame to remove events from
  25880. */
  25881. removeEvents(frame: number): void;
  25882. /**
  25883. * Retrieves all the events from the animation
  25884. * @returns Events from the animation
  25885. */
  25886. getEvents(): AnimationEvent[];
  25887. /**
  25888. * Creates an animation range
  25889. * @param name Name of the animation range
  25890. * @param from Starting frame of the animation range
  25891. * @param to Ending frame of the animation
  25892. */
  25893. createRange(name: string, from: number, to: number): void;
  25894. /**
  25895. * Deletes an animation range by name
  25896. * @param name Name of the animation range to delete
  25897. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25898. */
  25899. deleteRange(name: string, deleteFrames?: boolean): void;
  25900. /**
  25901. * Gets the animation range by name, or null if not defined
  25902. * @param name Name of the animation range
  25903. * @returns Nullable animation range
  25904. */
  25905. getRange(name: string): Nullable<AnimationRange>;
  25906. /**
  25907. * Gets the key frames from the animation
  25908. * @returns The key frames of the animation
  25909. */
  25910. getKeys(): Array<IAnimationKey>;
  25911. /**
  25912. * Gets the highest frame rate of the animation
  25913. * @returns Highest frame rate of the animation
  25914. */
  25915. getHighestFrame(): number;
  25916. /**
  25917. * Gets the easing function of the animation
  25918. * @returns Easing function of the animation
  25919. */
  25920. getEasingFunction(): IEasingFunction;
  25921. /**
  25922. * Sets the easing function of the animation
  25923. * @param easingFunction A custom mathematical formula for animation
  25924. */
  25925. setEasingFunction(easingFunction: EasingFunction): void;
  25926. /**
  25927. * Interpolates a scalar linearly
  25928. * @param startValue Start value of the animation curve
  25929. * @param endValue End value of the animation curve
  25930. * @param gradient Scalar amount to interpolate
  25931. * @returns Interpolated scalar value
  25932. */
  25933. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25934. /**
  25935. * Interpolates a scalar cubically
  25936. * @param startValue Start value of the animation curve
  25937. * @param outTangent End tangent of the animation
  25938. * @param endValue End value of the animation curve
  25939. * @param inTangent Start tangent of the animation curve
  25940. * @param gradient Scalar amount to interpolate
  25941. * @returns Interpolated scalar value
  25942. */
  25943. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25944. /**
  25945. * Interpolates a quaternion using a spherical linear interpolation
  25946. * @param startValue Start value of the animation curve
  25947. * @param endValue End value of the animation curve
  25948. * @param gradient Scalar amount to interpolate
  25949. * @returns Interpolated quaternion value
  25950. */
  25951. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25952. /**
  25953. * Interpolates a quaternion cubically
  25954. * @param startValue Start value of the animation curve
  25955. * @param outTangent End tangent of the animation curve
  25956. * @param endValue End value of the animation curve
  25957. * @param inTangent Start tangent of the animation curve
  25958. * @param gradient Scalar amount to interpolate
  25959. * @returns Interpolated quaternion value
  25960. */
  25961. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25962. /**
  25963. * Interpolates a Vector3 linearl
  25964. * @param startValue Start value of the animation curve
  25965. * @param endValue End value of the animation curve
  25966. * @param gradient Scalar amount to interpolate
  25967. * @returns Interpolated scalar value
  25968. */
  25969. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25970. /**
  25971. * Interpolates a Vector3 cubically
  25972. * @param startValue Start value of the animation curve
  25973. * @param outTangent End tangent of the animation
  25974. * @param endValue End value of the animation curve
  25975. * @param inTangent Start tangent of the animation curve
  25976. * @param gradient Scalar amount to interpolate
  25977. * @returns InterpolatedVector3 value
  25978. */
  25979. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25980. /**
  25981. * Interpolates a Vector2 linearly
  25982. * @param startValue Start value of the animation curve
  25983. * @param endValue End value of the animation curve
  25984. * @param gradient Scalar amount to interpolate
  25985. * @returns Interpolated Vector2 value
  25986. */
  25987. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25988. /**
  25989. * Interpolates a Vector2 cubically
  25990. * @param startValue Start value of the animation curve
  25991. * @param outTangent End tangent of the animation
  25992. * @param endValue End value of the animation curve
  25993. * @param inTangent Start tangent of the animation curve
  25994. * @param gradient Scalar amount to interpolate
  25995. * @returns Interpolated Vector2 value
  25996. */
  25997. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25998. /**
  25999. * Interpolates a size linearly
  26000. * @param startValue Start value of the animation curve
  26001. * @param endValue End value of the animation curve
  26002. * @param gradient Scalar amount to interpolate
  26003. * @returns Interpolated Size value
  26004. */
  26005. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26006. /**
  26007. * Interpolates a Color3 linearly
  26008. * @param startValue Start value of the animation curve
  26009. * @param endValue End value of the animation curve
  26010. * @param gradient Scalar amount to interpolate
  26011. * @returns Interpolated Color3 value
  26012. */
  26013. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26014. /**
  26015. * @hidden Internal use only
  26016. */
  26017. _getKeyValue(value: any): any;
  26018. /**
  26019. * @hidden Internal use only
  26020. */
  26021. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  26022. /**
  26023. * Defines the function to use to interpolate matrices
  26024. * @param startValue defines the start matrix
  26025. * @param endValue defines the end matrix
  26026. * @param gradient defines the gradient between both matrices
  26027. * @param result defines an optional target matrix where to store the interpolation
  26028. * @returns the interpolated matrix
  26029. */
  26030. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26031. /**
  26032. * Makes a copy of the animation
  26033. * @returns Cloned animation
  26034. */
  26035. clone(): Animation;
  26036. /**
  26037. * Sets the key frames of the animation
  26038. * @param values The animation key frames to set
  26039. */
  26040. setKeys(values: Array<IAnimationKey>): void;
  26041. /**
  26042. * Serializes the animation to an object
  26043. * @returns Serialized object
  26044. */
  26045. serialize(): any;
  26046. /**
  26047. * Float animation type
  26048. */
  26049. private static _ANIMATIONTYPE_FLOAT;
  26050. /**
  26051. * Vector3 animation type
  26052. */
  26053. private static _ANIMATIONTYPE_VECTOR3;
  26054. /**
  26055. * Quaternion animation type
  26056. */
  26057. private static _ANIMATIONTYPE_QUATERNION;
  26058. /**
  26059. * Matrix animation type
  26060. */
  26061. private static _ANIMATIONTYPE_MATRIX;
  26062. /**
  26063. * Color3 animation type
  26064. */
  26065. private static _ANIMATIONTYPE_COLOR3;
  26066. /**
  26067. * Vector2 animation type
  26068. */
  26069. private static _ANIMATIONTYPE_VECTOR2;
  26070. /**
  26071. * Size animation type
  26072. */
  26073. private static _ANIMATIONTYPE_SIZE;
  26074. /**
  26075. * Relative Loop Mode
  26076. */
  26077. private static _ANIMATIONLOOPMODE_RELATIVE;
  26078. /**
  26079. * Cycle Loop Mode
  26080. */
  26081. private static _ANIMATIONLOOPMODE_CYCLE;
  26082. /**
  26083. * Constant Loop Mode
  26084. */
  26085. private static _ANIMATIONLOOPMODE_CONSTANT;
  26086. /**
  26087. * Get the float animation type
  26088. */
  26089. static readonly ANIMATIONTYPE_FLOAT: number;
  26090. /**
  26091. * Get the Vector3 animation type
  26092. */
  26093. static readonly ANIMATIONTYPE_VECTOR3: number;
  26094. /**
  26095. * Get the Vector2 animation type
  26096. */
  26097. static readonly ANIMATIONTYPE_VECTOR2: number;
  26098. /**
  26099. * Get the Size animation type
  26100. */
  26101. static readonly ANIMATIONTYPE_SIZE: number;
  26102. /**
  26103. * Get the Quaternion animation type
  26104. */
  26105. static readonly ANIMATIONTYPE_QUATERNION: number;
  26106. /**
  26107. * Get the Matrix animation type
  26108. */
  26109. static readonly ANIMATIONTYPE_MATRIX: number;
  26110. /**
  26111. * Get the Color3 animation type
  26112. */
  26113. static readonly ANIMATIONTYPE_COLOR3: number;
  26114. /**
  26115. * Get the Relative Loop Mode
  26116. */
  26117. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26118. /**
  26119. * Get the Cycle Loop Mode
  26120. */
  26121. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26122. /**
  26123. * Get the Constant Loop Mode
  26124. */
  26125. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26126. /** @hidden */
  26127. static _UniversalLerp(left: any, right: any, amount: number): any;
  26128. /**
  26129. * Parses an animation object and creates an animation
  26130. * @param parsedAnimation Parsed animation object
  26131. * @returns Animation object
  26132. */
  26133. static Parse(parsedAnimation: any): Animation;
  26134. /**
  26135. * Appends the serialized animations from the source animations
  26136. * @param source Source containing the animations
  26137. * @param destination Target to store the animations
  26138. */
  26139. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26140. }
  26141. }
  26142. declare module "babylonjs/Materials/Textures/baseTexture" {
  26143. import { Observable } from "babylonjs/Misc/observable";
  26144. import { IAnimatable } from "babylonjs/Misc/tools";
  26145. import { Nullable } from "babylonjs/types";
  26146. import { Scene } from "babylonjs/scene";
  26147. import { Matrix, ISize } from "babylonjs/Maths/math";
  26148. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26149. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26150. /**
  26151. * Base class of all the textures in babylon.
  26152. * It groups all the common properties the materials, post process, lights... might need
  26153. * in order to make a correct use of the texture.
  26154. */
  26155. export class BaseTexture implements IAnimatable {
  26156. /**
  26157. * Default anisotropic filtering level for the application.
  26158. * It is set to 4 as a good tradeoff between perf and quality.
  26159. */
  26160. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26161. /**
  26162. * Gets or sets the unique id of the texture
  26163. */
  26164. uniqueId: number;
  26165. /**
  26166. * Define the name of the texture.
  26167. */
  26168. name: string;
  26169. /**
  26170. * Gets or sets an object used to store user defined information.
  26171. */
  26172. metadata: any;
  26173. /**
  26174. * For internal use only. Please do not use.
  26175. */
  26176. reservedDataStore: any;
  26177. private _hasAlpha;
  26178. /**
  26179. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26180. */
  26181. hasAlpha: boolean;
  26182. /**
  26183. * Defines if the alpha value should be determined via the rgb values.
  26184. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26185. */
  26186. getAlphaFromRGB: boolean;
  26187. /**
  26188. * Intensity or strength of the texture.
  26189. * It is commonly used by materials to fine tune the intensity of the texture
  26190. */
  26191. level: number;
  26192. /**
  26193. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26194. * This is part of the texture as textures usually maps to one uv set.
  26195. */
  26196. coordinatesIndex: number;
  26197. private _coordinatesMode;
  26198. /**
  26199. * How a texture is mapped.
  26200. *
  26201. * | Value | Type | Description |
  26202. * | ----- | ----------------------------------- | ----------- |
  26203. * | 0 | EXPLICIT_MODE | |
  26204. * | 1 | SPHERICAL_MODE | |
  26205. * | 2 | PLANAR_MODE | |
  26206. * | 3 | CUBIC_MODE | |
  26207. * | 4 | PROJECTION_MODE | |
  26208. * | 5 | SKYBOX_MODE | |
  26209. * | 6 | INVCUBIC_MODE | |
  26210. * | 7 | EQUIRECTANGULAR_MODE | |
  26211. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26212. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26213. */
  26214. coordinatesMode: number;
  26215. /**
  26216. * | Value | Type | Description |
  26217. * | ----- | ------------------ | ----------- |
  26218. * | 0 | CLAMP_ADDRESSMODE | |
  26219. * | 1 | WRAP_ADDRESSMODE | |
  26220. * | 2 | MIRROR_ADDRESSMODE | |
  26221. */
  26222. wrapU: number;
  26223. /**
  26224. * | Value | Type | Description |
  26225. * | ----- | ------------------ | ----------- |
  26226. * | 0 | CLAMP_ADDRESSMODE | |
  26227. * | 1 | WRAP_ADDRESSMODE | |
  26228. * | 2 | MIRROR_ADDRESSMODE | |
  26229. */
  26230. wrapV: number;
  26231. /**
  26232. * | Value | Type | Description |
  26233. * | ----- | ------------------ | ----------- |
  26234. * | 0 | CLAMP_ADDRESSMODE | |
  26235. * | 1 | WRAP_ADDRESSMODE | |
  26236. * | 2 | MIRROR_ADDRESSMODE | |
  26237. */
  26238. wrapR: number;
  26239. /**
  26240. * With compliant hardware and browser (supporting anisotropic filtering)
  26241. * this defines the level of anisotropic filtering in the texture.
  26242. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26243. */
  26244. anisotropicFilteringLevel: number;
  26245. /**
  26246. * Define if the texture is a cube texture or if false a 2d texture.
  26247. */
  26248. isCube: boolean;
  26249. /**
  26250. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26251. */
  26252. is3D: boolean;
  26253. /**
  26254. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26255. * HDR texture are usually stored in linear space.
  26256. * This only impacts the PBR and Background materials
  26257. */
  26258. gammaSpace: boolean;
  26259. /**
  26260. * Gets whether or not the texture contains RGBD data.
  26261. */
  26262. readonly isRGBD: boolean;
  26263. /**
  26264. * Is Z inverted in the texture (useful in a cube texture).
  26265. */
  26266. invertZ: boolean;
  26267. /**
  26268. * Are mip maps generated for this texture or not.
  26269. */
  26270. readonly noMipmap: boolean;
  26271. /**
  26272. * @hidden
  26273. */
  26274. lodLevelInAlpha: boolean;
  26275. /**
  26276. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26277. */
  26278. lodGenerationOffset: number;
  26279. /**
  26280. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26281. */
  26282. lodGenerationScale: number;
  26283. /**
  26284. * Define if the texture is a render target.
  26285. */
  26286. isRenderTarget: boolean;
  26287. /**
  26288. * Define the unique id of the texture in the scene.
  26289. */
  26290. readonly uid: string;
  26291. /**
  26292. * Return a string representation of the texture.
  26293. * @returns the texture as a string
  26294. */
  26295. toString(): string;
  26296. /**
  26297. * Get the class name of the texture.
  26298. * @returns "BaseTexture"
  26299. */
  26300. getClassName(): string;
  26301. /**
  26302. * Define the list of animation attached to the texture.
  26303. */
  26304. animations: import("babylonjs/Animations/animation").Animation[];
  26305. /**
  26306. * An event triggered when the texture is disposed.
  26307. */
  26308. onDisposeObservable: Observable<BaseTexture>;
  26309. private _onDisposeObserver;
  26310. /**
  26311. * Callback triggered when the texture has been disposed.
  26312. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26313. */
  26314. onDispose: () => void;
  26315. /**
  26316. * Define the current state of the loading sequence when in delayed load mode.
  26317. */
  26318. delayLoadState: number;
  26319. private _scene;
  26320. /** @hidden */
  26321. _texture: Nullable<InternalTexture>;
  26322. private _uid;
  26323. /**
  26324. * Define if the texture is preventinga material to render or not.
  26325. * If not and the texture is not ready, the engine will use a default black texture instead.
  26326. */
  26327. readonly isBlocking: boolean;
  26328. /**
  26329. * Instantiates a new BaseTexture.
  26330. * Base class of all the textures in babylon.
  26331. * It groups all the common properties the materials, post process, lights... might need
  26332. * in order to make a correct use of the texture.
  26333. * @param scene Define the scene the texture blongs to
  26334. */
  26335. constructor(scene: Nullable<Scene>);
  26336. /**
  26337. * Get the scene the texture belongs to.
  26338. * @returns the scene or null if undefined
  26339. */
  26340. getScene(): Nullable<Scene>;
  26341. /**
  26342. * Get the texture transform matrix used to offset tile the texture for istance.
  26343. * @returns the transformation matrix
  26344. */
  26345. getTextureMatrix(): Matrix;
  26346. /**
  26347. * Get the texture reflection matrix used to rotate/transform the reflection.
  26348. * @returns the reflection matrix
  26349. */
  26350. getReflectionTextureMatrix(): Matrix;
  26351. /**
  26352. * Get the underlying lower level texture from Babylon.
  26353. * @returns the insternal texture
  26354. */
  26355. getInternalTexture(): Nullable<InternalTexture>;
  26356. /**
  26357. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26358. * @returns true if ready or not blocking
  26359. */
  26360. isReadyOrNotBlocking(): boolean;
  26361. /**
  26362. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26363. * @returns true if fully ready
  26364. */
  26365. isReady(): boolean;
  26366. private _cachedSize;
  26367. /**
  26368. * Get the size of the texture.
  26369. * @returns the texture size.
  26370. */
  26371. getSize(): ISize;
  26372. /**
  26373. * Get the base size of the texture.
  26374. * It can be different from the size if the texture has been resized for POT for instance
  26375. * @returns the base size
  26376. */
  26377. getBaseSize(): ISize;
  26378. /**
  26379. * Update the sampling mode of the texture.
  26380. * Default is Trilinear mode.
  26381. *
  26382. * | Value | Type | Description |
  26383. * | ----- | ------------------ | ----------- |
  26384. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26385. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26386. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26387. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26388. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26389. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26390. * | 7 | NEAREST_LINEAR | |
  26391. * | 8 | NEAREST_NEAREST | |
  26392. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26393. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26394. * | 11 | LINEAR_LINEAR | |
  26395. * | 12 | LINEAR_NEAREST | |
  26396. *
  26397. * > _mag_: magnification filter (close to the viewer)
  26398. * > _min_: minification filter (far from the viewer)
  26399. * > _mip_: filter used between mip map levels
  26400. *@param samplingMode Define the new sampling mode of the texture
  26401. */
  26402. updateSamplingMode(samplingMode: number): void;
  26403. /**
  26404. * Scales the texture if is `canRescale()`
  26405. * @param ratio the resize factor we want to use to rescale
  26406. */
  26407. scale(ratio: number): void;
  26408. /**
  26409. * Get if the texture can rescale.
  26410. */
  26411. readonly canRescale: boolean;
  26412. /** @hidden */
  26413. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26414. /** @hidden */
  26415. _rebuild(): void;
  26416. /**
  26417. * Triggers the load sequence in delayed load mode.
  26418. */
  26419. delayLoad(): void;
  26420. /**
  26421. * Clones the texture.
  26422. * @returns the cloned texture
  26423. */
  26424. clone(): Nullable<BaseTexture>;
  26425. /**
  26426. * Get the texture underlying type (INT, FLOAT...)
  26427. */
  26428. readonly textureType: number;
  26429. /**
  26430. * Get the texture underlying format (RGB, RGBA...)
  26431. */
  26432. readonly textureFormat: number;
  26433. /**
  26434. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26435. * This will returns an RGBA array buffer containing either in values (0-255) or
  26436. * float values (0-1) depending of the underlying buffer type.
  26437. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26438. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26439. * @param buffer defines a user defined buffer to fill with data (can be null)
  26440. * @returns The Array buffer containing the pixels data.
  26441. */
  26442. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26443. /**
  26444. * Release and destroy the underlying lower level texture aka internalTexture.
  26445. */
  26446. releaseInternalTexture(): void;
  26447. /**
  26448. * Get the polynomial representation of the texture data.
  26449. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26450. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26451. */
  26452. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26453. /** @hidden */
  26454. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26455. /** @hidden */
  26456. readonly _lodTextureMid: Nullable<BaseTexture>;
  26457. /** @hidden */
  26458. readonly _lodTextureLow: Nullable<BaseTexture>;
  26459. /**
  26460. * Dispose the texture and release its associated resources.
  26461. */
  26462. dispose(): void;
  26463. /**
  26464. * Serialize the texture into a JSON representation that can be parsed later on.
  26465. * @returns the JSON representation of the texture
  26466. */
  26467. serialize(): any;
  26468. /**
  26469. * Helper function to be called back once a list of texture contains only ready textures.
  26470. * @param textures Define the list of textures to wait for
  26471. * @param callback Define the callback triggered once the entire list will be ready
  26472. */
  26473. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26474. }
  26475. }
  26476. declare module "babylonjs/Materials/uniformBuffer" {
  26477. import { Nullable, FloatArray } from "babylonjs/types";
  26478. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26479. import { Engine } from "babylonjs/Engines/engine";
  26480. import { Effect } from "babylonjs/Materials/effect";
  26481. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26482. /**
  26483. * Uniform buffer objects.
  26484. *
  26485. * Handles blocks of uniform on the GPU.
  26486. *
  26487. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26488. *
  26489. * For more information, please refer to :
  26490. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26491. */
  26492. export class UniformBuffer {
  26493. private _engine;
  26494. private _buffer;
  26495. private _data;
  26496. private _bufferData;
  26497. private _dynamic?;
  26498. private _uniformLocations;
  26499. private _uniformSizes;
  26500. private _uniformLocationPointer;
  26501. private _needSync;
  26502. private _noUBO;
  26503. private _currentEffect;
  26504. private static _MAX_UNIFORM_SIZE;
  26505. private static _tempBuffer;
  26506. /**
  26507. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26508. * This is dynamic to allow compat with webgl 1 and 2.
  26509. * You will need to pass the name of the uniform as well as the value.
  26510. */
  26511. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26512. /**
  26513. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26514. * This is dynamic to allow compat with webgl 1 and 2.
  26515. * You will need to pass the name of the uniform as well as the value.
  26516. */
  26517. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26518. /**
  26519. * Lambda to Update a single float in a uniform buffer.
  26520. * This is dynamic to allow compat with webgl 1 and 2.
  26521. * You will need to pass the name of the uniform as well as the value.
  26522. */
  26523. updateFloat: (name: string, x: number) => void;
  26524. /**
  26525. * Lambda to Update a vec2 of float in a uniform buffer.
  26526. * This is dynamic to allow compat with webgl 1 and 2.
  26527. * You will need to pass the name of the uniform as well as the value.
  26528. */
  26529. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26530. /**
  26531. * Lambda to Update a vec3 of float in a uniform buffer.
  26532. * This is dynamic to allow compat with webgl 1 and 2.
  26533. * You will need to pass the name of the uniform as well as the value.
  26534. */
  26535. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26536. /**
  26537. * Lambda to Update a vec4 of float in a uniform buffer.
  26538. * This is dynamic to allow compat with webgl 1 and 2.
  26539. * You will need to pass the name of the uniform as well as the value.
  26540. */
  26541. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26542. /**
  26543. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26544. * This is dynamic to allow compat with webgl 1 and 2.
  26545. * You will need to pass the name of the uniform as well as the value.
  26546. */
  26547. updateMatrix: (name: string, mat: Matrix) => void;
  26548. /**
  26549. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26550. * This is dynamic to allow compat with webgl 1 and 2.
  26551. * You will need to pass the name of the uniform as well as the value.
  26552. */
  26553. updateVector3: (name: string, vector: Vector3) => void;
  26554. /**
  26555. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26556. * This is dynamic to allow compat with webgl 1 and 2.
  26557. * You will need to pass the name of the uniform as well as the value.
  26558. */
  26559. updateVector4: (name: string, vector: Vector4) => void;
  26560. /**
  26561. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26562. * This is dynamic to allow compat with webgl 1 and 2.
  26563. * You will need to pass the name of the uniform as well as the value.
  26564. */
  26565. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26566. /**
  26567. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26568. * This is dynamic to allow compat with webgl 1 and 2.
  26569. * You will need to pass the name of the uniform as well as the value.
  26570. */
  26571. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26572. /**
  26573. * Instantiates a new Uniform buffer objects.
  26574. *
  26575. * Handles blocks of uniform on the GPU.
  26576. *
  26577. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26578. *
  26579. * For more information, please refer to :
  26580. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26581. * @param engine Define the engine the buffer is associated with
  26582. * @param data Define the data contained in the buffer
  26583. * @param dynamic Define if the buffer is updatable
  26584. */
  26585. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26586. /**
  26587. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26588. * or just falling back on setUniformXXX calls.
  26589. */
  26590. readonly useUbo: boolean;
  26591. /**
  26592. * Indicates if the WebGL underlying uniform buffer is in sync
  26593. * with the javascript cache data.
  26594. */
  26595. readonly isSync: boolean;
  26596. /**
  26597. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26598. * Also, a dynamic UniformBuffer will disable cache verification and always
  26599. * update the underlying WebGL uniform buffer to the GPU.
  26600. * @returns if Dynamic, otherwise false
  26601. */
  26602. isDynamic(): boolean;
  26603. /**
  26604. * The data cache on JS side.
  26605. * @returns the underlying data as a float array
  26606. */
  26607. getData(): Float32Array;
  26608. /**
  26609. * The underlying WebGL Uniform buffer.
  26610. * @returns the webgl buffer
  26611. */
  26612. getBuffer(): Nullable<WebGLBuffer>;
  26613. /**
  26614. * std140 layout specifies how to align data within an UBO structure.
  26615. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26616. * for specs.
  26617. */
  26618. private _fillAlignment;
  26619. /**
  26620. * Adds an uniform in the buffer.
  26621. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26622. * for the layout to be correct !
  26623. * @param name Name of the uniform, as used in the uniform block in the shader.
  26624. * @param size Data size, or data directly.
  26625. */
  26626. addUniform(name: string, size: number | number[]): void;
  26627. /**
  26628. * Adds a Matrix 4x4 to the uniform buffer.
  26629. * @param name Name of the uniform, as used in the uniform block in the shader.
  26630. * @param mat A 4x4 matrix.
  26631. */
  26632. addMatrix(name: string, mat: Matrix): void;
  26633. /**
  26634. * Adds a vec2 to the uniform buffer.
  26635. * @param name Name of the uniform, as used in the uniform block in the shader.
  26636. * @param x Define the x component value of the vec2
  26637. * @param y Define the y component value of the vec2
  26638. */
  26639. addFloat2(name: string, x: number, y: number): void;
  26640. /**
  26641. * Adds a vec3 to the uniform buffer.
  26642. * @param name Name of the uniform, as used in the uniform block in the shader.
  26643. * @param x Define the x component value of the vec3
  26644. * @param y Define the y component value of the vec3
  26645. * @param z Define the z component value of the vec3
  26646. */
  26647. addFloat3(name: string, x: number, y: number, z: number): void;
  26648. /**
  26649. * Adds a vec3 to the uniform buffer.
  26650. * @param name Name of the uniform, as used in the uniform block in the shader.
  26651. * @param color Define the vec3 from a Color
  26652. */
  26653. addColor3(name: string, color: Color3): void;
  26654. /**
  26655. * Adds a vec4 to the uniform buffer.
  26656. * @param name Name of the uniform, as used in the uniform block in the shader.
  26657. * @param color Define the rgb components from a Color
  26658. * @param alpha Define the a component of the vec4
  26659. */
  26660. addColor4(name: string, color: Color3, alpha: number): void;
  26661. /**
  26662. * Adds a vec3 to the uniform buffer.
  26663. * @param name Name of the uniform, as used in the uniform block in the shader.
  26664. * @param vector Define the vec3 components from a Vector
  26665. */
  26666. addVector3(name: string, vector: Vector3): void;
  26667. /**
  26668. * Adds a Matrix 3x3 to the uniform buffer.
  26669. * @param name Name of the uniform, as used in the uniform block in the shader.
  26670. */
  26671. addMatrix3x3(name: string): void;
  26672. /**
  26673. * Adds a Matrix 2x2 to the uniform buffer.
  26674. * @param name Name of the uniform, as used in the uniform block in the shader.
  26675. */
  26676. addMatrix2x2(name: string): void;
  26677. /**
  26678. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26679. */
  26680. create(): void;
  26681. /** @hidden */
  26682. _rebuild(): void;
  26683. /**
  26684. * Updates the WebGL Uniform Buffer on the GPU.
  26685. * If the `dynamic` flag is set to true, no cache comparison is done.
  26686. * Otherwise, the buffer will be updated only if the cache differs.
  26687. */
  26688. update(): void;
  26689. /**
  26690. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26691. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26692. * @param data Define the flattened data
  26693. * @param size Define the size of the data.
  26694. */
  26695. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26696. private _updateMatrix3x3ForUniform;
  26697. private _updateMatrix3x3ForEffect;
  26698. private _updateMatrix2x2ForEffect;
  26699. private _updateMatrix2x2ForUniform;
  26700. private _updateFloatForEffect;
  26701. private _updateFloatForUniform;
  26702. private _updateFloat2ForEffect;
  26703. private _updateFloat2ForUniform;
  26704. private _updateFloat3ForEffect;
  26705. private _updateFloat3ForUniform;
  26706. private _updateFloat4ForEffect;
  26707. private _updateFloat4ForUniform;
  26708. private _updateMatrixForEffect;
  26709. private _updateMatrixForUniform;
  26710. private _updateVector3ForEffect;
  26711. private _updateVector3ForUniform;
  26712. private _updateVector4ForEffect;
  26713. private _updateVector4ForUniform;
  26714. private _updateColor3ForEffect;
  26715. private _updateColor3ForUniform;
  26716. private _updateColor4ForEffect;
  26717. private _updateColor4ForUniform;
  26718. /**
  26719. * Sets a sampler uniform on the effect.
  26720. * @param name Define the name of the sampler.
  26721. * @param texture Define the texture to set in the sampler
  26722. */
  26723. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26724. /**
  26725. * Directly updates the value of the uniform in the cache AND on the GPU.
  26726. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26727. * @param data Define the flattened data
  26728. */
  26729. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26730. /**
  26731. * Binds this uniform buffer to an effect.
  26732. * @param effect Define the effect to bind the buffer to
  26733. * @param name Name of the uniform block in the shader.
  26734. */
  26735. bindToEffect(effect: Effect, name: string): void;
  26736. /**
  26737. * Disposes the uniform buffer.
  26738. */
  26739. dispose(): void;
  26740. }
  26741. }
  26742. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26743. import { Nullable } from "babylonjs/types";
  26744. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26745. /**
  26746. * This represents the required contract to create a new type of texture loader.
  26747. */
  26748. export interface IInternalTextureLoader {
  26749. /**
  26750. * Defines wether the loader supports cascade loading the different faces.
  26751. */
  26752. supportCascades: boolean;
  26753. /**
  26754. * This returns if the loader support the current file information.
  26755. * @param extension defines the file extension of the file being loaded
  26756. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26757. * @param fallback defines the fallback internal texture if any
  26758. * @param isBase64 defines whether the texture is encoded as a base64
  26759. * @param isBuffer defines whether the texture data are stored as a buffer
  26760. * @returns true if the loader can load the specified file
  26761. */
  26762. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26763. /**
  26764. * Transform the url before loading if required.
  26765. * @param rootUrl the url of the texture
  26766. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26767. * @returns the transformed texture
  26768. */
  26769. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26770. /**
  26771. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26772. * @param rootUrl the url of the texture
  26773. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26774. * @returns the fallback texture
  26775. */
  26776. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26777. /**
  26778. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26779. * @param data contains the texture data
  26780. * @param texture defines the BabylonJS internal texture
  26781. * @param createPolynomials will be true if polynomials have been requested
  26782. * @param onLoad defines the callback to trigger once the texture is ready
  26783. * @param onError defines the callback to trigger in case of error
  26784. */
  26785. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26786. /**
  26787. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26788. * @param data contains the texture data
  26789. * @param texture defines the BabylonJS internal texture
  26790. * @param callback defines the method to call once ready to upload
  26791. */
  26792. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26793. }
  26794. }
  26795. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26796. import { Scene } from "babylonjs/scene";
  26797. import { Engine } from "babylonjs/Engines/engine";
  26798. import { Texture } from "babylonjs/Materials/Textures/texture";
  26799. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26800. /**
  26801. * Creation options of the multi render target texture.
  26802. */
  26803. export interface IMultiRenderTargetOptions {
  26804. /**
  26805. * Define if the texture needs to create mip maps after render.
  26806. */
  26807. generateMipMaps?: boolean;
  26808. /**
  26809. * Define the types of all the draw buffers we want to create
  26810. */
  26811. types?: number[];
  26812. /**
  26813. * Define the sampling modes of all the draw buffers we want to create
  26814. */
  26815. samplingModes?: number[];
  26816. /**
  26817. * Define if a depth buffer is required
  26818. */
  26819. generateDepthBuffer?: boolean;
  26820. /**
  26821. * Define if a stencil buffer is required
  26822. */
  26823. generateStencilBuffer?: boolean;
  26824. /**
  26825. * Define if a depth texture is required instead of a depth buffer
  26826. */
  26827. generateDepthTexture?: boolean;
  26828. /**
  26829. * Define the number of desired draw buffers
  26830. */
  26831. textureCount?: number;
  26832. /**
  26833. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26834. */
  26835. doNotChangeAspectRatio?: boolean;
  26836. /**
  26837. * Define the default type of the buffers we are creating
  26838. */
  26839. defaultType?: number;
  26840. }
  26841. /**
  26842. * A multi render target, like a render target provides the ability to render to a texture.
  26843. * Unlike the render target, it can render to several draw buffers in one draw.
  26844. * This is specially interesting in deferred rendering or for any effects requiring more than
  26845. * just one color from a single pass.
  26846. */
  26847. export class MultiRenderTarget extends RenderTargetTexture {
  26848. private _internalTextures;
  26849. private _textures;
  26850. private _multiRenderTargetOptions;
  26851. /**
  26852. * Get if draw buffers are currently supported by the used hardware and browser.
  26853. */
  26854. readonly isSupported: boolean;
  26855. /**
  26856. * Get the list of textures generated by the multi render target.
  26857. */
  26858. readonly textures: Texture[];
  26859. /**
  26860. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26861. */
  26862. readonly depthTexture: Texture;
  26863. /**
  26864. * Set the wrapping mode on U of all the textures we are rendering to.
  26865. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26866. */
  26867. wrapU: number;
  26868. /**
  26869. * Set the wrapping mode on V of all the textures we are rendering to.
  26870. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26871. */
  26872. wrapV: number;
  26873. /**
  26874. * Instantiate a new multi render target texture.
  26875. * A multi render target, like a render target provides the ability to render to a texture.
  26876. * Unlike the render target, it can render to several draw buffers in one draw.
  26877. * This is specially interesting in deferred rendering or for any effects requiring more than
  26878. * just one color from a single pass.
  26879. * @param name Define the name of the texture
  26880. * @param size Define the size of the buffers to render to
  26881. * @param count Define the number of target we are rendering into
  26882. * @param scene Define the scene the texture belongs to
  26883. * @param options Define the options used to create the multi render target
  26884. */
  26885. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26886. /** @hidden */
  26887. _rebuild(): void;
  26888. private _createInternalTextures;
  26889. private _createTextures;
  26890. /**
  26891. * Define the number of samples used if MSAA is enabled.
  26892. */
  26893. samples: number;
  26894. /**
  26895. * Resize all the textures in the multi render target.
  26896. * Be carrefull as it will recreate all the data in the new texture.
  26897. * @param size Define the new size
  26898. */
  26899. resize(size: any): void;
  26900. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26901. /**
  26902. * Dispose the render targets and their associated resources
  26903. */
  26904. dispose(): void;
  26905. /**
  26906. * Release all the underlying texture used as draw buffers.
  26907. */
  26908. releaseInternalTextures(): void;
  26909. }
  26910. }
  26911. declare module "babylonjs/Audio/analyser" {
  26912. import { Scene } from "babylonjs/scene";
  26913. /**
  26914. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26915. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26916. */
  26917. export class Analyser {
  26918. /**
  26919. * Gets or sets the smoothing
  26920. * @ignorenaming
  26921. */
  26922. SMOOTHING: number;
  26923. /**
  26924. * Gets or sets the FFT table size
  26925. * @ignorenaming
  26926. */
  26927. FFT_SIZE: number;
  26928. /**
  26929. * Gets or sets the bar graph amplitude
  26930. * @ignorenaming
  26931. */
  26932. BARGRAPHAMPLITUDE: number;
  26933. /**
  26934. * Gets or sets the position of the debug canvas
  26935. * @ignorenaming
  26936. */
  26937. DEBUGCANVASPOS: {
  26938. x: number;
  26939. y: number;
  26940. };
  26941. /**
  26942. * Gets or sets the debug canvas size
  26943. * @ignorenaming
  26944. */
  26945. DEBUGCANVASSIZE: {
  26946. width: number;
  26947. height: number;
  26948. };
  26949. private _byteFreqs;
  26950. private _byteTime;
  26951. private _floatFreqs;
  26952. private _webAudioAnalyser;
  26953. private _debugCanvas;
  26954. private _debugCanvasContext;
  26955. private _scene;
  26956. private _registerFunc;
  26957. private _audioEngine;
  26958. /**
  26959. * Creates a new analyser
  26960. * @param scene defines hosting scene
  26961. */
  26962. constructor(scene: Scene);
  26963. /**
  26964. * Get the number of data values you will have to play with for the visualization
  26965. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26966. * @returns a number
  26967. */
  26968. getFrequencyBinCount(): number;
  26969. /**
  26970. * Gets the current frequency data as a byte array
  26971. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26972. * @returns a Uint8Array
  26973. */
  26974. getByteFrequencyData(): Uint8Array;
  26975. /**
  26976. * Gets the current waveform as a byte array
  26977. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26978. * @returns a Uint8Array
  26979. */
  26980. getByteTimeDomainData(): Uint8Array;
  26981. /**
  26982. * Gets the current frequency data as a float array
  26983. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26984. * @returns a Float32Array
  26985. */
  26986. getFloatFrequencyData(): Float32Array;
  26987. /**
  26988. * Renders the debug canvas
  26989. */
  26990. drawDebugCanvas(): void;
  26991. /**
  26992. * Stops rendering the debug canvas and removes it
  26993. */
  26994. stopDebugCanvas(): void;
  26995. /**
  26996. * Connects two audio nodes
  26997. * @param inputAudioNode defines first node to connect
  26998. * @param outputAudioNode defines second node to connect
  26999. */
  27000. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27001. /**
  27002. * Releases all associated resources
  27003. */
  27004. dispose(): void;
  27005. }
  27006. }
  27007. declare module "babylonjs/Audio/audioEngine" {
  27008. import { IDisposable } from "babylonjs/scene";
  27009. import { Analyser } from "babylonjs/Audio/analyser";
  27010. import { Nullable } from "babylonjs/types";
  27011. import { Observable } from "babylonjs/Misc/observable";
  27012. /**
  27013. * This represents an audio engine and it is responsible
  27014. * to play, synchronize and analyse sounds throughout the application.
  27015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27016. */
  27017. export interface IAudioEngine extends IDisposable {
  27018. /**
  27019. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27020. */
  27021. readonly canUseWebAudio: boolean;
  27022. /**
  27023. * Gets the current AudioContext if available.
  27024. */
  27025. readonly audioContext: Nullable<AudioContext>;
  27026. /**
  27027. * The master gain node defines the global audio volume of your audio engine.
  27028. */
  27029. readonly masterGain: GainNode;
  27030. /**
  27031. * Gets whether or not mp3 are supported by your browser.
  27032. */
  27033. readonly isMP3supported: boolean;
  27034. /**
  27035. * Gets whether or not ogg are supported by your browser.
  27036. */
  27037. readonly isOGGsupported: boolean;
  27038. /**
  27039. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27040. * @ignoreNaming
  27041. */
  27042. WarnedWebAudioUnsupported: boolean;
  27043. /**
  27044. * Defines if the audio engine relies on a custom unlocked button.
  27045. * In this case, the embedded button will not be displayed.
  27046. */
  27047. useCustomUnlockedButton: boolean;
  27048. /**
  27049. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27050. */
  27051. readonly unlocked: boolean;
  27052. /**
  27053. * Event raised when audio has been unlocked on the browser.
  27054. */
  27055. onAudioUnlockedObservable: Observable<AudioEngine>;
  27056. /**
  27057. * Event raised when audio has been locked on the browser.
  27058. */
  27059. onAudioLockedObservable: Observable<AudioEngine>;
  27060. /**
  27061. * Flags the audio engine in Locked state.
  27062. * This happens due to new browser policies preventing audio to autoplay.
  27063. */
  27064. lock(): void;
  27065. /**
  27066. * Unlocks the audio engine once a user action has been done on the dom.
  27067. * This is helpful to resume play once browser policies have been satisfied.
  27068. */
  27069. unlock(): void;
  27070. }
  27071. /**
  27072. * This represents the default audio engine used in babylon.
  27073. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27074. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27075. */
  27076. export class AudioEngine implements IAudioEngine {
  27077. private _audioContext;
  27078. private _audioContextInitialized;
  27079. private _muteButton;
  27080. private _hostElement;
  27081. /**
  27082. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27083. */
  27084. canUseWebAudio: boolean;
  27085. /**
  27086. * The master gain node defines the global audio volume of your audio engine.
  27087. */
  27088. masterGain: GainNode;
  27089. /**
  27090. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27091. * @ignoreNaming
  27092. */
  27093. WarnedWebAudioUnsupported: boolean;
  27094. /**
  27095. * Gets whether or not mp3 are supported by your browser.
  27096. */
  27097. isMP3supported: boolean;
  27098. /**
  27099. * Gets whether or not ogg are supported by your browser.
  27100. */
  27101. isOGGsupported: boolean;
  27102. /**
  27103. * Gets whether audio has been unlocked on the device.
  27104. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27105. * a user interaction has happened.
  27106. */
  27107. unlocked: boolean;
  27108. /**
  27109. * Defines if the audio engine relies on a custom unlocked button.
  27110. * In this case, the embedded button will not be displayed.
  27111. */
  27112. useCustomUnlockedButton: boolean;
  27113. /**
  27114. * Event raised when audio has been unlocked on the browser.
  27115. */
  27116. onAudioUnlockedObservable: Observable<AudioEngine>;
  27117. /**
  27118. * Event raised when audio has been locked on the browser.
  27119. */
  27120. onAudioLockedObservable: Observable<AudioEngine>;
  27121. /**
  27122. * Gets the current AudioContext if available.
  27123. */
  27124. readonly audioContext: Nullable<AudioContext>;
  27125. private _connectedAnalyser;
  27126. /**
  27127. * Instantiates a new audio engine.
  27128. *
  27129. * There should be only one per page as some browsers restrict the number
  27130. * of audio contexts you can create.
  27131. * @param hostElement defines the host element where to display the mute icon if necessary
  27132. */
  27133. constructor(hostElement?: Nullable<HTMLElement>);
  27134. /**
  27135. * Flags the audio engine in Locked state.
  27136. * This happens due to new browser policies preventing audio to autoplay.
  27137. */
  27138. lock(): void;
  27139. /**
  27140. * Unlocks the audio engine once a user action has been done on the dom.
  27141. * This is helpful to resume play once browser policies have been satisfied.
  27142. */
  27143. unlock(): void;
  27144. private _resumeAudioContext;
  27145. private _initializeAudioContext;
  27146. private _tryToRun;
  27147. private _triggerRunningState;
  27148. private _triggerSuspendedState;
  27149. private _displayMuteButton;
  27150. private _moveButtonToTopLeft;
  27151. private _onResize;
  27152. private _hideMuteButton;
  27153. /**
  27154. * Destroy and release the resources associated with the audio ccontext.
  27155. */
  27156. dispose(): void;
  27157. /**
  27158. * Gets the global volume sets on the master gain.
  27159. * @returns the global volume if set or -1 otherwise
  27160. */
  27161. getGlobalVolume(): number;
  27162. /**
  27163. * Sets the global volume of your experience (sets on the master gain).
  27164. * @param newVolume Defines the new global volume of the application
  27165. */
  27166. setGlobalVolume(newVolume: number): void;
  27167. /**
  27168. * Connect the audio engine to an audio analyser allowing some amazing
  27169. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27171. * @param analyser The analyser to connect to the engine
  27172. */
  27173. connectToAnalyser(analyser: Analyser): void;
  27174. }
  27175. }
  27176. declare module "babylonjs/Loading/loadingScreen" {
  27177. /**
  27178. * Interface used to present a loading screen while loading a scene
  27179. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27180. */
  27181. export interface ILoadingScreen {
  27182. /**
  27183. * Function called to display the loading screen
  27184. */
  27185. displayLoadingUI: () => void;
  27186. /**
  27187. * Function called to hide the loading screen
  27188. */
  27189. hideLoadingUI: () => void;
  27190. /**
  27191. * Gets or sets the color to use for the background
  27192. */
  27193. loadingUIBackgroundColor: string;
  27194. /**
  27195. * Gets or sets the text to display while loading
  27196. */
  27197. loadingUIText: string;
  27198. }
  27199. /**
  27200. * Class used for the default loading screen
  27201. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27202. */
  27203. export class DefaultLoadingScreen implements ILoadingScreen {
  27204. private _renderingCanvas;
  27205. private _loadingText;
  27206. private _loadingDivBackgroundColor;
  27207. private _loadingDiv;
  27208. private _loadingTextDiv;
  27209. /**
  27210. * Creates a new default loading screen
  27211. * @param _renderingCanvas defines the canvas used to render the scene
  27212. * @param _loadingText defines the default text to display
  27213. * @param _loadingDivBackgroundColor defines the default background color
  27214. */
  27215. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27216. /**
  27217. * Function called to display the loading screen
  27218. */
  27219. displayLoadingUI(): void;
  27220. /**
  27221. * Function called to hide the loading screen
  27222. */
  27223. hideLoadingUI(): void;
  27224. /**
  27225. * Gets or sets the text to display while loading
  27226. */
  27227. loadingUIText: string;
  27228. /**
  27229. * Gets or sets the color to use for the background
  27230. */
  27231. loadingUIBackgroundColor: string;
  27232. private _resizeLoadingUI;
  27233. }
  27234. }
  27235. declare module "babylonjs/Materials/Textures/videoTexture" {
  27236. import { Observable } from "babylonjs/Misc/observable";
  27237. import { Nullable } from "babylonjs/types";
  27238. import { Scene } from "babylonjs/scene";
  27239. import { Texture } from "babylonjs/Materials/Textures/texture";
  27240. /**
  27241. * Settings for finer control over video usage
  27242. */
  27243. export interface VideoTextureSettings {
  27244. /**
  27245. * Applies `autoplay` to video, if specified
  27246. */
  27247. autoPlay?: boolean;
  27248. /**
  27249. * Applies `loop` to video, if specified
  27250. */
  27251. loop?: boolean;
  27252. /**
  27253. * Automatically updates internal texture from video at every frame in the render loop
  27254. */
  27255. autoUpdateTexture: boolean;
  27256. /**
  27257. * Image src displayed during the video loading or until the user interacts with the video.
  27258. */
  27259. poster?: string;
  27260. }
  27261. /**
  27262. * If you want to display a video in your scene, this is the special texture for that.
  27263. * This special texture works similar to other textures, with the exception of a few parameters.
  27264. * @see https://doc.babylonjs.com/how_to/video_texture
  27265. */
  27266. export class VideoTexture extends Texture {
  27267. /**
  27268. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27269. */
  27270. readonly autoUpdateTexture: boolean;
  27271. /**
  27272. * The video instance used by the texture internally
  27273. */
  27274. readonly video: HTMLVideoElement;
  27275. private _onUserActionRequestedObservable;
  27276. /**
  27277. * Event triggerd when a dom action is required by the user to play the video.
  27278. * This happens due to recent changes in browser policies preventing video to auto start.
  27279. */
  27280. readonly onUserActionRequestedObservable: Observable<Texture>;
  27281. private _generateMipMaps;
  27282. private _engine;
  27283. private _stillImageCaptured;
  27284. private _displayingPosterTexture;
  27285. private _settings;
  27286. private _createInternalTextureOnEvent;
  27287. /**
  27288. * Creates a video texture.
  27289. * If you want to display a video in your scene, this is the special texture for that.
  27290. * This special texture works similar to other textures, with the exception of a few parameters.
  27291. * @see https://doc.babylonjs.com/how_to/video_texture
  27292. * @param name optional name, will detect from video source, if not defined
  27293. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27294. * @param scene is obviously the current scene.
  27295. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27296. * @param invertY is false by default but can be used to invert video on Y axis
  27297. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27298. * @param settings allows finer control over video usage
  27299. */
  27300. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27301. private _getName;
  27302. private _getVideo;
  27303. private _createInternalTexture;
  27304. private reset;
  27305. /**
  27306. * @hidden Internal method to initiate `update`.
  27307. */
  27308. _rebuild(): void;
  27309. /**
  27310. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27311. */
  27312. update(): void;
  27313. /**
  27314. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27315. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27316. */
  27317. updateTexture(isVisible: boolean): void;
  27318. protected _updateInternalTexture: () => void;
  27319. /**
  27320. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27321. * @param url New url.
  27322. */
  27323. updateURL(url: string): void;
  27324. /**
  27325. * Dispose the texture and release its associated resources.
  27326. */
  27327. dispose(): void;
  27328. /**
  27329. * Creates a video texture straight from a stream.
  27330. * @param scene Define the scene the texture should be created in
  27331. * @param stream Define the stream the texture should be created from
  27332. * @returns The created video texture as a promise
  27333. */
  27334. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27335. /**
  27336. * Creates a video texture straight from your WebCam video feed.
  27337. * @param scene Define the scene the texture should be created in
  27338. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27339. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27340. * @returns The created video texture as a promise
  27341. */
  27342. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27343. minWidth: number;
  27344. maxWidth: number;
  27345. minHeight: number;
  27346. maxHeight: number;
  27347. deviceId: string;
  27348. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27349. /**
  27350. * Creates a video texture straight from your WebCam video feed.
  27351. * @param scene Define the scene the texture should be created in
  27352. * @param onReady Define a callback to triggered once the texture will be ready
  27353. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27354. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27355. */
  27356. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27357. minWidth: number;
  27358. maxWidth: number;
  27359. minHeight: number;
  27360. maxHeight: number;
  27361. deviceId: string;
  27362. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27363. }
  27364. }
  27365. declare module "babylonjs/Engines/engine" {
  27366. import { Observable } from "babylonjs/Misc/observable";
  27367. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27368. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27369. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27370. import { Camera } from "babylonjs/Cameras/camera";
  27371. import { Scene } from "babylonjs/scene";
  27372. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27373. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27374. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27375. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27376. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27377. import { Material } from "babylonjs/Materials/material";
  27378. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27379. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27380. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27381. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27382. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27383. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27384. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27385. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27386. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27387. import { WebRequest } from "babylonjs/Misc/webRequest";
  27388. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27389. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27390. /**
  27391. * Interface for attribute information associated with buffer instanciation
  27392. */
  27393. export class InstancingAttributeInfo {
  27394. /**
  27395. * Index/offset of the attribute in the vertex shader
  27396. */
  27397. index: number;
  27398. /**
  27399. * size of the attribute, 1, 2, 3 or 4
  27400. */
  27401. attributeSize: number;
  27402. /**
  27403. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27404. * default is FLOAT
  27405. */
  27406. attribyteType: number;
  27407. /**
  27408. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27409. */
  27410. normalized: boolean;
  27411. /**
  27412. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27413. */
  27414. offset: number;
  27415. /**
  27416. * Name of the GLSL attribute, for debugging purpose only
  27417. */
  27418. attributeName: string;
  27419. }
  27420. /**
  27421. * Define options used to create a depth texture
  27422. */
  27423. export class DepthTextureCreationOptions {
  27424. /** Specifies whether or not a stencil should be allocated in the texture */
  27425. generateStencil?: boolean;
  27426. /** Specifies whether or not bilinear filtering is enable on the texture */
  27427. bilinearFiltering?: boolean;
  27428. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27429. comparisonFunction?: number;
  27430. /** Specifies if the created texture is a cube texture */
  27431. isCube?: boolean;
  27432. }
  27433. /**
  27434. * Class used to describe the capabilities of the engine relatively to the current browser
  27435. */
  27436. export class EngineCapabilities {
  27437. /** Maximum textures units per fragment shader */
  27438. maxTexturesImageUnits: number;
  27439. /** Maximum texture units per vertex shader */
  27440. maxVertexTextureImageUnits: number;
  27441. /** Maximum textures units in the entire pipeline */
  27442. maxCombinedTexturesImageUnits: number;
  27443. /** Maximum texture size */
  27444. maxTextureSize: number;
  27445. /** Maximum cube texture size */
  27446. maxCubemapTextureSize: number;
  27447. /** Maximum render texture size */
  27448. maxRenderTextureSize: number;
  27449. /** Maximum number of vertex attributes */
  27450. maxVertexAttribs: number;
  27451. /** Maximum number of varyings */
  27452. maxVaryingVectors: number;
  27453. /** Maximum number of uniforms per vertex shader */
  27454. maxVertexUniformVectors: number;
  27455. /** Maximum number of uniforms per fragment shader */
  27456. maxFragmentUniformVectors: number;
  27457. /** Defines if standard derivates (dx/dy) are supported */
  27458. standardDerivatives: boolean;
  27459. /** Defines if s3tc texture compression is supported */
  27460. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27461. /** Defines if pvrtc texture compression is supported */
  27462. pvrtc: any;
  27463. /** Defines if etc1 texture compression is supported */
  27464. etc1: any;
  27465. /** Defines if etc2 texture compression is supported */
  27466. etc2: any;
  27467. /** Defines if astc texture compression is supported */
  27468. astc: any;
  27469. /** Defines if float textures are supported */
  27470. textureFloat: boolean;
  27471. /** Defines if vertex array objects are supported */
  27472. vertexArrayObject: boolean;
  27473. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27474. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27475. /** Gets the maximum level of anisotropy supported */
  27476. maxAnisotropy: number;
  27477. /** Defines if instancing is supported */
  27478. instancedArrays: boolean;
  27479. /** Defines if 32 bits indices are supported */
  27480. uintIndices: boolean;
  27481. /** Defines if high precision shaders are supported */
  27482. highPrecisionShaderSupported: boolean;
  27483. /** Defines if depth reading in the fragment shader is supported */
  27484. fragmentDepthSupported: boolean;
  27485. /** Defines if float texture linear filtering is supported*/
  27486. textureFloatLinearFiltering: boolean;
  27487. /** Defines if rendering to float textures is supported */
  27488. textureFloatRender: boolean;
  27489. /** Defines if half float textures are supported*/
  27490. textureHalfFloat: boolean;
  27491. /** Defines if half float texture linear filtering is supported*/
  27492. textureHalfFloatLinearFiltering: boolean;
  27493. /** Defines if rendering to half float textures is supported */
  27494. textureHalfFloatRender: boolean;
  27495. /** Defines if textureLOD shader command is supported */
  27496. textureLOD: boolean;
  27497. /** Defines if draw buffers extension is supported */
  27498. drawBuffersExtension: boolean;
  27499. /** Defines if depth textures are supported */
  27500. depthTextureExtension: boolean;
  27501. /** Defines if float color buffer are supported */
  27502. colorBufferFloat: boolean;
  27503. /** Gets disjoint timer query extension (null if not supported) */
  27504. timerQuery: EXT_disjoint_timer_query;
  27505. /** Defines if timestamp can be used with timer query */
  27506. canUseTimestampForTimerQuery: boolean;
  27507. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27508. multiview: any;
  27509. /** Function used to let the system compiles shaders in background */
  27510. parallelShaderCompile: {
  27511. COMPLETION_STATUS_KHR: number;
  27512. };
  27513. }
  27514. /** Interface defining initialization parameters for Engine class */
  27515. export interface EngineOptions extends WebGLContextAttributes {
  27516. /**
  27517. * Defines if the engine should no exceed a specified device ratio
  27518. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27519. */
  27520. limitDeviceRatio?: number;
  27521. /**
  27522. * Defines if webvr should be enabled automatically
  27523. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27524. */
  27525. autoEnableWebVR?: boolean;
  27526. /**
  27527. * Defines if webgl2 should be turned off even if supported
  27528. * @see http://doc.babylonjs.com/features/webgl2
  27529. */
  27530. disableWebGL2Support?: boolean;
  27531. /**
  27532. * Defines if webaudio should be initialized as well
  27533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27534. */
  27535. audioEngine?: boolean;
  27536. /**
  27537. * Defines if animations should run using a deterministic lock step
  27538. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27539. */
  27540. deterministicLockstep?: boolean;
  27541. /** Defines the maximum steps to use with deterministic lock step mode */
  27542. lockstepMaxSteps?: number;
  27543. /**
  27544. * Defines that engine should ignore context lost events
  27545. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27546. */
  27547. doNotHandleContextLost?: boolean;
  27548. /**
  27549. * Defines that engine should ignore modifying touch action attribute and style
  27550. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27551. */
  27552. doNotHandleTouchAction?: boolean;
  27553. /**
  27554. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27555. */
  27556. useHighPrecisionFloats?: boolean;
  27557. }
  27558. /**
  27559. * Defines the interface used by display changed events
  27560. */
  27561. export interface IDisplayChangedEventArgs {
  27562. /** Gets the vrDisplay object (if any) */
  27563. vrDisplay: Nullable<any>;
  27564. /** Gets a boolean indicating if webVR is supported */
  27565. vrSupported: boolean;
  27566. }
  27567. /**
  27568. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27569. */
  27570. export class Engine {
  27571. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27572. static ExceptionList: ({
  27573. key: string;
  27574. capture: string;
  27575. captureConstraint: number;
  27576. targets: string[];
  27577. } | {
  27578. key: string;
  27579. capture: null;
  27580. captureConstraint: null;
  27581. targets: string[];
  27582. })[];
  27583. /** Gets the list of created engines */
  27584. static readonly Instances: Engine[];
  27585. /**
  27586. * Gets the latest created engine
  27587. */
  27588. static readonly LastCreatedEngine: Nullable<Engine>;
  27589. /**
  27590. * Gets the latest created scene
  27591. */
  27592. static readonly LastCreatedScene: Nullable<Scene>;
  27593. /**
  27594. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27595. * @param flag defines which part of the materials must be marked as dirty
  27596. * @param predicate defines a predicate used to filter which materials should be affected
  27597. */
  27598. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27599. /**
  27600. * Hidden
  27601. */
  27602. static _TextureLoaders: IInternalTextureLoader[];
  27603. /** Defines that alpha blending is disabled */
  27604. static readonly ALPHA_DISABLE: number;
  27605. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27606. static readonly ALPHA_ADD: number;
  27607. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27608. static readonly ALPHA_COMBINE: number;
  27609. /** Defines that alpha blending to DEST - SRC * DEST */
  27610. static readonly ALPHA_SUBTRACT: number;
  27611. /** Defines that alpha blending to SRC * DEST */
  27612. static readonly ALPHA_MULTIPLY: number;
  27613. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27614. static readonly ALPHA_MAXIMIZED: number;
  27615. /** Defines that alpha blending to SRC + DEST */
  27616. static readonly ALPHA_ONEONE: number;
  27617. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27618. static readonly ALPHA_PREMULTIPLIED: number;
  27619. /**
  27620. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27621. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27622. */
  27623. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27624. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27625. static readonly ALPHA_INTERPOLATE: number;
  27626. /**
  27627. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27628. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27629. */
  27630. static readonly ALPHA_SCREENMODE: number;
  27631. /** Defines that the ressource is not delayed*/
  27632. static readonly DELAYLOADSTATE_NONE: number;
  27633. /** Defines that the ressource was successfully delay loaded */
  27634. static readonly DELAYLOADSTATE_LOADED: number;
  27635. /** Defines that the ressource is currently delay loading */
  27636. static readonly DELAYLOADSTATE_LOADING: number;
  27637. /** Defines that the ressource is delayed and has not started loading */
  27638. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27639. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27640. static readonly NEVER: number;
  27641. /** 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 */
  27642. static readonly ALWAYS: number;
  27643. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27644. static readonly LESS: number;
  27645. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27646. static readonly EQUAL: number;
  27647. /** 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 */
  27648. static readonly LEQUAL: number;
  27649. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27650. static readonly GREATER: number;
  27651. /** 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 */
  27652. static readonly GEQUAL: number;
  27653. /** 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 */
  27654. static readonly NOTEQUAL: number;
  27655. /** Passed to stencilOperation to specify that stencil value must be kept */
  27656. static readonly KEEP: number;
  27657. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27658. static readonly REPLACE: number;
  27659. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27660. static readonly INCR: number;
  27661. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27662. static readonly DECR: number;
  27663. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27664. static readonly INVERT: number;
  27665. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27666. static readonly INCR_WRAP: number;
  27667. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27668. static readonly DECR_WRAP: number;
  27669. /** Texture is not repeating outside of 0..1 UVs */
  27670. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27671. /** Texture is repeating outside of 0..1 UVs */
  27672. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27673. /** Texture is repeating and mirrored */
  27674. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27675. /** ALPHA */
  27676. static readonly TEXTUREFORMAT_ALPHA: number;
  27677. /** LUMINANCE */
  27678. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27679. /** LUMINANCE_ALPHA */
  27680. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27681. /** RGB */
  27682. static readonly TEXTUREFORMAT_RGB: number;
  27683. /** RGBA */
  27684. static readonly TEXTUREFORMAT_RGBA: number;
  27685. /** RED */
  27686. static readonly TEXTUREFORMAT_RED: number;
  27687. /** RED (2nd reference) */
  27688. static readonly TEXTUREFORMAT_R: number;
  27689. /** RG */
  27690. static readonly TEXTUREFORMAT_RG: number;
  27691. /** RED_INTEGER */
  27692. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27693. /** RED_INTEGER (2nd reference) */
  27694. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27695. /** RG_INTEGER */
  27696. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27697. /** RGB_INTEGER */
  27698. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27699. /** RGBA_INTEGER */
  27700. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27701. /** UNSIGNED_BYTE */
  27702. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27703. /** UNSIGNED_BYTE (2nd reference) */
  27704. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27705. /** FLOAT */
  27706. static readonly TEXTURETYPE_FLOAT: number;
  27707. /** HALF_FLOAT */
  27708. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27709. /** BYTE */
  27710. static readonly TEXTURETYPE_BYTE: number;
  27711. /** SHORT */
  27712. static readonly TEXTURETYPE_SHORT: number;
  27713. /** UNSIGNED_SHORT */
  27714. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27715. /** INT */
  27716. static readonly TEXTURETYPE_INT: number;
  27717. /** UNSIGNED_INT */
  27718. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27719. /** UNSIGNED_SHORT_4_4_4_4 */
  27720. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27721. /** UNSIGNED_SHORT_5_5_5_1 */
  27722. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27723. /** UNSIGNED_SHORT_5_6_5 */
  27724. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27725. /** UNSIGNED_INT_2_10_10_10_REV */
  27726. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27727. /** UNSIGNED_INT_24_8 */
  27728. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27729. /** UNSIGNED_INT_10F_11F_11F_REV */
  27730. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27731. /** UNSIGNED_INT_5_9_9_9_REV */
  27732. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27733. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27734. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27735. /** nearest is mag = nearest and min = nearest and mip = linear */
  27736. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27737. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27738. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27739. /** Trilinear is mag = linear and min = linear and mip = linear */
  27740. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27741. /** nearest is mag = nearest and min = nearest and mip = linear */
  27742. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27743. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27744. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27745. /** Trilinear is mag = linear and min = linear and mip = linear */
  27746. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27747. /** mag = nearest and min = nearest and mip = nearest */
  27748. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27749. /** mag = nearest and min = linear and mip = nearest */
  27750. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27751. /** mag = nearest and min = linear and mip = linear */
  27752. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27753. /** mag = nearest and min = linear and mip = none */
  27754. static readonly TEXTURE_NEAREST_LINEAR: number;
  27755. /** mag = nearest and min = nearest and mip = none */
  27756. static readonly TEXTURE_NEAREST_NEAREST: number;
  27757. /** mag = linear and min = nearest and mip = nearest */
  27758. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27759. /** mag = linear and min = nearest and mip = linear */
  27760. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27761. /** mag = linear and min = linear and mip = none */
  27762. static readonly TEXTURE_LINEAR_LINEAR: number;
  27763. /** mag = linear and min = nearest and mip = none */
  27764. static readonly TEXTURE_LINEAR_NEAREST: number;
  27765. /** Explicit coordinates mode */
  27766. static readonly TEXTURE_EXPLICIT_MODE: number;
  27767. /** Spherical coordinates mode */
  27768. static readonly TEXTURE_SPHERICAL_MODE: number;
  27769. /** Planar coordinates mode */
  27770. static readonly TEXTURE_PLANAR_MODE: number;
  27771. /** Cubic coordinates mode */
  27772. static readonly TEXTURE_CUBIC_MODE: number;
  27773. /** Projection coordinates mode */
  27774. static readonly TEXTURE_PROJECTION_MODE: number;
  27775. /** Skybox coordinates mode */
  27776. static readonly TEXTURE_SKYBOX_MODE: number;
  27777. /** Inverse Cubic coordinates mode */
  27778. static readonly TEXTURE_INVCUBIC_MODE: number;
  27779. /** Equirectangular coordinates mode */
  27780. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27781. /** Equirectangular Fixed coordinates mode */
  27782. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27783. /** Equirectangular Fixed Mirrored coordinates mode */
  27784. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27785. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27786. static readonly SCALEMODE_FLOOR: number;
  27787. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27788. static readonly SCALEMODE_NEAREST: number;
  27789. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27790. static readonly SCALEMODE_CEILING: number;
  27791. /**
  27792. * Returns the current npm package of the sdk
  27793. */
  27794. static readonly NpmPackage: string;
  27795. /**
  27796. * Returns the current version of the framework
  27797. */
  27798. static readonly Version: string;
  27799. /**
  27800. * Returns a string describing the current engine
  27801. */
  27802. readonly description: string;
  27803. /**
  27804. * Gets or sets the epsilon value used by collision engine
  27805. */
  27806. static CollisionsEpsilon: number;
  27807. /**
  27808. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27809. */
  27810. static ShadersRepository: string;
  27811. /**
  27812. * Method called to create the default loading screen.
  27813. * This can be overriden in your own app.
  27814. * @param canvas The rendering canvas element
  27815. * @returns The loading screen
  27816. */
  27817. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27818. /**
  27819. * Method called to create the default rescale post process on each engine.
  27820. */
  27821. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27822. /**
  27823. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27824. */
  27825. forcePOTTextures: boolean;
  27826. /**
  27827. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27828. */
  27829. isFullscreen: boolean;
  27830. /**
  27831. * Gets a boolean indicating if the pointer is currently locked
  27832. */
  27833. isPointerLock: boolean;
  27834. /**
  27835. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27836. */
  27837. cullBackFaces: boolean;
  27838. /**
  27839. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27840. */
  27841. renderEvenInBackground: boolean;
  27842. /**
  27843. * Gets or sets a boolean indicating that cache can be kept between frames
  27844. */
  27845. preventCacheWipeBetweenFrames: boolean;
  27846. /**
  27847. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27848. **/
  27849. enableOfflineSupport: boolean;
  27850. /**
  27851. * 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)
  27852. **/
  27853. disableManifestCheck: boolean;
  27854. /**
  27855. * Gets the list of created scenes
  27856. */
  27857. scenes: Scene[];
  27858. /**
  27859. * Event raised when a new scene is created
  27860. */
  27861. onNewSceneAddedObservable: Observable<Scene>;
  27862. /**
  27863. * Gets the list of created postprocesses
  27864. */
  27865. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27866. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27867. validateShaderPrograms: boolean;
  27868. /**
  27869. * Observable event triggered each time the rendering canvas is resized
  27870. */
  27871. onResizeObservable: Observable<Engine>;
  27872. /**
  27873. * Observable event triggered each time the canvas loses focus
  27874. */
  27875. onCanvasBlurObservable: Observable<Engine>;
  27876. /**
  27877. * Observable event triggered each time the canvas gains focus
  27878. */
  27879. onCanvasFocusObservable: Observable<Engine>;
  27880. /**
  27881. * Observable event triggered each time the canvas receives pointerout event
  27882. */
  27883. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27884. /**
  27885. * Observable event triggered before each texture is initialized
  27886. */
  27887. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27888. private _vrDisplay;
  27889. private _vrSupported;
  27890. private _oldSize;
  27891. private _oldHardwareScaleFactor;
  27892. private _vrExclusivePointerMode;
  27893. private _webVRInitPromise;
  27894. /**
  27895. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27896. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27897. */
  27898. readonly isInVRExclusivePointerMode: boolean;
  27899. /**
  27900. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27901. */
  27902. disableUniformBuffers: boolean;
  27903. /** @hidden */
  27904. _uniformBuffers: UniformBuffer[];
  27905. /**
  27906. * Gets a boolean indicating that the engine supports uniform buffers
  27907. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27908. */
  27909. readonly supportsUniformBuffers: boolean;
  27910. /**
  27911. * Observable raised when the engine begins a new frame
  27912. */
  27913. onBeginFrameObservable: Observable<Engine>;
  27914. /**
  27915. * If set, will be used to request the next animation frame for the render loop
  27916. */
  27917. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27918. /**
  27919. * Observable raised when the engine ends the current frame
  27920. */
  27921. onEndFrameObservable: Observable<Engine>;
  27922. /**
  27923. * Observable raised when the engine is about to compile a shader
  27924. */
  27925. onBeforeShaderCompilationObservable: Observable<Engine>;
  27926. /**
  27927. * Observable raised when the engine has jsut compiled a shader
  27928. */
  27929. onAfterShaderCompilationObservable: Observable<Engine>;
  27930. /** @hidden */
  27931. _gl: WebGLRenderingContext;
  27932. private _renderingCanvas;
  27933. private _windowIsBackground;
  27934. private _webGLVersion;
  27935. protected _highPrecisionShadersAllowed: boolean;
  27936. /** @hidden */
  27937. readonly _shouldUseHighPrecisionShader: boolean;
  27938. /**
  27939. * Gets a boolean indicating that only power of 2 textures are supported
  27940. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27941. */
  27942. readonly needPOTTextures: boolean;
  27943. /** @hidden */
  27944. _badOS: boolean;
  27945. /** @hidden */
  27946. _badDesktopOS: boolean;
  27947. /**
  27948. * Gets the audio engine
  27949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27950. * @ignorenaming
  27951. */
  27952. static audioEngine: IAudioEngine;
  27953. /**
  27954. * Default AudioEngine factory responsible of creating the Audio Engine.
  27955. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27956. */
  27957. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27958. /**
  27959. * Default offline support factory responsible of creating a tool used to store data locally.
  27960. * By default, this will create a Database object if the workload has been embedded.
  27961. */
  27962. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27963. private _onFocus;
  27964. private _onBlur;
  27965. private _onCanvasPointerOut;
  27966. private _onCanvasBlur;
  27967. private _onCanvasFocus;
  27968. private _onFullscreenChange;
  27969. private _onPointerLockChange;
  27970. private _onVRDisplayPointerRestricted;
  27971. private _onVRDisplayPointerUnrestricted;
  27972. private _onVrDisplayConnect;
  27973. private _onVrDisplayDisconnect;
  27974. private _onVrDisplayPresentChange;
  27975. /**
  27976. * Observable signaled when VR display mode changes
  27977. */
  27978. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27979. /**
  27980. * Observable signaled when VR request present is complete
  27981. */
  27982. onVRRequestPresentComplete: Observable<boolean>;
  27983. /**
  27984. * Observable signaled when VR request present starts
  27985. */
  27986. onVRRequestPresentStart: Observable<Engine>;
  27987. private _hardwareScalingLevel;
  27988. /** @hidden */
  27989. protected _caps: EngineCapabilities;
  27990. private _pointerLockRequested;
  27991. private _isStencilEnable;
  27992. private _colorWrite;
  27993. private _loadingScreen;
  27994. /** @hidden */
  27995. _drawCalls: PerfCounter;
  27996. private _glVersion;
  27997. private _glRenderer;
  27998. private _glVendor;
  27999. private _videoTextureSupported;
  28000. private _renderingQueueLaunched;
  28001. private _activeRenderLoops;
  28002. private _deterministicLockstep;
  28003. private _lockstepMaxSteps;
  28004. /**
  28005. * Observable signaled when a context lost event is raised
  28006. */
  28007. onContextLostObservable: Observable<Engine>;
  28008. /**
  28009. * Observable signaled when a context restored event is raised
  28010. */
  28011. onContextRestoredObservable: Observable<Engine>;
  28012. private _onContextLost;
  28013. private _onContextRestored;
  28014. private _contextWasLost;
  28015. private _doNotHandleContextLost;
  28016. /**
  28017. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28018. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28019. */
  28020. doNotHandleContextLost: boolean;
  28021. private _performanceMonitor;
  28022. private _fps;
  28023. private _deltaTime;
  28024. /**
  28025. * Turn this value on if you want to pause FPS computation when in background
  28026. */
  28027. disablePerformanceMonitorInBackground: boolean;
  28028. /**
  28029. * Gets the performance monitor attached to this engine
  28030. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28031. */
  28032. readonly performanceMonitor: PerformanceMonitor;
  28033. /**
  28034. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28035. */
  28036. disableVertexArrayObjects: boolean;
  28037. /** @hidden */
  28038. protected _depthCullingState: _DepthCullingState;
  28039. /** @hidden */
  28040. protected _stencilState: _StencilState;
  28041. /** @hidden */
  28042. protected _alphaState: _AlphaState;
  28043. /** @hidden */
  28044. protected _alphaMode: number;
  28045. protected _internalTexturesCache: InternalTexture[];
  28046. /** @hidden */
  28047. protected _activeChannel: number;
  28048. private _currentTextureChannel;
  28049. /** @hidden */
  28050. protected _boundTexturesCache: {
  28051. [key: string]: Nullable<InternalTexture>;
  28052. };
  28053. /** @hidden */
  28054. protected _currentEffect: Nullable<Effect>;
  28055. /** @hidden */
  28056. protected _currentProgram: Nullable<WebGLProgram>;
  28057. private _compiledEffects;
  28058. private _vertexAttribArraysEnabled;
  28059. /** @hidden */
  28060. protected _cachedViewport: Nullable<Viewport>;
  28061. private _cachedVertexArrayObject;
  28062. /** @hidden */
  28063. protected _cachedVertexBuffers: any;
  28064. /** @hidden */
  28065. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28066. /** @hidden */
  28067. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28068. /** @hidden */
  28069. protected _currentRenderTarget: Nullable<InternalTexture>;
  28070. private _uintIndicesCurrentlySet;
  28071. private _currentBoundBuffer;
  28072. /** @hidden */
  28073. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28074. private _currentBufferPointers;
  28075. private _currentInstanceLocations;
  28076. private _currentInstanceBuffers;
  28077. private _textureUnits;
  28078. private _workingCanvas;
  28079. private _workingContext;
  28080. private _rescalePostProcess;
  28081. private _dummyFramebuffer;
  28082. private _externalData;
  28083. private _bindedRenderFunction;
  28084. private _vaoRecordInProgress;
  28085. private _mustWipeVertexAttributes;
  28086. private _emptyTexture;
  28087. private _emptyCubeTexture;
  28088. private _emptyTexture3D;
  28089. /** @hidden */
  28090. _frameHandler: number;
  28091. private _nextFreeTextureSlots;
  28092. private _maxSimultaneousTextures;
  28093. private _activeRequests;
  28094. private _texturesSupported;
  28095. private _textureFormatInUse;
  28096. /**
  28097. * Gets the list of texture formats supported
  28098. */
  28099. readonly texturesSupported: Array<string>;
  28100. /**
  28101. * Gets the list of texture formats in use
  28102. */
  28103. readonly textureFormatInUse: Nullable<string>;
  28104. /**
  28105. * Gets the current viewport
  28106. */
  28107. readonly currentViewport: Nullable<Viewport>;
  28108. /**
  28109. * Gets the default empty texture
  28110. */
  28111. readonly emptyTexture: InternalTexture;
  28112. /**
  28113. * Gets the default empty 3D texture
  28114. */
  28115. readonly emptyTexture3D: InternalTexture;
  28116. /**
  28117. * Gets the default empty cube texture
  28118. */
  28119. readonly emptyCubeTexture: InternalTexture;
  28120. /**
  28121. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28122. */
  28123. readonly premultipliedAlpha: boolean;
  28124. /**
  28125. * Creates a new engine
  28126. * @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
  28127. * @param antialias defines enable antialiasing (default: false)
  28128. * @param options defines further options to be sent to the getContext() function
  28129. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28130. */
  28131. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28132. private _disableTouchAction;
  28133. private _rebuildInternalTextures;
  28134. private _rebuildEffects;
  28135. /**
  28136. * Gets a boolean indicating if all created effects are ready
  28137. * @returns true if all effects are ready
  28138. */
  28139. areAllEffectsReady(): boolean;
  28140. private _rebuildBuffers;
  28141. private _initGLContext;
  28142. /**
  28143. * Gets version of the current webGL context
  28144. */
  28145. readonly webGLVersion: number;
  28146. /**
  28147. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28148. */
  28149. readonly isStencilEnable: boolean;
  28150. private _prepareWorkingCanvas;
  28151. /**
  28152. * Reset the texture cache to empty state
  28153. */
  28154. resetTextureCache(): void;
  28155. /**
  28156. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28157. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28158. * @returns true if engine is in deterministic lock step mode
  28159. */
  28160. isDeterministicLockStep(): boolean;
  28161. /**
  28162. * Gets the max steps when engine is running in deterministic lock step
  28163. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28164. * @returns the max steps
  28165. */
  28166. getLockstepMaxSteps(): number;
  28167. /**
  28168. * Gets an object containing information about the current webGL context
  28169. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28170. */
  28171. getGlInfo(): {
  28172. vendor: string;
  28173. renderer: string;
  28174. version: string;
  28175. };
  28176. /**
  28177. * Gets current aspect ratio
  28178. * @param camera defines the camera to use to get the aspect ratio
  28179. * @param useScreen defines if screen size must be used (or the current render target if any)
  28180. * @returns a number defining the aspect ratio
  28181. */
  28182. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28183. /**
  28184. * Gets current screen aspect ratio
  28185. * @returns a number defining the aspect ratio
  28186. */
  28187. getScreenAspectRatio(): number;
  28188. /**
  28189. * Gets the current render width
  28190. * @param useScreen defines if screen size must be used (or the current render target if any)
  28191. * @returns a number defining the current render width
  28192. */
  28193. getRenderWidth(useScreen?: boolean): number;
  28194. /**
  28195. * Gets the current render height
  28196. * @param useScreen defines if screen size must be used (or the current render target if any)
  28197. * @returns a number defining the current render height
  28198. */
  28199. getRenderHeight(useScreen?: boolean): number;
  28200. /**
  28201. * Gets the HTML canvas attached with the current webGL context
  28202. * @returns a HTML canvas
  28203. */
  28204. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28205. /**
  28206. * Gets the client rect of the HTML canvas attached with the current webGL context
  28207. * @returns a client rectanglee
  28208. */
  28209. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28210. /**
  28211. * Defines the hardware scaling level.
  28212. * By default the hardware scaling level is computed from the window device ratio.
  28213. * 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.
  28214. * @param level defines the level to use
  28215. */
  28216. setHardwareScalingLevel(level: number): void;
  28217. /**
  28218. * Gets the current hardware scaling level.
  28219. * By default the hardware scaling level is computed from the window device ratio.
  28220. * 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.
  28221. * @returns a number indicating the current hardware scaling level
  28222. */
  28223. getHardwareScalingLevel(): number;
  28224. /**
  28225. * Gets the list of loaded textures
  28226. * @returns an array containing all loaded textures
  28227. */
  28228. getLoadedTexturesCache(): InternalTexture[];
  28229. /**
  28230. * Gets the object containing all engine capabilities
  28231. * @returns the EngineCapabilities object
  28232. */
  28233. getCaps(): EngineCapabilities;
  28234. /**
  28235. * Gets the current depth function
  28236. * @returns a number defining the depth function
  28237. */
  28238. getDepthFunction(): Nullable<number>;
  28239. /**
  28240. * Sets the current depth function
  28241. * @param depthFunc defines the function to use
  28242. */
  28243. setDepthFunction(depthFunc: number): void;
  28244. /**
  28245. * Sets the current depth function to GREATER
  28246. */
  28247. setDepthFunctionToGreater(): void;
  28248. /**
  28249. * Sets the current depth function to GEQUAL
  28250. */
  28251. setDepthFunctionToGreaterOrEqual(): void;
  28252. /**
  28253. * Sets the current depth function to LESS
  28254. */
  28255. setDepthFunctionToLess(): void;
  28256. private _cachedStencilBuffer;
  28257. private _cachedStencilFunction;
  28258. private _cachedStencilMask;
  28259. private _cachedStencilOperationPass;
  28260. private _cachedStencilOperationFail;
  28261. private _cachedStencilOperationDepthFail;
  28262. private _cachedStencilReference;
  28263. /**
  28264. * Caches the the state of the stencil buffer
  28265. */
  28266. cacheStencilState(): void;
  28267. /**
  28268. * Restores the state of the stencil buffer
  28269. */
  28270. restoreStencilState(): void;
  28271. /**
  28272. * Sets the current depth function to LEQUAL
  28273. */
  28274. setDepthFunctionToLessOrEqual(): void;
  28275. /**
  28276. * Gets a boolean indicating if stencil buffer is enabled
  28277. * @returns the current stencil buffer state
  28278. */
  28279. getStencilBuffer(): boolean;
  28280. /**
  28281. * Enable or disable the stencil buffer
  28282. * @param enable defines if the stencil buffer must be enabled or disabled
  28283. */
  28284. setStencilBuffer(enable: boolean): void;
  28285. /**
  28286. * Gets the current stencil mask
  28287. * @returns a number defining the new stencil mask to use
  28288. */
  28289. getStencilMask(): number;
  28290. /**
  28291. * Sets the current stencil mask
  28292. * @param mask defines the new stencil mask to use
  28293. */
  28294. setStencilMask(mask: number): void;
  28295. /**
  28296. * Gets the current stencil function
  28297. * @returns a number defining the stencil function to use
  28298. */
  28299. getStencilFunction(): number;
  28300. /**
  28301. * Gets the current stencil reference value
  28302. * @returns a number defining the stencil reference value to use
  28303. */
  28304. getStencilFunctionReference(): number;
  28305. /**
  28306. * Gets the current stencil mask
  28307. * @returns a number defining the stencil mask to use
  28308. */
  28309. getStencilFunctionMask(): number;
  28310. /**
  28311. * Sets the current stencil function
  28312. * @param stencilFunc defines the new stencil function to use
  28313. */
  28314. setStencilFunction(stencilFunc: number): void;
  28315. /**
  28316. * Sets the current stencil reference
  28317. * @param reference defines the new stencil reference to use
  28318. */
  28319. setStencilFunctionReference(reference: number): void;
  28320. /**
  28321. * Sets the current stencil mask
  28322. * @param mask defines the new stencil mask to use
  28323. */
  28324. setStencilFunctionMask(mask: number): void;
  28325. /**
  28326. * Gets the current stencil operation when stencil fails
  28327. * @returns a number defining stencil operation to use when stencil fails
  28328. */
  28329. getStencilOperationFail(): number;
  28330. /**
  28331. * Gets the current stencil operation when depth fails
  28332. * @returns a number defining stencil operation to use when depth fails
  28333. */
  28334. getStencilOperationDepthFail(): number;
  28335. /**
  28336. * Gets the current stencil operation when stencil passes
  28337. * @returns a number defining stencil operation to use when stencil passes
  28338. */
  28339. getStencilOperationPass(): number;
  28340. /**
  28341. * Sets the stencil operation to use when stencil fails
  28342. * @param operation defines the stencil operation to use when stencil fails
  28343. */
  28344. setStencilOperationFail(operation: number): void;
  28345. /**
  28346. * Sets the stencil operation to use when depth fails
  28347. * @param operation defines the stencil operation to use when depth fails
  28348. */
  28349. setStencilOperationDepthFail(operation: number): void;
  28350. /**
  28351. * Sets the stencil operation to use when stencil passes
  28352. * @param operation defines the stencil operation to use when stencil passes
  28353. */
  28354. setStencilOperationPass(operation: number): void;
  28355. /**
  28356. * Sets a boolean indicating if the dithering state is enabled or disabled
  28357. * @param value defines the dithering state
  28358. */
  28359. setDitheringState(value: boolean): void;
  28360. /**
  28361. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28362. * @param value defines the rasterizer state
  28363. */
  28364. setRasterizerState(value: boolean): void;
  28365. /**
  28366. * stop executing a render loop function and remove it from the execution array
  28367. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28368. */
  28369. stopRenderLoop(renderFunction?: () => void): void;
  28370. /** @hidden */
  28371. _renderLoop(): void;
  28372. /**
  28373. * Register and execute a render loop. The engine can have more than one render function
  28374. * @param renderFunction defines the function to continuously execute
  28375. */
  28376. runRenderLoop(renderFunction: () => void): void;
  28377. /**
  28378. * Toggle full screen mode
  28379. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28380. */
  28381. switchFullscreen(requestPointerLock: boolean): void;
  28382. /**
  28383. * Enters full screen mode
  28384. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28385. */
  28386. enterFullscreen(requestPointerLock: boolean): void;
  28387. /**
  28388. * Exits full screen mode
  28389. */
  28390. exitFullscreen(): void;
  28391. /**
  28392. * Clear the current render buffer or the current render target (if any is set up)
  28393. * @param color defines the color to use
  28394. * @param backBuffer defines if the back buffer must be cleared
  28395. * @param depth defines if the depth buffer must be cleared
  28396. * @param stencil defines if the stencil buffer must be cleared
  28397. */
  28398. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28399. /**
  28400. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28401. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28402. * @param y defines the y-coordinate of the corner of the clear rectangle
  28403. * @param width defines the width of the clear rectangle
  28404. * @param height defines the height of the clear rectangle
  28405. * @param clearColor defines the clear color
  28406. */
  28407. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28408. /**
  28409. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28410. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28411. * @param y defines the y-coordinate of the corner of the clear rectangle
  28412. * @param width defines the width of the clear rectangle
  28413. * @param height defines the height of the clear rectangle
  28414. */
  28415. enableScissor(x: number, y: number, width: number, height: number): void;
  28416. /**
  28417. * Disable previously set scissor test rectangle
  28418. */
  28419. disableScissor(): void;
  28420. private _viewportCached;
  28421. /** @hidden */
  28422. _viewport(x: number, y: number, width: number, height: number): void;
  28423. /**
  28424. * Set the WebGL's viewport
  28425. * @param viewport defines the viewport element to be used
  28426. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28427. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28428. */
  28429. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28430. /**
  28431. * Directly set the WebGL Viewport
  28432. * @param x defines the x coordinate of the viewport (in screen space)
  28433. * @param y defines the y coordinate of the viewport (in screen space)
  28434. * @param width defines the width of the viewport (in screen space)
  28435. * @param height defines the height of the viewport (in screen space)
  28436. * @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
  28437. */
  28438. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28439. /**
  28440. * Begin a new frame
  28441. */
  28442. beginFrame(): void;
  28443. /**
  28444. * Enf the current frame
  28445. */
  28446. endFrame(): void;
  28447. /**
  28448. * Resize the view according to the canvas' size
  28449. */
  28450. resize(): void;
  28451. /**
  28452. * Force a specific size of the canvas
  28453. * @param width defines the new canvas' width
  28454. * @param height defines the new canvas' height
  28455. */
  28456. setSize(width: number, height: number): void;
  28457. /**
  28458. * Gets a boolean indicating if a webVR device was detected
  28459. * @returns true if a webVR device was detected
  28460. */
  28461. isVRDevicePresent(): boolean;
  28462. /**
  28463. * Gets the current webVR device
  28464. * @returns the current webVR device (or null)
  28465. */
  28466. getVRDevice(): any;
  28467. /**
  28468. * Initializes a webVR display and starts listening to display change events
  28469. * The onVRDisplayChangedObservable will be notified upon these changes
  28470. * @returns The onVRDisplayChangedObservable
  28471. */
  28472. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28473. /**
  28474. * Initializes a webVR display and starts listening to display change events
  28475. * The onVRDisplayChangedObservable will be notified upon these changes
  28476. * @returns A promise containing a VRDisplay and if vr is supported
  28477. */
  28478. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28479. /**
  28480. * Call this function to switch to webVR mode
  28481. * Will do nothing if webVR is not supported or if there is no webVR device
  28482. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28483. */
  28484. enableVR(): void;
  28485. /**
  28486. * Call this function to leave webVR mode
  28487. * Will do nothing if webVR is not supported or if there is no webVR device
  28488. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28489. */
  28490. disableVR(): void;
  28491. private _onVRFullScreenTriggered;
  28492. private _getVRDisplaysAsync;
  28493. /**
  28494. * Binds the frame buffer to the specified texture.
  28495. * @param texture The texture to render to or null for the default canvas
  28496. * @param faceIndex The face of the texture to render to in case of cube texture
  28497. * @param requiredWidth The width of the target to render to
  28498. * @param requiredHeight The height of the target to render to
  28499. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28500. * @param depthStencilTexture The depth stencil texture to use to render
  28501. * @param lodLevel defines le lod level to bind to the frame buffer
  28502. */
  28503. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28504. private bindUnboundFramebuffer;
  28505. /**
  28506. * Unbind the current render target texture from the webGL context
  28507. * @param texture defines the render target texture to unbind
  28508. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28509. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28510. */
  28511. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28512. /**
  28513. * Unbind a list of render target textures from the webGL context
  28514. * This is used only when drawBuffer extension or webGL2 are active
  28515. * @param textures defines the render target textures to unbind
  28516. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28517. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28518. */
  28519. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28520. /**
  28521. * Force the mipmap generation for the given render target texture
  28522. * @param texture defines the render target texture to use
  28523. */
  28524. generateMipMapsForCubemap(texture: InternalTexture): void;
  28525. /**
  28526. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28527. */
  28528. flushFramebuffer(): void;
  28529. /**
  28530. * Unbind the current render target and bind the default framebuffer
  28531. */
  28532. restoreDefaultFramebuffer(): void;
  28533. /**
  28534. * Create an uniform buffer
  28535. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28536. * @param elements defines the content of the uniform buffer
  28537. * @returns the webGL uniform buffer
  28538. */
  28539. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28540. /**
  28541. * Create a dynamic uniform buffer
  28542. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28543. * @param elements defines the content of the uniform buffer
  28544. * @returns the webGL uniform buffer
  28545. */
  28546. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28547. /**
  28548. * Update an existing uniform buffer
  28549. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28550. * @param uniformBuffer defines the target uniform buffer
  28551. * @param elements defines the content to update
  28552. * @param offset defines the offset in the uniform buffer where update should start
  28553. * @param count defines the size of the data to update
  28554. */
  28555. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28556. private _resetVertexBufferBinding;
  28557. /**
  28558. * Creates a vertex buffer
  28559. * @param data the data for the vertex buffer
  28560. * @returns the new WebGL static buffer
  28561. */
  28562. createVertexBuffer(data: DataArray): WebGLBuffer;
  28563. /**
  28564. * Creates a dynamic vertex buffer
  28565. * @param data the data for the dynamic vertex buffer
  28566. * @returns the new WebGL dynamic buffer
  28567. */
  28568. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28569. /**
  28570. * Update a dynamic index buffer
  28571. * @param indexBuffer defines the target index buffer
  28572. * @param indices defines the data to update
  28573. * @param offset defines the offset in the target index buffer where update should start
  28574. */
  28575. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28576. /**
  28577. * Updates a dynamic vertex buffer.
  28578. * @param vertexBuffer the vertex buffer to update
  28579. * @param data the data used to update the vertex buffer
  28580. * @param byteOffset the byte offset of the data
  28581. * @param byteLength the byte length of the data
  28582. */
  28583. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28584. private _resetIndexBufferBinding;
  28585. /**
  28586. * Creates a new index buffer
  28587. * @param indices defines the content of the index buffer
  28588. * @param updatable defines if the index buffer must be updatable
  28589. * @returns a new webGL buffer
  28590. */
  28591. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28592. /**
  28593. * Bind a webGL buffer to the webGL context
  28594. * @param buffer defines the buffer to bind
  28595. */
  28596. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28597. /**
  28598. * Bind an uniform buffer to the current webGL context
  28599. * @param buffer defines the buffer to bind
  28600. */
  28601. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28602. /**
  28603. * Bind a buffer to the current webGL context at a given location
  28604. * @param buffer defines the buffer to bind
  28605. * @param location defines the index where to bind the buffer
  28606. */
  28607. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28608. /**
  28609. * Bind a specific block at a given index in a specific shader program
  28610. * @param shaderProgram defines the shader program
  28611. * @param blockName defines the block name
  28612. * @param index defines the index where to bind the block
  28613. */
  28614. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28615. private bindIndexBuffer;
  28616. private bindBuffer;
  28617. /**
  28618. * update the bound buffer with the given data
  28619. * @param data defines the data to update
  28620. */
  28621. updateArrayBuffer(data: Float32Array): void;
  28622. private _vertexAttribPointer;
  28623. private _bindIndexBufferWithCache;
  28624. private _bindVertexBuffersAttributes;
  28625. /**
  28626. * Records a vertex array object
  28627. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28628. * @param vertexBuffers defines the list of vertex buffers to store
  28629. * @param indexBuffer defines the index buffer to store
  28630. * @param effect defines the effect to store
  28631. * @returns the new vertex array object
  28632. */
  28633. recordVertexArrayObject(vertexBuffers: {
  28634. [key: string]: VertexBuffer;
  28635. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28636. /**
  28637. * Bind a specific vertex array object
  28638. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28639. * @param vertexArrayObject defines the vertex array object to bind
  28640. * @param indexBuffer defines the index buffer to bind
  28641. */
  28642. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28643. /**
  28644. * Bind webGl buffers directly to the webGL context
  28645. * @param vertexBuffer defines the vertex buffer to bind
  28646. * @param indexBuffer defines the index buffer to bind
  28647. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28648. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28649. * @param effect defines the effect associated with the vertex buffer
  28650. */
  28651. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28652. private _unbindVertexArrayObject;
  28653. /**
  28654. * Bind a list of vertex buffers to the webGL context
  28655. * @param vertexBuffers defines the list of vertex buffers to bind
  28656. * @param indexBuffer defines the index buffer to bind
  28657. * @param effect defines the effect associated with the vertex buffers
  28658. */
  28659. bindBuffers(vertexBuffers: {
  28660. [key: string]: Nullable<VertexBuffer>;
  28661. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28662. /**
  28663. * Unbind all instance attributes
  28664. */
  28665. unbindInstanceAttributes(): void;
  28666. /**
  28667. * Release and free the memory of a vertex array object
  28668. * @param vao defines the vertex array object to delete
  28669. */
  28670. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28671. /** @hidden */
  28672. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28673. /**
  28674. * Creates a webGL buffer to use with instanciation
  28675. * @param capacity defines the size of the buffer
  28676. * @returns the webGL buffer
  28677. */
  28678. createInstancesBuffer(capacity: number): WebGLBuffer;
  28679. /**
  28680. * Delete a webGL buffer used with instanciation
  28681. * @param buffer defines the webGL buffer to delete
  28682. */
  28683. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28684. /**
  28685. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28686. * @param instancesBuffer defines the webGL buffer to update and bind
  28687. * @param data defines the data to store in the buffer
  28688. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28689. */
  28690. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28691. /**
  28692. * Apply all cached states (depth, culling, stencil and alpha)
  28693. */
  28694. applyStates(): void;
  28695. /**
  28696. * Send a draw order
  28697. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28698. * @param indexStart defines the starting index
  28699. * @param indexCount defines the number of index to draw
  28700. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28701. */
  28702. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28703. /**
  28704. * Draw a list of points
  28705. * @param verticesStart defines the index of first vertex to draw
  28706. * @param verticesCount defines the count of vertices to draw
  28707. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28708. */
  28709. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28710. /**
  28711. * Draw a list of unindexed primitives
  28712. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28713. * @param verticesStart defines the index of first vertex to draw
  28714. * @param verticesCount defines the count of vertices to draw
  28715. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28716. */
  28717. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28718. /**
  28719. * Draw a list of indexed primitives
  28720. * @param fillMode defines the primitive to use
  28721. * @param indexStart defines the starting index
  28722. * @param indexCount defines the number of index to draw
  28723. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28724. */
  28725. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28726. /**
  28727. * Draw a list of unindexed primitives
  28728. * @param fillMode defines the primitive to use
  28729. * @param verticesStart defines the index of first vertex to draw
  28730. * @param verticesCount defines the count of vertices to draw
  28731. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28732. */
  28733. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28734. private _drawMode;
  28735. /** @hidden */
  28736. _releaseEffect(effect: Effect): void;
  28737. /** @hidden */
  28738. _deleteProgram(program: WebGLProgram): void;
  28739. /**
  28740. * Create a new effect (used to store vertex/fragment shaders)
  28741. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28742. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28743. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28744. * @param samplers defines an array of string used to represent textures
  28745. * @param defines defines the string containing the defines to use to compile the shaders
  28746. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28747. * @param onCompiled defines a function to call when the effect creation is successful
  28748. * @param onError defines a function to call when the effect creation has failed
  28749. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28750. * @returns the new Effect
  28751. */
  28752. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  28753. private _compileShader;
  28754. private _compileRawShader;
  28755. /**
  28756. * Directly creates a webGL program
  28757. * @param vertexCode defines the vertex shader code to use
  28758. * @param fragmentCode defines the fragment shader code to use
  28759. * @param context defines the webGL context to use (if not set, the current one will be used)
  28760. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28761. * @returns the new webGL program
  28762. */
  28763. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28764. /**
  28765. * Creates a webGL program
  28766. * @param vertexCode defines the vertex shader code to use
  28767. * @param fragmentCode defines the fragment shader code to use
  28768. * @param defines defines the string containing the defines to use to compile the shaders
  28769. * @param context defines the webGL context to use (if not set, the current one will be used)
  28770. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28771. * @returns the new webGL program
  28772. */
  28773. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28774. private _createShaderProgram;
  28775. private _finalizeProgram;
  28776. /** @hidden */
  28777. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28778. /** @hidden */
  28779. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28780. /**
  28781. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28782. * @param shaderProgram defines the webGL program to use
  28783. * @param uniformsNames defines the list of uniform names
  28784. * @returns an array of webGL uniform locations
  28785. */
  28786. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28787. /**
  28788. * Gets the lsit of active attributes for a given webGL program
  28789. * @param shaderProgram defines the webGL program to use
  28790. * @param attributesNames defines the list of attribute names to get
  28791. * @returns an array of indices indicating the offset of each attribute
  28792. */
  28793. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28794. /**
  28795. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28796. * @param effect defines the effect to activate
  28797. */
  28798. enableEffect(effect: Nullable<Effect>): void;
  28799. /**
  28800. * Set the value of an uniform to an array of int32
  28801. * @param uniform defines the webGL uniform location where to store the value
  28802. * @param array defines the array of int32 to store
  28803. */
  28804. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28805. /**
  28806. * Set the value of an uniform to an array of int32 (stored as vec2)
  28807. * @param uniform defines the webGL uniform location where to store the value
  28808. * @param array defines the array of int32 to store
  28809. */
  28810. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28811. /**
  28812. * Set the value of an uniform to an array of int32 (stored as vec3)
  28813. * @param uniform defines the webGL uniform location where to store the value
  28814. * @param array defines the array of int32 to store
  28815. */
  28816. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28817. /**
  28818. * Set the value of an uniform to an array of int32 (stored as vec4)
  28819. * @param uniform defines the webGL uniform location where to store the value
  28820. * @param array defines the array of int32 to store
  28821. */
  28822. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28823. /**
  28824. * Set the value of an uniform to an array of float32
  28825. * @param uniform defines the webGL uniform location where to store the value
  28826. * @param array defines the array of float32 to store
  28827. */
  28828. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28829. /**
  28830. * Set the value of an uniform to an array of float32 (stored as vec2)
  28831. * @param uniform defines the webGL uniform location where to store the value
  28832. * @param array defines the array of float32 to store
  28833. */
  28834. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28835. /**
  28836. * Set the value of an uniform to an array of float32 (stored as vec3)
  28837. * @param uniform defines the webGL uniform location where to store the value
  28838. * @param array defines the array of float32 to store
  28839. */
  28840. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28841. /**
  28842. * Set the value of an uniform to an array of float32 (stored as vec4)
  28843. * @param uniform defines the webGL uniform location where to store the value
  28844. * @param array defines the array of float32 to store
  28845. */
  28846. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28847. /**
  28848. * Set the value of an uniform to an array of number
  28849. * @param uniform defines the webGL uniform location where to store the value
  28850. * @param array defines the array of number to store
  28851. */
  28852. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28853. /**
  28854. * Set the value of an uniform to an array of number (stored as vec2)
  28855. * @param uniform defines the webGL uniform location where to store the value
  28856. * @param array defines the array of number to store
  28857. */
  28858. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28859. /**
  28860. * Set the value of an uniform to an array of number (stored as vec3)
  28861. * @param uniform defines the webGL uniform location where to store the value
  28862. * @param array defines the array of number to store
  28863. */
  28864. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28865. /**
  28866. * Set the value of an uniform to an array of number (stored as vec4)
  28867. * @param uniform defines the webGL uniform location where to store the value
  28868. * @param array defines the array of number to store
  28869. */
  28870. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28871. /**
  28872. * Set the value of an uniform to an array of float32 (stored as matrices)
  28873. * @param uniform defines the webGL uniform location where to store the value
  28874. * @param matrices defines the array of float32 to store
  28875. */
  28876. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28877. /**
  28878. * Set the value of an uniform to a matrix
  28879. * @param uniform defines the webGL uniform location where to store the value
  28880. * @param matrix defines the matrix to store
  28881. */
  28882. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28883. /**
  28884. * Set the value of an uniform to a matrix (3x3)
  28885. * @param uniform defines the webGL uniform location where to store the value
  28886. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28887. */
  28888. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28889. /**
  28890. * Set the value of an uniform to a matrix (2x2)
  28891. * @param uniform defines the webGL uniform location where to store the value
  28892. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28893. */
  28894. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28895. /**
  28896. * Set the value of an uniform to a number (int)
  28897. * @param uniform defines the webGL uniform location where to store the value
  28898. * @param value defines the int number to store
  28899. */
  28900. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28901. /**
  28902. * Set the value of an uniform to a number (float)
  28903. * @param uniform defines the webGL uniform location where to store the value
  28904. * @param value defines the float number to store
  28905. */
  28906. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28907. /**
  28908. * Set the value of an uniform to a vec2
  28909. * @param uniform defines the webGL uniform location where to store the value
  28910. * @param x defines the 1st component of the value
  28911. * @param y defines the 2nd component of the value
  28912. */
  28913. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28914. /**
  28915. * Set the value of an uniform to a vec3
  28916. * @param uniform defines the webGL uniform location where to store the value
  28917. * @param x defines the 1st component of the value
  28918. * @param y defines the 2nd component of the value
  28919. * @param z defines the 3rd component of the value
  28920. */
  28921. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28922. /**
  28923. * Set the value of an uniform to a boolean
  28924. * @param uniform defines the webGL uniform location where to store the value
  28925. * @param bool defines the boolean to store
  28926. */
  28927. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28928. /**
  28929. * Set the value of an uniform to a vec4
  28930. * @param uniform defines the webGL uniform location where to store the value
  28931. * @param x defines the 1st component of the value
  28932. * @param y defines the 2nd component of the value
  28933. * @param z defines the 3rd component of the value
  28934. * @param w defines the 4th component of the value
  28935. */
  28936. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28937. /**
  28938. * Set the value of an uniform to a Color3
  28939. * @param uniform defines the webGL uniform location where to store the value
  28940. * @param color3 defines the color to store
  28941. */
  28942. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28943. /**
  28944. * Set the value of an uniform to a Color3 and an alpha value
  28945. * @param uniform defines the webGL uniform location where to store the value
  28946. * @param color3 defines the color to store
  28947. * @param alpha defines the alpha component to store
  28948. */
  28949. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28950. /**
  28951. * Sets a Color4 on a uniform variable
  28952. * @param uniform defines the uniform location
  28953. * @param color4 defines the value to be set
  28954. */
  28955. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28956. /**
  28957. * Set various states to the webGL context
  28958. * @param culling defines backface culling state
  28959. * @param zOffset defines the value to apply to zOffset (0 by default)
  28960. * @param force defines if states must be applied even if cache is up to date
  28961. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28962. */
  28963. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28964. /**
  28965. * Set the z offset to apply to current rendering
  28966. * @param value defines the offset to apply
  28967. */
  28968. setZOffset(value: number): void;
  28969. /**
  28970. * Gets the current value of the zOffset
  28971. * @returns the current zOffset state
  28972. */
  28973. getZOffset(): number;
  28974. /**
  28975. * Enable or disable depth buffering
  28976. * @param enable defines the state to set
  28977. */
  28978. setDepthBuffer(enable: boolean): void;
  28979. /**
  28980. * Gets a boolean indicating if depth writing is enabled
  28981. * @returns the current depth writing state
  28982. */
  28983. getDepthWrite(): boolean;
  28984. /**
  28985. * Enable or disable depth writing
  28986. * @param enable defines the state to set
  28987. */
  28988. setDepthWrite(enable: boolean): void;
  28989. /**
  28990. * Enable or disable color writing
  28991. * @param enable defines the state to set
  28992. */
  28993. setColorWrite(enable: boolean): void;
  28994. /**
  28995. * Gets a boolean indicating if color writing is enabled
  28996. * @returns the current color writing state
  28997. */
  28998. getColorWrite(): boolean;
  28999. /**
  29000. * Sets alpha constants used by some alpha blending modes
  29001. * @param r defines the red component
  29002. * @param g defines the green component
  29003. * @param b defines the blue component
  29004. * @param a defines the alpha component
  29005. */
  29006. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29007. /**
  29008. * Sets the current alpha mode
  29009. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29010. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29011. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29012. */
  29013. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29014. /**
  29015. * Gets the current alpha mode
  29016. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29017. * @returns the current alpha mode
  29018. */
  29019. getAlphaMode(): number;
  29020. /**
  29021. * Clears the list of texture accessible through engine.
  29022. * This can help preventing texture load conflict due to name collision.
  29023. */
  29024. clearInternalTexturesCache(): void;
  29025. /**
  29026. * Force the entire cache to be cleared
  29027. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29028. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29029. */
  29030. wipeCaches(bruteForce?: boolean): void;
  29031. /**
  29032. * Set the compressed texture format to use, based on the formats you have, and the formats
  29033. * supported by the hardware / browser.
  29034. *
  29035. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29036. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29037. * to API arguments needed to compressed textures. This puts the burden on the container
  29038. * generator to house the arcane code for determining these for current & future formats.
  29039. *
  29040. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29041. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29042. *
  29043. * Note: The result of this call is not taken into account when a texture is base64.
  29044. *
  29045. * @param formatsAvailable defines the list of those format families you have created
  29046. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29047. *
  29048. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29049. * @returns The extension selected.
  29050. */
  29051. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29052. private _getSamplingParameters;
  29053. private _partialLoadImg;
  29054. private _cascadeLoadImgs;
  29055. /** @hidden */
  29056. _createTexture(): WebGLTexture;
  29057. /**
  29058. * Usually called from Texture.ts.
  29059. * Passed information to create a WebGLTexture
  29060. * @param urlArg defines a value which contains one of the following:
  29061. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29062. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29063. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29064. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29065. * @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)
  29066. * @param scene needed for loading to the correct scene
  29067. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29068. * @param onLoad optional callback to be called upon successful completion
  29069. * @param onError optional callback to be called upon failure
  29070. * @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
  29071. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29072. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29073. * @param forcedExtension defines the extension to use to pick the right loader
  29074. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29075. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29076. */
  29077. 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;
  29078. private _rescaleTexture;
  29079. /**
  29080. * Update a raw texture
  29081. * @param texture defines the texture to update
  29082. * @param data defines the data to store in the texture
  29083. * @param format defines the format of the data
  29084. * @param invertY defines if data must be stored with Y axis inverted
  29085. * @param compression defines the compression used (null by default)
  29086. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29087. */
  29088. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  29089. /**
  29090. * Creates a raw texture
  29091. * @param data defines the data to store in the texture
  29092. * @param width defines the width of the texture
  29093. * @param height defines the height of the texture
  29094. * @param format defines the format of the data
  29095. * @param generateMipMaps defines if the engine should generate the mip levels
  29096. * @param invertY defines if data must be stored with Y axis inverted
  29097. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29098. * @param compression defines the compression used (null by default)
  29099. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29100. * @returns the raw texture inside an InternalTexture
  29101. */
  29102. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29103. private _unpackFlipYCached;
  29104. /**
  29105. * In case you are sharing the context with other applications, it might
  29106. * be interested to not cache the unpack flip y state to ensure a consistent
  29107. * value would be set.
  29108. */
  29109. enableUnpackFlipYCached: boolean;
  29110. /** @hidden */
  29111. _unpackFlipY(value: boolean): void;
  29112. /** @hidden */
  29113. _getUnpackAlignement(): number;
  29114. /**
  29115. * Creates a dynamic texture
  29116. * @param width defines the width of the texture
  29117. * @param height defines the height of the texture
  29118. * @param generateMipMaps defines if the engine should generate the mip levels
  29119. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29120. * @returns the dynamic texture inside an InternalTexture
  29121. */
  29122. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29123. /**
  29124. * Update the sampling mode of a given texture
  29125. * @param samplingMode defines the required sampling mode
  29126. * @param texture defines the texture to update
  29127. */
  29128. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29129. /**
  29130. * Update the content of a dynamic texture
  29131. * @param texture defines the texture to update
  29132. * @param canvas defines the canvas containing the source
  29133. * @param invertY defines if data must be stored with Y axis inverted
  29134. * @param premulAlpha defines if alpha is stored as premultiplied
  29135. * @param format defines the format of the data
  29136. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29137. */
  29138. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29139. /**
  29140. * Update a video texture
  29141. * @param texture defines the texture to update
  29142. * @param video defines the video element to use
  29143. * @param invertY defines if data must be stored with Y axis inverted
  29144. */
  29145. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29146. /**
  29147. * Updates a depth texture Comparison Mode and Function.
  29148. * If the comparison Function is equal to 0, the mode will be set to none.
  29149. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29150. * @param texture The texture to set the comparison function for
  29151. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29152. */
  29153. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29154. private _setupDepthStencilTexture;
  29155. /**
  29156. * Creates a depth stencil texture.
  29157. * This is only available in WebGL 2 or with the depth texture extension available.
  29158. * @param size The size of face edge in the texture.
  29159. * @param options The options defining the texture.
  29160. * @returns The texture
  29161. */
  29162. createDepthStencilTexture(size: number | {
  29163. width: number;
  29164. height: number;
  29165. }, options: DepthTextureCreationOptions): InternalTexture;
  29166. /**
  29167. * Creates a depth stencil texture.
  29168. * This is only available in WebGL 2 or with the depth texture extension available.
  29169. * @param size The size of face edge in the texture.
  29170. * @param options The options defining the texture.
  29171. * @returns The texture
  29172. */
  29173. private _createDepthStencilTexture;
  29174. /**
  29175. * Creates a depth stencil cube texture.
  29176. * This is only available in WebGL 2.
  29177. * @param size The size of face edge in the cube texture.
  29178. * @param options The options defining the cube texture.
  29179. * @returns The cube texture
  29180. */
  29181. private _createDepthStencilCubeTexture;
  29182. /**
  29183. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29184. * @param renderTarget The render target to set the frame buffer for
  29185. */
  29186. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29187. /**
  29188. * Creates a new render target texture
  29189. * @param size defines the size of the texture
  29190. * @param options defines the options used to create the texture
  29191. * @returns a new render target texture stored in an InternalTexture
  29192. */
  29193. createRenderTargetTexture(size: number | {
  29194. width: number;
  29195. height: number;
  29196. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29197. /**
  29198. * Create a multi render target texture
  29199. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29200. * @param size defines the size of the texture
  29201. * @param options defines the creation options
  29202. * @returns the cube texture as an InternalTexture
  29203. */
  29204. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29205. private _setupFramebufferDepthAttachments;
  29206. /**
  29207. * Updates the sample count of a render target texture
  29208. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29209. * @param texture defines the texture to update
  29210. * @param samples defines the sample count to set
  29211. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29212. */
  29213. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29214. /**
  29215. * Update the sample count for a given multiple render target texture
  29216. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29217. * @param textures defines the textures to update
  29218. * @param samples defines the sample count to set
  29219. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29220. */
  29221. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29222. /** @hidden */
  29223. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29224. /** @hidden */
  29225. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29226. /** @hidden */
  29227. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29228. /** @hidden */
  29229. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29230. /**
  29231. * Creates a new render target cube texture
  29232. * @param size defines the size of the texture
  29233. * @param options defines the options used to create the texture
  29234. * @returns a new render target cube texture stored in an InternalTexture
  29235. */
  29236. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29237. /**
  29238. * Creates a cube texture
  29239. * @param rootUrl defines the url where the files to load is located
  29240. * @param scene defines the current scene
  29241. * @param files defines the list of files to load (1 per face)
  29242. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29243. * @param onLoad defines an optional callback raised when the texture is loaded
  29244. * @param onError defines an optional callback raised if there is an issue to load the texture
  29245. * @param format defines the format of the data
  29246. * @param forcedExtension defines the extension to use to pick the right loader
  29247. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29248. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29249. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29250. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29251. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29252. * @returns the cube texture as an InternalTexture
  29253. */
  29254. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29255. /**
  29256. * @hidden
  29257. */
  29258. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29259. /**
  29260. * Update a raw cube texture
  29261. * @param texture defines the texture to udpdate
  29262. * @param data defines the data to store
  29263. * @param format defines the data format
  29264. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29265. * @param invertY defines if data must be stored with Y axis inverted
  29266. * @param compression defines the compression used (null by default)
  29267. * @param level defines which level of the texture to update
  29268. */
  29269. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29270. /**
  29271. * Creates a new raw cube texture
  29272. * @param data defines the array of data to use to create each face
  29273. * @param size defines the size of the textures
  29274. * @param format defines the format of the data
  29275. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29276. * @param generateMipMaps defines if the engine should generate the mip levels
  29277. * @param invertY defines if data must be stored with Y axis inverted
  29278. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29279. * @param compression defines the compression used (null by default)
  29280. * @returns the cube texture as an InternalTexture
  29281. */
  29282. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29283. /**
  29284. * Creates a new raw cube texture from a specified url
  29285. * @param url defines the url where the data is located
  29286. * @param scene defines the current scene
  29287. * @param size defines the size of the textures
  29288. * @param format defines the format of the data
  29289. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29290. * @param noMipmap defines if the engine should avoid generating the mip levels
  29291. * @param callback defines a callback used to extract texture data from loaded data
  29292. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29293. * @param onLoad defines a callback called when texture is loaded
  29294. * @param onError defines a callback called if there is an error
  29295. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29296. * @param invertY defines if data must be stored with Y axis inverted
  29297. * @returns the cube texture as an InternalTexture
  29298. */
  29299. 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;
  29300. /**
  29301. * Update a raw 3D texture
  29302. * @param texture defines the texture to update
  29303. * @param data defines the data to store
  29304. * @param format defines the data format
  29305. * @param invertY defines if data must be stored with Y axis inverted
  29306. * @param compression defines the used compression (can be null)
  29307. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29308. */
  29309. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29310. /**
  29311. * Creates a new raw 3D texture
  29312. * @param data defines the data used to create the texture
  29313. * @param width defines the width of the texture
  29314. * @param height defines the height of the texture
  29315. * @param depth defines the depth of the texture
  29316. * @param format defines the format of the texture
  29317. * @param generateMipMaps defines if the engine must generate mip levels
  29318. * @param invertY defines if data must be stored with Y axis inverted
  29319. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29320. * @param compression defines the compressed used (can be null)
  29321. * @param textureType defines the compressed used (can be null)
  29322. * @returns a new raw 3D texture (stored in an InternalTexture)
  29323. */
  29324. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29325. private _prepareWebGLTextureContinuation;
  29326. private _prepareWebGLTexture;
  29327. private _convertRGBtoRGBATextureData;
  29328. /** @hidden */
  29329. _releaseFramebufferObjects(texture: InternalTexture): void;
  29330. /** @hidden */
  29331. _releaseTexture(texture: InternalTexture): void;
  29332. private setProgram;
  29333. private _boundUniforms;
  29334. /**
  29335. * Binds an effect to the webGL context
  29336. * @param effect defines the effect to bind
  29337. */
  29338. bindSamplers(effect: Effect): void;
  29339. private _activateCurrentTexture;
  29340. /** @hidden */
  29341. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29342. /** @hidden */
  29343. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29344. /**
  29345. * Sets a texture to the webGL context from a postprocess
  29346. * @param channel defines the channel to use
  29347. * @param postProcess defines the source postprocess
  29348. */
  29349. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29350. /**
  29351. * Binds the output of the passed in post process to the texture channel specified
  29352. * @param channel The channel the texture should be bound to
  29353. * @param postProcess The post process which's output should be bound
  29354. */
  29355. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29356. /**
  29357. * Unbind all textures from the webGL context
  29358. */
  29359. unbindAllTextures(): void;
  29360. /**
  29361. * Sets a texture to the according uniform.
  29362. * @param channel The texture channel
  29363. * @param uniform The uniform to set
  29364. * @param texture The texture to apply
  29365. */
  29366. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29367. /**
  29368. * Sets a depth stencil texture from a render target to the according uniform.
  29369. * @param channel The texture channel
  29370. * @param uniform The uniform to set
  29371. * @param texture The render target texture containing the depth stencil texture to apply
  29372. */
  29373. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29374. private _bindSamplerUniformToChannel;
  29375. private _getTextureWrapMode;
  29376. private _setTexture;
  29377. /**
  29378. * Sets an array of texture to the webGL context
  29379. * @param channel defines the channel where the texture array must be set
  29380. * @param uniform defines the associated uniform location
  29381. * @param textures defines the array of textures to bind
  29382. */
  29383. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29384. /** @hidden */
  29385. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29386. private _setTextureParameterFloat;
  29387. private _setTextureParameterInteger;
  29388. /**
  29389. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29390. * @param x defines the x coordinate of the rectangle where pixels must be read
  29391. * @param y defines the y coordinate of the rectangle where pixels must be read
  29392. * @param width defines the width of the rectangle where pixels must be read
  29393. * @param height defines the height of the rectangle where pixels must be read
  29394. * @returns a Uint8Array containing RGBA colors
  29395. */
  29396. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29397. /**
  29398. * Add an externaly attached data from its key.
  29399. * This method call will fail and return false, if such key already exists.
  29400. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29401. * @param key the unique key that identifies the data
  29402. * @param data the data object to associate to the key for this Engine instance
  29403. * @return true if no such key were already present and the data was added successfully, false otherwise
  29404. */
  29405. addExternalData<T>(key: string, data: T): boolean;
  29406. /**
  29407. * Get an externaly attached data from its key
  29408. * @param key the unique key that identifies the data
  29409. * @return the associated data, if present (can be null), or undefined if not present
  29410. */
  29411. getExternalData<T>(key: string): T;
  29412. /**
  29413. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29414. * @param key the unique key that identifies the data
  29415. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29416. * @return the associated data, can be null if the factory returned null.
  29417. */
  29418. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29419. /**
  29420. * Remove an externaly attached data from the Engine instance
  29421. * @param key the unique key that identifies the data
  29422. * @return true if the data was successfully removed, false if it doesn't exist
  29423. */
  29424. removeExternalData(key: string): boolean;
  29425. /**
  29426. * Unbind all vertex attributes from the webGL context
  29427. */
  29428. unbindAllAttributes(): void;
  29429. /**
  29430. * 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
  29431. */
  29432. releaseEffects(): void;
  29433. /**
  29434. * Dispose and release all associated resources
  29435. */
  29436. dispose(): void;
  29437. /**
  29438. * Display the loading screen
  29439. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29440. */
  29441. displayLoadingUI(): void;
  29442. /**
  29443. * Hide the loading screen
  29444. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29445. */
  29446. hideLoadingUI(): void;
  29447. /**
  29448. * Gets the current loading screen object
  29449. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29450. */
  29451. /**
  29452. * Sets the current loading screen object
  29453. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29454. */
  29455. loadingScreen: ILoadingScreen;
  29456. /**
  29457. * Sets the current loading screen text
  29458. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29459. */
  29460. loadingUIText: string;
  29461. /**
  29462. * Sets the current loading screen background color
  29463. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29464. */
  29465. loadingUIBackgroundColor: string;
  29466. /**
  29467. * Attach a new callback raised when context lost event is fired
  29468. * @param callback defines the callback to call
  29469. */
  29470. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29471. /**
  29472. * Attach a new callback raised when context restored event is fired
  29473. * @param callback defines the callback to call
  29474. */
  29475. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29476. /**
  29477. * Gets the source code of the vertex shader associated with a specific webGL program
  29478. * @param program defines the program to use
  29479. * @returns a string containing the source code of the vertex shader associated with the program
  29480. */
  29481. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29482. /**
  29483. * Gets the source code of the fragment shader associated with a specific webGL program
  29484. * @param program defines the program to use
  29485. * @returns a string containing the source code of the fragment shader associated with the program
  29486. */
  29487. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29488. /**
  29489. * Get the current error code of the webGL context
  29490. * @returns the error code
  29491. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29492. */
  29493. getError(): number;
  29494. /**
  29495. * Gets the current framerate
  29496. * @returns a number representing the framerate
  29497. */
  29498. getFps(): number;
  29499. /**
  29500. * Gets the time spent between current and previous frame
  29501. * @returns a number representing the delta time in ms
  29502. */
  29503. getDeltaTime(): number;
  29504. private _measureFps;
  29505. /** @hidden */
  29506. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29507. private _canRenderToFloatFramebuffer;
  29508. private _canRenderToHalfFloatFramebuffer;
  29509. private _canRenderToFramebuffer;
  29510. /** @hidden */
  29511. _getWebGLTextureType(type: number): number;
  29512. private _getInternalFormat;
  29513. /** @hidden */
  29514. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29515. /** @hidden */
  29516. _getRGBAMultiSampleBufferFormat(type: number): number;
  29517. /** @hidden */
  29518. _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;
  29519. /** @hidden */
  29520. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29521. private _partialLoadFile;
  29522. private _cascadeLoadFiles;
  29523. /**
  29524. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29525. * @returns true if the engine can be created
  29526. * @ignorenaming
  29527. */
  29528. static isSupported(): boolean;
  29529. }
  29530. }
  29531. declare module "babylonjs/Materials/effect" {
  29532. import { Observable } from "babylonjs/Misc/observable";
  29533. import { Nullable } from "babylonjs/types";
  29534. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29535. import { Engine } from "babylonjs/Engines/engine";
  29536. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29537. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29538. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29539. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29541. /**
  29542. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29543. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29544. */
  29545. export class EffectFallbacks {
  29546. private _defines;
  29547. private _currentRank;
  29548. private _maxRank;
  29549. private _mesh;
  29550. /**
  29551. * Removes the fallback from the bound mesh.
  29552. */
  29553. unBindMesh(): void;
  29554. /**
  29555. * Adds a fallback on the specified property.
  29556. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29557. * @param define The name of the define in the shader
  29558. */
  29559. addFallback(rank: number, define: string): void;
  29560. /**
  29561. * Sets the mesh to use CPU skinning when needing to fallback.
  29562. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29563. * @param mesh The mesh to use the fallbacks.
  29564. */
  29565. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29566. /**
  29567. * Checks to see if more fallbacks are still availible.
  29568. */
  29569. readonly isMoreFallbacks: boolean;
  29570. /**
  29571. * Removes the defines that shoould be removed when falling back.
  29572. * @param currentDefines defines the current define statements for the shader.
  29573. * @param effect defines the current effect we try to compile
  29574. * @returns The resulting defines with defines of the current rank removed.
  29575. */
  29576. reduce(currentDefines: string, effect: Effect): string;
  29577. }
  29578. /**
  29579. * Options to be used when creating an effect.
  29580. */
  29581. export class EffectCreationOptions {
  29582. /**
  29583. * Atrributes that will be used in the shader.
  29584. */
  29585. attributes: string[];
  29586. /**
  29587. * Uniform varible names that will be set in the shader.
  29588. */
  29589. uniformsNames: string[];
  29590. /**
  29591. * Uniform buffer varible names that will be set in the shader.
  29592. */
  29593. uniformBuffersNames: string[];
  29594. /**
  29595. * Sampler texture variable names that will be set in the shader.
  29596. */
  29597. samplers: string[];
  29598. /**
  29599. * Define statements that will be set in the shader.
  29600. */
  29601. defines: any;
  29602. /**
  29603. * Possible fallbacks for this effect to improve performance when needed.
  29604. */
  29605. fallbacks: Nullable<EffectFallbacks>;
  29606. /**
  29607. * Callback that will be called when the shader is compiled.
  29608. */
  29609. onCompiled: Nullable<(effect: Effect) => void>;
  29610. /**
  29611. * Callback that will be called if an error occurs during shader compilation.
  29612. */
  29613. onError: Nullable<(effect: Effect, errors: string) => void>;
  29614. /**
  29615. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29616. */
  29617. indexParameters: any;
  29618. /**
  29619. * Max number of lights that can be used in the shader.
  29620. */
  29621. maxSimultaneousLights: number;
  29622. /**
  29623. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29624. */
  29625. transformFeedbackVaryings: Nullable<string[]>;
  29626. }
  29627. /**
  29628. * Effect containing vertex and fragment shader that can be executed on an object.
  29629. */
  29630. export class Effect {
  29631. /**
  29632. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29633. */
  29634. static ShadersRepository: string;
  29635. /**
  29636. * Name of the effect.
  29637. */
  29638. name: any;
  29639. /**
  29640. * String container all the define statements that should be set on the shader.
  29641. */
  29642. defines: string;
  29643. /**
  29644. * Callback that will be called when the shader is compiled.
  29645. */
  29646. onCompiled: Nullable<(effect: Effect) => void>;
  29647. /**
  29648. * Callback that will be called if an error occurs during shader compilation.
  29649. */
  29650. onError: Nullable<(effect: Effect, errors: string) => void>;
  29651. /**
  29652. * Callback that will be called when effect is bound.
  29653. */
  29654. onBind: Nullable<(effect: Effect) => void>;
  29655. /**
  29656. * Unique ID of the effect.
  29657. */
  29658. uniqueId: number;
  29659. /**
  29660. * Observable that will be called when the shader is compiled.
  29661. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29662. */
  29663. onCompileObservable: Observable<Effect>;
  29664. /**
  29665. * Observable that will be called if an error occurs during shader compilation.
  29666. */
  29667. onErrorObservable: Observable<Effect>;
  29668. /** @hidden */
  29669. _onBindObservable: Nullable<Observable<Effect>>;
  29670. /**
  29671. * Observable that will be called when effect is bound.
  29672. */
  29673. readonly onBindObservable: Observable<Effect>;
  29674. /** @hidden */
  29675. _bonesComputationForcedToCPU: boolean;
  29676. private static _uniqueIdSeed;
  29677. private _engine;
  29678. private _uniformBuffersNames;
  29679. private _uniformsNames;
  29680. private _samplers;
  29681. private _isReady;
  29682. private _compilationError;
  29683. private _attributesNames;
  29684. private _attributes;
  29685. private _uniforms;
  29686. /**
  29687. * Key for the effect.
  29688. * @hidden
  29689. */
  29690. _key: string;
  29691. private _indexParameters;
  29692. private _fallbacks;
  29693. private _vertexSourceCode;
  29694. private _fragmentSourceCode;
  29695. private _vertexSourceCodeOverride;
  29696. private _fragmentSourceCodeOverride;
  29697. private _transformFeedbackVaryings;
  29698. /**
  29699. * Compiled shader to webGL program.
  29700. * @hidden
  29701. */
  29702. _program: WebGLProgram;
  29703. private _valueCache;
  29704. private static _baseCache;
  29705. /**
  29706. * Instantiates an effect.
  29707. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29708. * @param baseName Name of the effect.
  29709. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29710. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29711. * @param samplers List of sampler variables that will be passed to the shader.
  29712. * @param engine Engine to be used to render the effect
  29713. * @param defines Define statements to be added to the shader.
  29714. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29715. * @param onCompiled Callback that will be called when the shader is compiled.
  29716. * @param onError Callback that will be called if an error occurs during shader compilation.
  29717. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29718. */
  29719. 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);
  29720. /**
  29721. * Unique key for this effect
  29722. */
  29723. readonly key: string;
  29724. /**
  29725. * If the effect has been compiled and prepared.
  29726. * @returns if the effect is compiled and prepared.
  29727. */
  29728. isReady(): boolean;
  29729. /**
  29730. * The engine the effect was initialized with.
  29731. * @returns the engine.
  29732. */
  29733. getEngine(): Engine;
  29734. /**
  29735. * The compiled webGL program for the effect
  29736. * @returns the webGL program.
  29737. */
  29738. getProgram(): WebGLProgram;
  29739. /**
  29740. * The set of names of attribute variables for the shader.
  29741. * @returns An array of attribute names.
  29742. */
  29743. getAttributesNames(): string[];
  29744. /**
  29745. * Returns the attribute at the given index.
  29746. * @param index The index of the attribute.
  29747. * @returns The location of the attribute.
  29748. */
  29749. getAttributeLocation(index: number): number;
  29750. /**
  29751. * Returns the attribute based on the name of the variable.
  29752. * @param name of the attribute to look up.
  29753. * @returns the attribute location.
  29754. */
  29755. getAttributeLocationByName(name: string): number;
  29756. /**
  29757. * The number of attributes.
  29758. * @returns the numnber of attributes.
  29759. */
  29760. getAttributesCount(): number;
  29761. /**
  29762. * Gets the index of a uniform variable.
  29763. * @param uniformName of the uniform to look up.
  29764. * @returns the index.
  29765. */
  29766. getUniformIndex(uniformName: string): number;
  29767. /**
  29768. * Returns the attribute based on the name of the variable.
  29769. * @param uniformName of the uniform to look up.
  29770. * @returns the location of the uniform.
  29771. */
  29772. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29773. /**
  29774. * Returns an array of sampler variable names
  29775. * @returns The array of sampler variable neames.
  29776. */
  29777. getSamplers(): string[];
  29778. /**
  29779. * The error from the last compilation.
  29780. * @returns the error string.
  29781. */
  29782. getCompilationError(): string;
  29783. /**
  29784. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29785. * @param func The callback to be used.
  29786. */
  29787. executeWhenCompiled(func: (effect: Effect) => void): void;
  29788. private _checkIsReady;
  29789. /** @hidden */
  29790. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29791. /** @hidden */
  29792. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29793. /** @hidden */
  29794. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29795. private _processShaderConversion;
  29796. private _processIncludes;
  29797. private _processPrecision;
  29798. /**
  29799. * Recompiles the webGL program
  29800. * @param vertexSourceCode The source code for the vertex shader.
  29801. * @param fragmentSourceCode The source code for the fragment shader.
  29802. * @param onCompiled Callback called when completed.
  29803. * @param onError Callback called on error.
  29804. * @hidden
  29805. */
  29806. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29807. /**
  29808. * Gets the uniform locations of the the specified variable names
  29809. * @param names THe names of the variables to lookup.
  29810. * @returns Array of locations in the same order as variable names.
  29811. */
  29812. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29813. /**
  29814. * Prepares the effect
  29815. * @hidden
  29816. */
  29817. _prepareEffect(): void;
  29818. /**
  29819. * Checks if the effect is supported. (Must be called after compilation)
  29820. */
  29821. readonly isSupported: boolean;
  29822. /**
  29823. * Binds a texture to the engine to be used as output of the shader.
  29824. * @param channel Name of the output variable.
  29825. * @param texture Texture to bind.
  29826. * @hidden
  29827. */
  29828. _bindTexture(channel: string, texture: InternalTexture): void;
  29829. /**
  29830. * Sets a texture on the engine to be used in the shader.
  29831. * @param channel Name of the sampler variable.
  29832. * @param texture Texture to set.
  29833. */
  29834. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29835. /**
  29836. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29837. * @param channel Name of the sampler variable.
  29838. * @param texture Texture to set.
  29839. */
  29840. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29841. /**
  29842. * Sets an array of textures on the engine to be used in the shader.
  29843. * @param channel Name of the variable.
  29844. * @param textures Textures to set.
  29845. */
  29846. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29847. /**
  29848. * 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)
  29849. * @param channel Name of the sampler variable.
  29850. * @param postProcess Post process to get the input texture from.
  29851. */
  29852. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29853. /**
  29854. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29855. * 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)
  29856. * @param channel Name of the sampler variable.
  29857. * @param postProcess Post process to get the output texture from.
  29858. */
  29859. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29860. /** @hidden */
  29861. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29862. /** @hidden */
  29863. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29864. /** @hidden */
  29865. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29866. /** @hidden */
  29867. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29868. /**
  29869. * Binds a buffer to a uniform.
  29870. * @param buffer Buffer to bind.
  29871. * @param name Name of the uniform variable to bind to.
  29872. */
  29873. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29874. /**
  29875. * Binds block to a uniform.
  29876. * @param blockName Name of the block to bind.
  29877. * @param index Index to bind.
  29878. */
  29879. bindUniformBlock(blockName: string, index: number): void;
  29880. /**
  29881. * Sets an interger value on a uniform variable.
  29882. * @param uniformName Name of the variable.
  29883. * @param value Value to be set.
  29884. * @returns this effect.
  29885. */
  29886. setInt(uniformName: string, value: number): Effect;
  29887. /**
  29888. * Sets an int array on a uniform variable.
  29889. * @param uniformName Name of the variable.
  29890. * @param array array to be set.
  29891. * @returns this effect.
  29892. */
  29893. setIntArray(uniformName: string, array: Int32Array): Effect;
  29894. /**
  29895. * 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)
  29896. * @param uniformName Name of the variable.
  29897. * @param array array to be set.
  29898. * @returns this effect.
  29899. */
  29900. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29901. /**
  29902. * 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)
  29903. * @param uniformName Name of the variable.
  29904. * @param array array to be set.
  29905. * @returns this effect.
  29906. */
  29907. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29908. /**
  29909. * 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)
  29910. * @param uniformName Name of the variable.
  29911. * @param array array to be set.
  29912. * @returns this effect.
  29913. */
  29914. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29915. /**
  29916. * Sets an float array on a uniform variable.
  29917. * @param uniformName Name of the variable.
  29918. * @param array array to be set.
  29919. * @returns this effect.
  29920. */
  29921. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29922. /**
  29923. * 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)
  29924. * @param uniformName Name of the variable.
  29925. * @param array array to be set.
  29926. * @returns this effect.
  29927. */
  29928. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29929. /**
  29930. * 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)
  29931. * @param uniformName Name of the variable.
  29932. * @param array array to be set.
  29933. * @returns this effect.
  29934. */
  29935. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29936. /**
  29937. * 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)
  29938. * @param uniformName Name of the variable.
  29939. * @param array array to be set.
  29940. * @returns this effect.
  29941. */
  29942. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29943. /**
  29944. * Sets an array on a uniform variable.
  29945. * @param uniformName Name of the variable.
  29946. * @param array array to be set.
  29947. * @returns this effect.
  29948. */
  29949. setArray(uniformName: string, array: number[]): Effect;
  29950. /**
  29951. * 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)
  29952. * @param uniformName Name of the variable.
  29953. * @param array array to be set.
  29954. * @returns this effect.
  29955. */
  29956. setArray2(uniformName: string, array: number[]): Effect;
  29957. /**
  29958. * 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)
  29959. * @param uniformName Name of the variable.
  29960. * @param array array to be set.
  29961. * @returns this effect.
  29962. */
  29963. setArray3(uniformName: string, array: number[]): Effect;
  29964. /**
  29965. * 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)
  29966. * @param uniformName Name of the variable.
  29967. * @param array array to be set.
  29968. * @returns this effect.
  29969. */
  29970. setArray4(uniformName: string, array: number[]): Effect;
  29971. /**
  29972. * Sets matrices on a uniform variable.
  29973. * @param uniformName Name of the variable.
  29974. * @param matrices matrices to be set.
  29975. * @returns this effect.
  29976. */
  29977. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29978. /**
  29979. * Sets matrix on a uniform variable.
  29980. * @param uniformName Name of the variable.
  29981. * @param matrix matrix to be set.
  29982. * @returns this effect.
  29983. */
  29984. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29985. /**
  29986. * 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)
  29987. * @param uniformName Name of the variable.
  29988. * @param matrix matrix to be set.
  29989. * @returns this effect.
  29990. */
  29991. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29992. /**
  29993. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29994. * @param uniformName Name of the variable.
  29995. * @param matrix matrix to be set.
  29996. * @returns this effect.
  29997. */
  29998. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29999. /**
  30000. * Sets a float on a uniform variable.
  30001. * @param uniformName Name of the variable.
  30002. * @param value value to be set.
  30003. * @returns this effect.
  30004. */
  30005. setFloat(uniformName: string, value: number): Effect;
  30006. /**
  30007. * Sets a boolean on a uniform variable.
  30008. * @param uniformName Name of the variable.
  30009. * @param bool value to be set.
  30010. * @returns this effect.
  30011. */
  30012. setBool(uniformName: string, bool: boolean): Effect;
  30013. /**
  30014. * Sets a Vector2 on a uniform variable.
  30015. * @param uniformName Name of the variable.
  30016. * @param vector2 vector2 to be set.
  30017. * @returns this effect.
  30018. */
  30019. setVector2(uniformName: string, vector2: Vector2): Effect;
  30020. /**
  30021. * Sets a float2 on a uniform variable.
  30022. * @param uniformName Name of the variable.
  30023. * @param x First float in float2.
  30024. * @param y Second float in float2.
  30025. * @returns this effect.
  30026. */
  30027. setFloat2(uniformName: string, x: number, y: number): Effect;
  30028. /**
  30029. * Sets a Vector3 on a uniform variable.
  30030. * @param uniformName Name of the variable.
  30031. * @param vector3 Value to be set.
  30032. * @returns this effect.
  30033. */
  30034. setVector3(uniformName: string, vector3: Vector3): Effect;
  30035. /**
  30036. * Sets a float3 on a uniform variable.
  30037. * @param uniformName Name of the variable.
  30038. * @param x First float in float3.
  30039. * @param y Second float in float3.
  30040. * @param z Third float in float3.
  30041. * @returns this effect.
  30042. */
  30043. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30044. /**
  30045. * Sets a Vector4 on a uniform variable.
  30046. * @param uniformName Name of the variable.
  30047. * @param vector4 Value to be set.
  30048. * @returns this effect.
  30049. */
  30050. setVector4(uniformName: string, vector4: Vector4): Effect;
  30051. /**
  30052. * Sets a float4 on a uniform variable.
  30053. * @param uniformName Name of the variable.
  30054. * @param x First float in float4.
  30055. * @param y Second float in float4.
  30056. * @param z Third float in float4.
  30057. * @param w Fourth float in float4.
  30058. * @returns this effect.
  30059. */
  30060. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30061. /**
  30062. * Sets a Color3 on a uniform variable.
  30063. * @param uniformName Name of the variable.
  30064. * @param color3 Value to be set.
  30065. * @returns this effect.
  30066. */
  30067. setColor3(uniformName: string, color3: Color3): Effect;
  30068. /**
  30069. * Sets a Color4 on a uniform variable.
  30070. * @param uniformName Name of the variable.
  30071. * @param color3 Value to be set.
  30072. * @param alpha Alpha value to be set.
  30073. * @returns this effect.
  30074. */
  30075. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30076. /**
  30077. * Sets a Color4 on a uniform variable
  30078. * @param uniformName defines the name of the variable
  30079. * @param color4 defines the value to be set
  30080. * @returns this effect.
  30081. */
  30082. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30083. /**
  30084. * This function will add a new shader to the shader store
  30085. * @param name the name of the shader
  30086. * @param pixelShader optional pixel shader content
  30087. * @param vertexShader optional vertex shader content
  30088. */
  30089. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30090. /**
  30091. * Store of each shader (The can be looked up using effect.key)
  30092. */
  30093. static ShadersStore: {
  30094. [key: string]: string;
  30095. };
  30096. /**
  30097. * Store of each included file for a shader (The can be looked up using effect.key)
  30098. */
  30099. static IncludesShadersStore: {
  30100. [key: string]: string;
  30101. };
  30102. /**
  30103. * Resets the cache of effects.
  30104. */
  30105. static ResetCache(): void;
  30106. }
  30107. }
  30108. declare module "babylonjs/Materials/colorCurves" {
  30109. import { Effect } from "babylonjs/Materials/effect";
  30110. /**
  30111. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30112. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30113. * 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;
  30114. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30115. */
  30116. export class ColorCurves {
  30117. private _dirty;
  30118. private _tempColor;
  30119. private _globalCurve;
  30120. private _highlightsCurve;
  30121. private _midtonesCurve;
  30122. private _shadowsCurve;
  30123. private _positiveCurve;
  30124. private _negativeCurve;
  30125. private _globalHue;
  30126. private _globalDensity;
  30127. private _globalSaturation;
  30128. private _globalExposure;
  30129. /**
  30130. * Gets the global Hue value.
  30131. * 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).
  30132. */
  30133. /**
  30134. * Sets the global Hue value.
  30135. * 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).
  30136. */
  30137. globalHue: number;
  30138. /**
  30139. * Gets the global Density value.
  30140. * 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.
  30141. * Values less than zero provide a filter of opposite hue.
  30142. */
  30143. /**
  30144. * Sets the global Density value.
  30145. * 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.
  30146. * Values less than zero provide a filter of opposite hue.
  30147. */
  30148. globalDensity: number;
  30149. /**
  30150. * Gets the global Saturation value.
  30151. * 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.
  30152. */
  30153. /**
  30154. * Sets the global Saturation value.
  30155. * 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.
  30156. */
  30157. globalSaturation: number;
  30158. /**
  30159. * Gets the global Exposure value.
  30160. * 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.
  30161. */
  30162. /**
  30163. * Sets the global Exposure value.
  30164. * 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.
  30165. */
  30166. globalExposure: number;
  30167. private _highlightsHue;
  30168. private _highlightsDensity;
  30169. private _highlightsSaturation;
  30170. private _highlightsExposure;
  30171. /**
  30172. * Gets the highlights Hue value.
  30173. * 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).
  30174. */
  30175. /**
  30176. * Sets the highlights Hue value.
  30177. * 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).
  30178. */
  30179. highlightsHue: number;
  30180. /**
  30181. * Gets the highlights Density value.
  30182. * 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.
  30183. * Values less than zero provide a filter of opposite hue.
  30184. */
  30185. /**
  30186. * Sets the highlights Density value.
  30187. * 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.
  30188. * Values less than zero provide a filter of opposite hue.
  30189. */
  30190. highlightsDensity: number;
  30191. /**
  30192. * Gets the highlights Saturation value.
  30193. * 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.
  30194. */
  30195. /**
  30196. * Sets the highlights Saturation value.
  30197. * 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.
  30198. */
  30199. highlightsSaturation: number;
  30200. /**
  30201. * Gets the highlights Exposure value.
  30202. * 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.
  30203. */
  30204. /**
  30205. * Sets the highlights Exposure value.
  30206. * 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.
  30207. */
  30208. highlightsExposure: number;
  30209. private _midtonesHue;
  30210. private _midtonesDensity;
  30211. private _midtonesSaturation;
  30212. private _midtonesExposure;
  30213. /**
  30214. * Gets the midtones Hue value.
  30215. * 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).
  30216. */
  30217. /**
  30218. * Sets the midtones Hue value.
  30219. * 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).
  30220. */
  30221. midtonesHue: number;
  30222. /**
  30223. * Gets the midtones Density value.
  30224. * 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.
  30225. * Values less than zero provide a filter of opposite hue.
  30226. */
  30227. /**
  30228. * Sets the midtones Density value.
  30229. * 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.
  30230. * Values less than zero provide a filter of opposite hue.
  30231. */
  30232. midtonesDensity: number;
  30233. /**
  30234. * Gets the midtones Saturation value.
  30235. * 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.
  30236. */
  30237. /**
  30238. * Sets the midtones Saturation value.
  30239. * 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.
  30240. */
  30241. midtonesSaturation: number;
  30242. /**
  30243. * Gets the midtones Exposure value.
  30244. * 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.
  30245. */
  30246. /**
  30247. * Sets the midtones Exposure value.
  30248. * 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.
  30249. */
  30250. midtonesExposure: number;
  30251. private _shadowsHue;
  30252. private _shadowsDensity;
  30253. private _shadowsSaturation;
  30254. private _shadowsExposure;
  30255. /**
  30256. * Gets the shadows Hue value.
  30257. * 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).
  30258. */
  30259. /**
  30260. * Sets the shadows Hue value.
  30261. * 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).
  30262. */
  30263. shadowsHue: number;
  30264. /**
  30265. * Gets the shadows Density value.
  30266. * 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.
  30267. * Values less than zero provide a filter of opposite hue.
  30268. */
  30269. /**
  30270. * Sets the shadows Density value.
  30271. * 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.
  30272. * Values less than zero provide a filter of opposite hue.
  30273. */
  30274. shadowsDensity: number;
  30275. /**
  30276. * Gets the shadows Saturation value.
  30277. * 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.
  30278. */
  30279. /**
  30280. * Sets the shadows Saturation value.
  30281. * 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.
  30282. */
  30283. shadowsSaturation: number;
  30284. /**
  30285. * Gets the shadows Exposure value.
  30286. * 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.
  30287. */
  30288. /**
  30289. * Sets the shadows Exposure value.
  30290. * 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.
  30291. */
  30292. shadowsExposure: number;
  30293. /**
  30294. * Returns the class name
  30295. * @returns The class name
  30296. */
  30297. getClassName(): string;
  30298. /**
  30299. * Binds the color curves to the shader.
  30300. * @param colorCurves The color curve to bind
  30301. * @param effect The effect to bind to
  30302. * @param positiveUniform The positive uniform shader parameter
  30303. * @param neutralUniform The neutral uniform shader parameter
  30304. * @param negativeUniform The negative uniform shader parameter
  30305. */
  30306. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30307. /**
  30308. * Prepare the list of uniforms associated with the ColorCurves effects.
  30309. * @param uniformsList The list of uniforms used in the effect
  30310. */
  30311. static PrepareUniforms(uniformsList: string[]): void;
  30312. /**
  30313. * Returns color grading data based on a hue, density, saturation and exposure value.
  30314. * @param filterHue The hue of the color filter.
  30315. * @param filterDensity The density of the color filter.
  30316. * @param saturation The saturation.
  30317. * @param exposure The exposure.
  30318. * @param result The result data container.
  30319. */
  30320. private getColorGradingDataToRef;
  30321. /**
  30322. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30323. * @param value The input slider value in range [-100,100].
  30324. * @returns Adjusted value.
  30325. */
  30326. private static applyColorGradingSliderNonlinear;
  30327. /**
  30328. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30329. * @param hue The hue (H) input.
  30330. * @param saturation The saturation (S) input.
  30331. * @param brightness The brightness (B) input.
  30332. * @result An RGBA color represented as Vector4.
  30333. */
  30334. private static fromHSBToRef;
  30335. /**
  30336. * Returns a value clamped between min and max
  30337. * @param value The value to clamp
  30338. * @param min The minimum of value
  30339. * @param max The maximum of value
  30340. * @returns The clamped value.
  30341. */
  30342. private static clamp;
  30343. /**
  30344. * Clones the current color curve instance.
  30345. * @return The cloned curves
  30346. */
  30347. clone(): ColorCurves;
  30348. /**
  30349. * Serializes the current color curve instance to a json representation.
  30350. * @return a JSON representation
  30351. */
  30352. serialize(): any;
  30353. /**
  30354. * Parses the color curve from a json representation.
  30355. * @param source the JSON source to parse
  30356. * @return The parsed curves
  30357. */
  30358. static Parse(source: any): ColorCurves;
  30359. }
  30360. }
  30361. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30362. import { Observable } from "babylonjs/Misc/observable";
  30363. import { Nullable } from "babylonjs/types";
  30364. import { Color4 } from "babylonjs/Maths/math";
  30365. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30366. import { Effect } from "babylonjs/Materials/effect";
  30367. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30368. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30369. /**
  30370. * Interface to follow in your material defines to integrate easily the
  30371. * Image proccessing functions.
  30372. * @hidden
  30373. */
  30374. export interface IImageProcessingConfigurationDefines {
  30375. IMAGEPROCESSING: boolean;
  30376. VIGNETTE: boolean;
  30377. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30378. VIGNETTEBLENDMODEOPAQUE: boolean;
  30379. TONEMAPPING: boolean;
  30380. TONEMAPPING_ACES: boolean;
  30381. CONTRAST: boolean;
  30382. EXPOSURE: boolean;
  30383. COLORCURVES: boolean;
  30384. COLORGRADING: boolean;
  30385. COLORGRADING3D: boolean;
  30386. SAMPLER3DGREENDEPTH: boolean;
  30387. SAMPLER3DBGRMAP: boolean;
  30388. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30389. }
  30390. /**
  30391. * @hidden
  30392. */
  30393. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30394. IMAGEPROCESSING: boolean;
  30395. VIGNETTE: boolean;
  30396. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30397. VIGNETTEBLENDMODEOPAQUE: boolean;
  30398. TONEMAPPING: boolean;
  30399. TONEMAPPING_ACES: boolean;
  30400. CONTRAST: boolean;
  30401. COLORCURVES: boolean;
  30402. COLORGRADING: boolean;
  30403. COLORGRADING3D: boolean;
  30404. SAMPLER3DGREENDEPTH: boolean;
  30405. SAMPLER3DBGRMAP: boolean;
  30406. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30407. EXPOSURE: boolean;
  30408. constructor();
  30409. }
  30410. /**
  30411. * This groups together the common properties used for image processing either in direct forward pass
  30412. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30413. * or not.
  30414. */
  30415. export class ImageProcessingConfiguration {
  30416. /**
  30417. * Default tone mapping applied in BabylonJS.
  30418. */
  30419. static readonly TONEMAPPING_STANDARD: number;
  30420. /**
  30421. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30422. * to other engines rendering to increase portability.
  30423. */
  30424. static readonly TONEMAPPING_ACES: number;
  30425. /**
  30426. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30427. */
  30428. colorCurves: Nullable<ColorCurves>;
  30429. private _colorCurvesEnabled;
  30430. /**
  30431. * Gets wether the color curves effect is enabled.
  30432. */
  30433. /**
  30434. * Sets wether the color curves effect is enabled.
  30435. */
  30436. colorCurvesEnabled: boolean;
  30437. private _colorGradingTexture;
  30438. /**
  30439. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30440. */
  30441. /**
  30442. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30443. */
  30444. colorGradingTexture: Nullable<BaseTexture>;
  30445. private _colorGradingEnabled;
  30446. /**
  30447. * Gets wether the color grading effect is enabled.
  30448. */
  30449. /**
  30450. * Sets wether the color grading effect is enabled.
  30451. */
  30452. colorGradingEnabled: boolean;
  30453. private _colorGradingWithGreenDepth;
  30454. /**
  30455. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30456. */
  30457. /**
  30458. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30459. */
  30460. colorGradingWithGreenDepth: boolean;
  30461. private _colorGradingBGR;
  30462. /**
  30463. * Gets wether the color grading texture contains BGR values.
  30464. */
  30465. /**
  30466. * Sets wether the color grading texture contains BGR values.
  30467. */
  30468. colorGradingBGR: boolean;
  30469. /** @hidden */
  30470. _exposure: number;
  30471. /**
  30472. * Gets the Exposure used in the effect.
  30473. */
  30474. /**
  30475. * Sets the Exposure used in the effect.
  30476. */
  30477. exposure: number;
  30478. private _toneMappingEnabled;
  30479. /**
  30480. * Gets wether the tone mapping effect is enabled.
  30481. */
  30482. /**
  30483. * Sets wether the tone mapping effect is enabled.
  30484. */
  30485. toneMappingEnabled: boolean;
  30486. private _toneMappingType;
  30487. /**
  30488. * Gets the type of tone mapping effect.
  30489. */
  30490. /**
  30491. * Sets the type of tone mapping effect used in BabylonJS.
  30492. */
  30493. toneMappingType: number;
  30494. protected _contrast: number;
  30495. /**
  30496. * Gets the contrast used in the effect.
  30497. */
  30498. /**
  30499. * Sets the contrast used in the effect.
  30500. */
  30501. contrast: number;
  30502. /**
  30503. * Vignette stretch size.
  30504. */
  30505. vignetteStretch: number;
  30506. /**
  30507. * Vignette centre X Offset.
  30508. */
  30509. vignetteCentreX: number;
  30510. /**
  30511. * Vignette centre Y Offset.
  30512. */
  30513. vignetteCentreY: number;
  30514. /**
  30515. * Vignette weight or intensity of the vignette effect.
  30516. */
  30517. vignetteWeight: number;
  30518. /**
  30519. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30520. * if vignetteEnabled is set to true.
  30521. */
  30522. vignetteColor: Color4;
  30523. /**
  30524. * Camera field of view used by the Vignette effect.
  30525. */
  30526. vignetteCameraFov: number;
  30527. private _vignetteBlendMode;
  30528. /**
  30529. * Gets the vignette blend mode allowing different kind of effect.
  30530. */
  30531. /**
  30532. * Sets the vignette blend mode allowing different kind of effect.
  30533. */
  30534. vignetteBlendMode: number;
  30535. private _vignetteEnabled;
  30536. /**
  30537. * Gets wether the vignette effect is enabled.
  30538. */
  30539. /**
  30540. * Sets wether the vignette effect is enabled.
  30541. */
  30542. vignetteEnabled: boolean;
  30543. private _applyByPostProcess;
  30544. /**
  30545. * Gets wether the image processing is applied through a post process or not.
  30546. */
  30547. /**
  30548. * Sets wether the image processing is applied through a post process or not.
  30549. */
  30550. applyByPostProcess: boolean;
  30551. private _isEnabled;
  30552. /**
  30553. * Gets wether the image processing is enabled or not.
  30554. */
  30555. /**
  30556. * Sets wether the image processing is enabled or not.
  30557. */
  30558. isEnabled: boolean;
  30559. /**
  30560. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30561. */
  30562. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30563. /**
  30564. * Method called each time the image processing information changes requires to recompile the effect.
  30565. */
  30566. protected _updateParameters(): void;
  30567. /**
  30568. * Gets the current class name.
  30569. * @return "ImageProcessingConfiguration"
  30570. */
  30571. getClassName(): string;
  30572. /**
  30573. * Prepare the list of uniforms associated with the Image Processing effects.
  30574. * @param uniforms The list of uniforms used in the effect
  30575. * @param defines the list of defines currently in use
  30576. */
  30577. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30578. /**
  30579. * Prepare the list of samplers associated with the Image Processing effects.
  30580. * @param samplersList The list of uniforms used in the effect
  30581. * @param defines the list of defines currently in use
  30582. */
  30583. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30584. /**
  30585. * Prepare the list of defines associated to the shader.
  30586. * @param defines the list of defines to complete
  30587. * @param forPostProcess Define if we are currently in post process mode or not
  30588. */
  30589. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30590. /**
  30591. * Returns true if all the image processing information are ready.
  30592. * @returns True if ready, otherwise, false
  30593. */
  30594. isReady(): boolean;
  30595. /**
  30596. * Binds the image processing to the shader.
  30597. * @param effect The effect to bind to
  30598. * @param aspectRatio Define the current aspect ratio of the effect
  30599. */
  30600. bind(effect: Effect, aspectRatio?: number): void;
  30601. /**
  30602. * Clones the current image processing instance.
  30603. * @return The cloned image processing
  30604. */
  30605. clone(): ImageProcessingConfiguration;
  30606. /**
  30607. * Serializes the current image processing instance to a json representation.
  30608. * @return a JSON representation
  30609. */
  30610. serialize(): any;
  30611. /**
  30612. * Parses the image processing from a json representation.
  30613. * @param source the JSON source to parse
  30614. * @return The parsed image processing
  30615. */
  30616. static Parse(source: any): ImageProcessingConfiguration;
  30617. private static _VIGNETTEMODE_MULTIPLY;
  30618. private static _VIGNETTEMODE_OPAQUE;
  30619. /**
  30620. * Used to apply the vignette as a mix with the pixel color.
  30621. */
  30622. static readonly VIGNETTEMODE_MULTIPLY: number;
  30623. /**
  30624. * Used to apply the vignette as a replacement of the pixel color.
  30625. */
  30626. static readonly VIGNETTEMODE_OPAQUE: number;
  30627. }
  30628. }
  30629. declare module "babylonjs/Materials/fresnelParameters" {
  30630. import { Color3 } from "babylonjs/Maths/math";
  30631. /**
  30632. * This represents all the required information to add a fresnel effect on a material:
  30633. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30634. */
  30635. export class FresnelParameters {
  30636. private _isEnabled;
  30637. /**
  30638. * Define if the fresnel effect is enable or not.
  30639. */
  30640. isEnabled: boolean;
  30641. /**
  30642. * Define the color used on edges (grazing angle)
  30643. */
  30644. leftColor: Color3;
  30645. /**
  30646. * Define the color used on center
  30647. */
  30648. rightColor: Color3;
  30649. /**
  30650. * Define bias applied to computed fresnel term
  30651. */
  30652. bias: number;
  30653. /**
  30654. * Defined the power exponent applied to fresnel term
  30655. */
  30656. power: number;
  30657. /**
  30658. * Clones the current fresnel and its valuues
  30659. * @returns a clone fresnel configuration
  30660. */
  30661. clone(): FresnelParameters;
  30662. /**
  30663. * Serializes the current fresnel parameters to a JSON representation.
  30664. * @return the JSON serialization
  30665. */
  30666. serialize(): any;
  30667. /**
  30668. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30669. * @param parsedFresnelParameters Define the JSON representation
  30670. * @returns the parsed parameters
  30671. */
  30672. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30673. }
  30674. }
  30675. declare module "babylonjs/Misc/decorators" {
  30676. import { Nullable } from "babylonjs/types";
  30677. import { Scene } from "babylonjs/scene";
  30678. import { IAnimatable } from "babylonjs/Misc/tools";
  30679. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30680. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30681. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30682. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30683. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30684. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30685. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30686. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30687. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30688. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30689. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30690. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30691. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30692. /**
  30693. * Decorator used to define property that can be serialized as reference to a camera
  30694. * @param sourceName defines the name of the property to decorate
  30695. */
  30696. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30697. /**
  30698. * Class used to help serialization objects
  30699. */
  30700. export class SerializationHelper {
  30701. /** hidden */
  30702. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30703. /** hidden */
  30704. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30705. /** hidden */
  30706. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30707. /** hidden */
  30708. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30709. /**
  30710. * Appends the serialized animations from the source animations
  30711. * @param source Source containing the animations
  30712. * @param destination Target to store the animations
  30713. */
  30714. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30715. /**
  30716. * Static function used to serialized a specific entity
  30717. * @param entity defines the entity to serialize
  30718. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30719. * @returns a JSON compatible object representing the serialization of the entity
  30720. */
  30721. static Serialize<T>(entity: T, serializationObject?: any): any;
  30722. /**
  30723. * Creates a new entity from a serialization data object
  30724. * @param creationFunction defines a function used to instanciated the new entity
  30725. * @param source defines the source serialization data
  30726. * @param scene defines the hosting scene
  30727. * @param rootUrl defines the root url for resources
  30728. * @returns a new entity
  30729. */
  30730. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30731. /**
  30732. * Clones an object
  30733. * @param creationFunction defines the function used to instanciate the new object
  30734. * @param source defines the source object
  30735. * @returns the cloned object
  30736. */
  30737. static Clone<T>(creationFunction: () => T, source: T): T;
  30738. /**
  30739. * Instanciates a new object based on a source one (some data will be shared between both object)
  30740. * @param creationFunction defines the function used to instanciate the new object
  30741. * @param source defines the source object
  30742. * @returns the new object
  30743. */
  30744. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30745. }
  30746. }
  30747. declare module "babylonjs/Cameras/camera" {
  30748. import { SmartArray } from "babylonjs/Misc/smartArray";
  30749. import { Observable } from "babylonjs/Misc/observable";
  30750. import { Nullable } from "babylonjs/types";
  30751. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30752. import { Scene } from "babylonjs/scene";
  30753. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30754. import { Node } from "babylonjs/node";
  30755. import { Mesh } from "babylonjs/Meshes/mesh";
  30756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30757. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30758. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30759. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30760. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30761. import { Ray } from "babylonjs/Culling/ray";
  30762. /**
  30763. * This is the base class of all the camera used in the application.
  30764. * @see http://doc.babylonjs.com/features/cameras
  30765. */
  30766. export class Camera extends Node {
  30767. /** @hidden */
  30768. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30769. /**
  30770. * This is the default projection mode used by the cameras.
  30771. * It helps recreating a feeling of perspective and better appreciate depth.
  30772. * This is the best way to simulate real life cameras.
  30773. */
  30774. static readonly PERSPECTIVE_CAMERA: number;
  30775. /**
  30776. * This helps creating camera with an orthographic mode.
  30777. * 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.
  30778. */
  30779. static readonly ORTHOGRAPHIC_CAMERA: number;
  30780. /**
  30781. * This is the default FOV mode for perspective cameras.
  30782. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30783. */
  30784. static readonly FOVMODE_VERTICAL_FIXED: number;
  30785. /**
  30786. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30787. */
  30788. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30789. /**
  30790. * This specifies ther is no need for a camera rig.
  30791. * Basically only one eye is rendered corresponding to the camera.
  30792. */
  30793. static readonly RIG_MODE_NONE: number;
  30794. /**
  30795. * Simulates a camera Rig with one blue eye and one red eye.
  30796. * This can be use with 3d blue and red glasses.
  30797. */
  30798. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30799. /**
  30800. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30801. */
  30802. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30803. /**
  30804. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30805. */
  30806. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30807. /**
  30808. * Defines that both eyes of the camera will be rendered over under each other.
  30809. */
  30810. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30811. /**
  30812. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30813. */
  30814. static readonly RIG_MODE_VR: number;
  30815. /**
  30816. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30817. */
  30818. static readonly RIG_MODE_WEBVR: number;
  30819. /**
  30820. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30821. */
  30822. static readonly RIG_MODE_CUSTOM: number;
  30823. /**
  30824. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30825. */
  30826. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30827. /**
  30828. * Define the input manager associated with the camera.
  30829. */
  30830. inputs: CameraInputsManager<Camera>;
  30831. /** @hidden */
  30832. _position: Vector3;
  30833. /**
  30834. * Define the current local position of the camera in the scene
  30835. */
  30836. position: Vector3;
  30837. /**
  30838. * The vector the camera should consider as up.
  30839. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30840. */
  30841. upVector: Vector3;
  30842. /**
  30843. * Define the current limit on the left side for an orthographic camera
  30844. * In scene unit
  30845. */
  30846. orthoLeft: Nullable<number>;
  30847. /**
  30848. * Define the current limit on the right side for an orthographic camera
  30849. * In scene unit
  30850. */
  30851. orthoRight: Nullable<number>;
  30852. /**
  30853. * Define the current limit on the bottom side for an orthographic camera
  30854. * In scene unit
  30855. */
  30856. orthoBottom: Nullable<number>;
  30857. /**
  30858. * Define the current limit on the top side for an orthographic camera
  30859. * In scene unit
  30860. */
  30861. orthoTop: Nullable<number>;
  30862. /**
  30863. * Field Of View is set in Radians. (default is 0.8)
  30864. */
  30865. fov: number;
  30866. /**
  30867. * Define the minimum distance the camera can see from.
  30868. * This is important to note that the depth buffer are not infinite and the closer it starts
  30869. * the more your scene might encounter depth fighting issue.
  30870. */
  30871. minZ: number;
  30872. /**
  30873. * Define the maximum distance the camera can see to.
  30874. * This is important to note that the depth buffer are not infinite and the further it end
  30875. * the more your scene might encounter depth fighting issue.
  30876. */
  30877. maxZ: number;
  30878. /**
  30879. * Define the default inertia of the camera.
  30880. * This helps giving a smooth feeling to the camera movement.
  30881. */
  30882. inertia: number;
  30883. /**
  30884. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30885. */
  30886. mode: number;
  30887. /**
  30888. * Define wether the camera is intermediate.
  30889. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30890. */
  30891. isIntermediate: boolean;
  30892. /**
  30893. * Define the viewport of the camera.
  30894. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30895. */
  30896. viewport: Viewport;
  30897. /**
  30898. * Restricts the camera to viewing objects with the same layerMask.
  30899. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30900. */
  30901. layerMask: number;
  30902. /**
  30903. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30904. */
  30905. fovMode: number;
  30906. /**
  30907. * Rig mode of the camera.
  30908. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30909. * This is normally controlled byt the camera themselves as internal use.
  30910. */
  30911. cameraRigMode: number;
  30912. /**
  30913. * Defines the distance between both "eyes" in case of a RIG
  30914. */
  30915. interaxialDistance: number;
  30916. /**
  30917. * Defines if stereoscopic rendering is done side by side or over under.
  30918. */
  30919. isStereoscopicSideBySide: boolean;
  30920. /**
  30921. * 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
  30922. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30923. * else in the scene.
  30924. */
  30925. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30926. /**
  30927. * When set, the camera will render to this render target instead of the default canvas
  30928. */
  30929. outputRenderTarget: Nullable<RenderTargetTexture>;
  30930. /**
  30931. * Observable triggered when the camera view matrix has changed.
  30932. */
  30933. onViewMatrixChangedObservable: Observable<Camera>;
  30934. /**
  30935. * Observable triggered when the camera Projection matrix has changed.
  30936. */
  30937. onProjectionMatrixChangedObservable: Observable<Camera>;
  30938. /**
  30939. * Observable triggered when the inputs have been processed.
  30940. */
  30941. onAfterCheckInputsObservable: Observable<Camera>;
  30942. /**
  30943. * Observable triggered when reset has been called and applied to the camera.
  30944. */
  30945. onRestoreStateObservable: Observable<Camera>;
  30946. /** @hidden */
  30947. _cameraRigParams: any;
  30948. /** @hidden */
  30949. _rigCameras: Camera[];
  30950. /** @hidden */
  30951. _rigPostProcess: Nullable<PostProcess>;
  30952. protected _webvrViewMatrix: Matrix;
  30953. /** @hidden */
  30954. _skipRendering: boolean;
  30955. /** @hidden */
  30956. _projectionMatrix: Matrix;
  30957. /** @hidden */
  30958. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30959. /** @hidden */
  30960. _activeMeshes: SmartArray<AbstractMesh>;
  30961. protected _globalPosition: Vector3;
  30962. /** hidden */
  30963. _computedViewMatrix: Matrix;
  30964. private _doNotComputeProjectionMatrix;
  30965. private _transformMatrix;
  30966. private _frustumPlanes;
  30967. private _refreshFrustumPlanes;
  30968. private _storedFov;
  30969. private _stateStored;
  30970. /**
  30971. * Instantiates a new camera object.
  30972. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30973. * @see http://doc.babylonjs.com/features/cameras
  30974. * @param name Defines the name of the camera in the scene
  30975. * @param position Defines the position of the camera
  30976. * @param scene Defines the scene the camera belongs too
  30977. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30978. */
  30979. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30980. /**
  30981. * Store current camera state (fov, position, etc..)
  30982. * @returns the camera
  30983. */
  30984. storeState(): Camera;
  30985. /**
  30986. * Restores the camera state values if it has been stored. You must call storeState() first
  30987. */
  30988. protected _restoreStateValues(): boolean;
  30989. /**
  30990. * Restored camera state. You must call storeState() first.
  30991. * @returns true if restored and false otherwise
  30992. */
  30993. restoreState(): boolean;
  30994. /**
  30995. * Gets the class name of the camera.
  30996. * @returns the class name
  30997. */
  30998. getClassName(): string;
  30999. /** @hidden */
  31000. readonly _isCamera: boolean;
  31001. /**
  31002. * Gets a string representation of the camera useful for debug purpose.
  31003. * @param fullDetails Defines that a more verboe level of logging is required
  31004. * @returns the string representation
  31005. */
  31006. toString(fullDetails?: boolean): string;
  31007. /**
  31008. * Gets the current world space position of the camera.
  31009. */
  31010. readonly globalPosition: Vector3;
  31011. /**
  31012. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31013. * @returns the active meshe list
  31014. */
  31015. getActiveMeshes(): SmartArray<AbstractMesh>;
  31016. /**
  31017. * Check wether a mesh is part of the current active mesh list of the camera
  31018. * @param mesh Defines the mesh to check
  31019. * @returns true if active, false otherwise
  31020. */
  31021. isActiveMesh(mesh: Mesh): boolean;
  31022. /**
  31023. * Is this camera ready to be used/rendered
  31024. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31025. * @return true if the camera is ready
  31026. */
  31027. isReady(completeCheck?: boolean): boolean;
  31028. /** @hidden */
  31029. _initCache(): void;
  31030. /** @hidden */
  31031. _updateCache(ignoreParentClass?: boolean): void;
  31032. /** @hidden */
  31033. _isSynchronized(): boolean;
  31034. /** @hidden */
  31035. _isSynchronizedViewMatrix(): boolean;
  31036. /** @hidden */
  31037. _isSynchronizedProjectionMatrix(): boolean;
  31038. /**
  31039. * Attach the input controls to a specific dom element to get the input from.
  31040. * @param element Defines the element the controls should be listened from
  31041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31042. */
  31043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31044. /**
  31045. * Detach the current controls from the specified dom element.
  31046. * @param element Defines the element to stop listening the inputs from
  31047. */
  31048. detachControl(element: HTMLElement): void;
  31049. /**
  31050. * Update the camera state according to the different inputs gathered during the frame.
  31051. */
  31052. update(): void;
  31053. /** @hidden */
  31054. _checkInputs(): void;
  31055. /** @hidden */
  31056. readonly rigCameras: Camera[];
  31057. /**
  31058. * Gets the post process used by the rig cameras
  31059. */
  31060. readonly rigPostProcess: Nullable<PostProcess>;
  31061. /**
  31062. * Internal, gets the first post proces.
  31063. * @returns the first post process to be run on this camera.
  31064. */
  31065. _getFirstPostProcess(): Nullable<PostProcess>;
  31066. private _cascadePostProcessesToRigCams;
  31067. /**
  31068. * Attach a post process to the camera.
  31069. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31070. * @param postProcess The post process to attach to the camera
  31071. * @param insertAt The position of the post process in case several of them are in use in the scene
  31072. * @returns the position the post process has been inserted at
  31073. */
  31074. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31075. /**
  31076. * Detach a post process to the camera.
  31077. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31078. * @param postProcess The post process to detach from the camera
  31079. */
  31080. detachPostProcess(postProcess: PostProcess): void;
  31081. /**
  31082. * Gets the current world matrix of the camera
  31083. */
  31084. getWorldMatrix(): Matrix;
  31085. /** @hidden */
  31086. _getViewMatrix(): Matrix;
  31087. /**
  31088. * Gets the current view matrix of the camera.
  31089. * @param force forces the camera to recompute the matrix without looking at the cached state
  31090. * @returns the view matrix
  31091. */
  31092. getViewMatrix(force?: boolean): Matrix;
  31093. /**
  31094. * Freeze the projection matrix.
  31095. * It will prevent the cache check of the camera projection compute and can speed up perf
  31096. * if no parameter of the camera are meant to change
  31097. * @param projection Defines manually a projection if necessary
  31098. */
  31099. freezeProjectionMatrix(projection?: Matrix): void;
  31100. /**
  31101. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31102. */
  31103. unfreezeProjectionMatrix(): void;
  31104. /**
  31105. * Gets the current projection matrix of the camera.
  31106. * @param force forces the camera to recompute the matrix without looking at the cached state
  31107. * @returns the projection matrix
  31108. */
  31109. getProjectionMatrix(force?: boolean): Matrix;
  31110. /**
  31111. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31112. * @returns a Matrix
  31113. */
  31114. getTransformationMatrix(): Matrix;
  31115. private _updateFrustumPlanes;
  31116. /**
  31117. * Checks if a cullable object (mesh...) is in the camera frustum
  31118. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31119. * @param target The object to check
  31120. * @returns true if the object is in frustum otherwise false
  31121. */
  31122. isInFrustum(target: ICullable): boolean;
  31123. /**
  31124. * Checks if a cullable object (mesh...) is in the camera frustum
  31125. * Unlike isInFrustum this cheks the full bounding box
  31126. * @param target The object to check
  31127. * @returns true if the object is in frustum otherwise false
  31128. */
  31129. isCompletelyInFrustum(target: ICullable): boolean;
  31130. /**
  31131. * Gets a ray in the forward direction from the camera.
  31132. * @param length Defines the length of the ray to create
  31133. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31134. * @param origin Defines the start point of the ray which defaults to the camera position
  31135. * @returns the forward ray
  31136. */
  31137. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31138. /**
  31139. * Releases resources associated with this node.
  31140. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31141. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31142. */
  31143. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31144. /** @hidden */
  31145. _isLeftCamera: boolean;
  31146. /**
  31147. * Gets the left camera of a rig setup in case of Rigged Camera
  31148. */
  31149. readonly isLeftCamera: boolean;
  31150. /** @hidden */
  31151. _isRightCamera: boolean;
  31152. /**
  31153. * Gets the right camera of a rig setup in case of Rigged Camera
  31154. */
  31155. readonly isRightCamera: boolean;
  31156. /**
  31157. * Gets the left camera of a rig setup in case of Rigged Camera
  31158. */
  31159. readonly leftCamera: Nullable<FreeCamera>;
  31160. /**
  31161. * Gets the right camera of a rig setup in case of Rigged Camera
  31162. */
  31163. readonly rightCamera: Nullable<FreeCamera>;
  31164. /**
  31165. * Gets the left camera target of a rig setup in case of Rigged Camera
  31166. * @returns the target position
  31167. */
  31168. getLeftTarget(): Nullable<Vector3>;
  31169. /**
  31170. * Gets the right camera target of a rig setup in case of Rigged Camera
  31171. * @returns the target position
  31172. */
  31173. getRightTarget(): Nullable<Vector3>;
  31174. /**
  31175. * @hidden
  31176. */
  31177. setCameraRigMode(mode: number, rigParams: any): void;
  31178. /** @hidden */
  31179. static _setStereoscopicRigMode(camera: Camera): void;
  31180. /** @hidden */
  31181. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31182. /** @hidden */
  31183. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31184. /** @hidden */
  31185. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31186. /** @hidden */
  31187. _getVRProjectionMatrix(): Matrix;
  31188. protected _updateCameraRotationMatrix(): void;
  31189. protected _updateWebVRCameraRotationMatrix(): void;
  31190. /**
  31191. * This function MUST be overwritten by the different WebVR cameras available.
  31192. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31193. * @hidden
  31194. */
  31195. _getWebVRProjectionMatrix(): Matrix;
  31196. /**
  31197. * This function MUST be overwritten by the different WebVR cameras available.
  31198. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31199. * @hidden
  31200. */
  31201. _getWebVRViewMatrix(): Matrix;
  31202. /** @hidden */
  31203. setCameraRigParameter(name: string, value: any): void;
  31204. /**
  31205. * needs to be overridden by children so sub has required properties to be copied
  31206. * @hidden
  31207. */
  31208. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31209. /**
  31210. * May need to be overridden by children
  31211. * @hidden
  31212. */
  31213. _updateRigCameras(): void;
  31214. /** @hidden */
  31215. _setupInputs(): void;
  31216. /**
  31217. * Serialiaze the camera setup to a json represention
  31218. * @returns the JSON representation
  31219. */
  31220. serialize(): any;
  31221. /**
  31222. * Clones the current camera.
  31223. * @param name The cloned camera name
  31224. * @returns the cloned camera
  31225. */
  31226. clone(name: string): Camera;
  31227. /**
  31228. * Gets the direction of the camera relative to a given local axis.
  31229. * @param localAxis Defines the reference axis to provide a relative direction.
  31230. * @return the direction
  31231. */
  31232. getDirection(localAxis: Vector3): Vector3;
  31233. /**
  31234. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31235. * @param localAxis Defines the reference axis to provide a relative direction.
  31236. * @param result Defines the vector to store the result in
  31237. */
  31238. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31239. /**
  31240. * Gets a camera constructor for a given camera type
  31241. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31242. * @param name The name of the camera the result will be able to instantiate
  31243. * @param scene The scene the result will construct the camera in
  31244. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31245. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31246. * @returns a factory method to construc the camera
  31247. */
  31248. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31249. /**
  31250. * Compute the world matrix of the camera.
  31251. * @returns the camera workd matrix
  31252. */
  31253. computeWorldMatrix(): Matrix;
  31254. /**
  31255. * Parse a JSON and creates the camera from the parsed information
  31256. * @param parsedCamera The JSON to parse
  31257. * @param scene The scene to instantiate the camera in
  31258. * @returns the newly constructed camera
  31259. */
  31260. static Parse(parsedCamera: any, scene: Scene): Camera;
  31261. }
  31262. }
  31263. declare module "babylonjs/Misc/tools" {
  31264. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31265. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31266. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31267. import { Observable } from "babylonjs/Misc/observable";
  31268. import { DomManagement } from "babylonjs/Misc/domManagement";
  31269. import { WebRequest } from "babylonjs/Misc/webRequest";
  31270. import { Camera } from "babylonjs/Cameras/camera";
  31271. import { Engine } from "babylonjs/Engines/engine";
  31272. import { Animation } from "babylonjs/Animations/animation";
  31273. /**
  31274. * Interface for any object that can request an animation frame
  31275. */
  31276. export interface ICustomAnimationFrameRequester {
  31277. /**
  31278. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31279. */
  31280. renderFunction?: Function;
  31281. /**
  31282. * Called to request the next frame to render to
  31283. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31284. */
  31285. requestAnimationFrame: Function;
  31286. /**
  31287. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31288. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31289. */
  31290. requestID?: number;
  31291. }
  31292. /**
  31293. * Interface containing an array of animations
  31294. */
  31295. export interface IAnimatable {
  31296. /**
  31297. * Array of animations
  31298. */
  31299. animations: Array<Animation>;
  31300. }
  31301. /** Interface used by value gradients (color, factor, ...) */
  31302. export interface IValueGradient {
  31303. /**
  31304. * Gets or sets the gradient value (between 0 and 1)
  31305. */
  31306. gradient: number;
  31307. }
  31308. /** Class used to store color4 gradient */
  31309. export class ColorGradient implements IValueGradient {
  31310. /**
  31311. * Gets or sets the gradient value (between 0 and 1)
  31312. */
  31313. gradient: number;
  31314. /**
  31315. * Gets or sets first associated color
  31316. */
  31317. color1: Color4;
  31318. /**
  31319. * Gets or sets second associated color
  31320. */
  31321. color2?: Color4;
  31322. /**
  31323. * Will get a color picked randomly between color1 and color2.
  31324. * If color2 is undefined then color1 will be used
  31325. * @param result defines the target Color4 to store the result in
  31326. */
  31327. getColorToRef(result: Color4): void;
  31328. }
  31329. /** Class used to store color 3 gradient */
  31330. export class Color3Gradient implements IValueGradient {
  31331. /**
  31332. * Gets or sets the gradient value (between 0 and 1)
  31333. */
  31334. gradient: number;
  31335. /**
  31336. * Gets or sets the associated color
  31337. */
  31338. color: Color3;
  31339. }
  31340. /** Class used to store factor gradient */
  31341. export class FactorGradient implements IValueGradient {
  31342. /**
  31343. * Gets or sets the gradient value (between 0 and 1)
  31344. */
  31345. gradient: number;
  31346. /**
  31347. * Gets or sets first associated factor
  31348. */
  31349. factor1: number;
  31350. /**
  31351. * Gets or sets second associated factor
  31352. */
  31353. factor2?: number;
  31354. /**
  31355. * Will get a number picked randomly between factor1 and factor2.
  31356. * If factor2 is undefined then factor1 will be used
  31357. * @returns the picked number
  31358. */
  31359. getFactor(): number;
  31360. }
  31361. /**
  31362. * @ignore
  31363. * Application error to support additional information when loading a file
  31364. */
  31365. export class LoadFileError extends Error {
  31366. /** defines the optional web request */
  31367. request?: WebRequest | undefined;
  31368. private static _setPrototypeOf;
  31369. /**
  31370. * Creates a new LoadFileError
  31371. * @param message defines the message of the error
  31372. * @param request defines the optional web request
  31373. */
  31374. constructor(message: string,
  31375. /** defines the optional web request */
  31376. request?: WebRequest | undefined);
  31377. }
  31378. /**
  31379. * Class used to define a retry strategy when error happens while loading assets
  31380. */
  31381. export class RetryStrategy {
  31382. /**
  31383. * Function used to defines an exponential back off strategy
  31384. * @param maxRetries defines the maximum number of retries (3 by default)
  31385. * @param baseInterval defines the interval between retries
  31386. * @returns the strategy function to use
  31387. */
  31388. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31389. }
  31390. /**
  31391. * File request interface
  31392. */
  31393. export interface IFileRequest {
  31394. /**
  31395. * Raised when the request is complete (success or error).
  31396. */
  31397. onCompleteObservable: Observable<IFileRequest>;
  31398. /**
  31399. * Aborts the request for a file.
  31400. */
  31401. abort: () => void;
  31402. }
  31403. /**
  31404. * Class containing a set of static utilities functions
  31405. */
  31406. export class Tools {
  31407. /**
  31408. * Gets or sets the base URL to use to load assets
  31409. */
  31410. static BaseUrl: string;
  31411. /**
  31412. * Enable/Disable Custom HTTP Request Headers globally.
  31413. * default = false
  31414. * @see CustomRequestHeaders
  31415. */
  31416. static UseCustomRequestHeaders: boolean;
  31417. /**
  31418. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31419. * i.e. when loading files, where the server/service expects an Authorization header
  31420. */
  31421. static CustomRequestHeaders: {
  31422. [key: string]: string;
  31423. };
  31424. /**
  31425. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31426. */
  31427. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31428. /**
  31429. * Default behaviour for cors in the application.
  31430. * It can be a string if the expected behavior is identical in the entire app.
  31431. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31432. */
  31433. static CorsBehavior: string | ((url: string | string[]) => string);
  31434. /**
  31435. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31436. * @ignorenaming
  31437. */
  31438. static UseFallbackTexture: boolean;
  31439. /**
  31440. * Use this object to register external classes like custom textures or material
  31441. * to allow the laoders to instantiate them
  31442. */
  31443. static RegisteredExternalClasses: {
  31444. [key: string]: Object;
  31445. };
  31446. /**
  31447. * Texture content used if a texture cannot loaded
  31448. * @ignorenaming
  31449. */
  31450. static fallbackTexture: string;
  31451. /**
  31452. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31453. * @param u defines the coordinate on X axis
  31454. * @param v defines the coordinate on Y axis
  31455. * @param width defines the width of the source data
  31456. * @param height defines the height of the source data
  31457. * @param pixels defines the source byte array
  31458. * @param color defines the output color
  31459. */
  31460. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31461. /**
  31462. * Interpolates between a and b via alpha
  31463. * @param a The lower value (returned when alpha = 0)
  31464. * @param b The upper value (returned when alpha = 1)
  31465. * @param alpha The interpolation-factor
  31466. * @return The mixed value
  31467. */
  31468. static Mix(a: number, b: number, alpha: number): number;
  31469. /**
  31470. * Tries to instantiate a new object from a given class name
  31471. * @param className defines the class name to instantiate
  31472. * @returns the new object or null if the system was not able to do the instantiation
  31473. */
  31474. static Instantiate(className: string): any;
  31475. /**
  31476. * Provides a slice function that will work even on IE
  31477. * @param data defines the array to slice
  31478. * @param start defines the start of the data (optional)
  31479. * @param end defines the end of the data (optional)
  31480. * @returns the new sliced array
  31481. */
  31482. static Slice<T>(data: T, start?: number, end?: number): T;
  31483. /**
  31484. * Polyfill for setImmediate
  31485. * @param action defines the action to execute after the current execution block
  31486. */
  31487. static SetImmediate(action: () => void): void;
  31488. /**
  31489. * Function indicating if a number is an exponent of 2
  31490. * @param value defines the value to test
  31491. * @returns true if the value is an exponent of 2
  31492. */
  31493. static IsExponentOfTwo(value: number): boolean;
  31494. private static _tmpFloatArray;
  31495. /**
  31496. * Returns the nearest 32-bit single precision float representation of a Number
  31497. * @param value A Number. If the parameter is of a different type, it will get converted
  31498. * to a number or to NaN if it cannot be converted
  31499. * @returns number
  31500. */
  31501. static FloatRound(value: number): number;
  31502. /**
  31503. * Find the next highest power of two.
  31504. * @param x Number to start search from.
  31505. * @return Next highest power of two.
  31506. */
  31507. static CeilingPOT(x: number): number;
  31508. /**
  31509. * Find the next lowest power of two.
  31510. * @param x Number to start search from.
  31511. * @return Next lowest power of two.
  31512. */
  31513. static FloorPOT(x: number): number;
  31514. /**
  31515. * Find the nearest power of two.
  31516. * @param x Number to start search from.
  31517. * @return Next nearest power of two.
  31518. */
  31519. static NearestPOT(x: number): number;
  31520. /**
  31521. * Get the closest exponent of two
  31522. * @param value defines the value to approximate
  31523. * @param max defines the maximum value to return
  31524. * @param mode defines how to define the closest value
  31525. * @returns closest exponent of two of the given value
  31526. */
  31527. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31528. /**
  31529. * Extracts the filename from a path
  31530. * @param path defines the path to use
  31531. * @returns the filename
  31532. */
  31533. static GetFilename(path: string): string;
  31534. /**
  31535. * Extracts the "folder" part of a path (everything before the filename).
  31536. * @param uri The URI to extract the info from
  31537. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31538. * @returns The "folder" part of the path
  31539. */
  31540. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31541. /**
  31542. * Extracts text content from a DOM element hierarchy
  31543. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31544. */
  31545. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31546. /**
  31547. * Convert an angle in radians to degrees
  31548. * @param angle defines the angle to convert
  31549. * @returns the angle in degrees
  31550. */
  31551. static ToDegrees(angle: number): number;
  31552. /**
  31553. * Convert an angle in degrees to radians
  31554. * @param angle defines the angle to convert
  31555. * @returns the angle in radians
  31556. */
  31557. static ToRadians(angle: number): number;
  31558. /**
  31559. * Encode a buffer to a base64 string
  31560. * @param buffer defines the buffer to encode
  31561. * @returns the encoded string
  31562. */
  31563. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31564. /**
  31565. * Extracts minimum and maximum values from a list of indexed positions
  31566. * @param positions defines the positions to use
  31567. * @param indices defines the indices to the positions
  31568. * @param indexStart defines the start index
  31569. * @param indexCount defines the end index
  31570. * @param bias defines bias value to add to the result
  31571. * @return minimum and maximum values
  31572. */
  31573. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31574. minimum: Vector3;
  31575. maximum: Vector3;
  31576. };
  31577. /**
  31578. * Extracts minimum and maximum values from a list of positions
  31579. * @param positions defines the positions to use
  31580. * @param start defines the start index in the positions array
  31581. * @param count defines the number of positions to handle
  31582. * @param bias defines bias value to add to the result
  31583. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31584. * @return minimum and maximum values
  31585. */
  31586. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31587. minimum: Vector3;
  31588. maximum: Vector3;
  31589. };
  31590. /**
  31591. * Returns an array if obj is not an array
  31592. * @param obj defines the object to evaluate as an array
  31593. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31594. * @returns either obj directly if obj is an array or a new array containing obj
  31595. */
  31596. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31597. /**
  31598. * Gets the pointer prefix to use
  31599. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31600. */
  31601. static GetPointerPrefix(): string;
  31602. /**
  31603. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31604. * @param func - the function to be called
  31605. * @param requester - the object that will request the next frame. Falls back to window.
  31606. * @returns frame number
  31607. */
  31608. static QueueNewFrame(func: () => void, requester?: any): number;
  31609. /**
  31610. * Ask the browser to promote the current element to fullscreen rendering mode
  31611. * @param element defines the DOM element to promote
  31612. */
  31613. static RequestFullscreen(element: HTMLElement): void;
  31614. /**
  31615. * Asks the browser to exit fullscreen mode
  31616. */
  31617. static ExitFullscreen(): void;
  31618. /**
  31619. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31620. * @param url define the url we are trying
  31621. * @param element define the dom element where to configure the cors policy
  31622. */
  31623. static SetCorsBehavior(url: string | string[], element: {
  31624. crossOrigin: string | null;
  31625. }): void;
  31626. /**
  31627. * Removes unwanted characters from an url
  31628. * @param url defines the url to clean
  31629. * @returns the cleaned url
  31630. */
  31631. static CleanUrl(url: string): string;
  31632. /**
  31633. * Gets or sets a function used to pre-process url before using them to load assets
  31634. */
  31635. static PreprocessUrl: (url: string) => string;
  31636. /**
  31637. * Loads an image as an HTMLImageElement.
  31638. * @param input url string, ArrayBuffer, or Blob to load
  31639. * @param onLoad callback called when the image successfully loads
  31640. * @param onError callback called when the image fails to load
  31641. * @param offlineProvider offline provider for caching
  31642. * @returns the HTMLImageElement of the loaded image
  31643. */
  31644. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31645. /**
  31646. * Loads a file
  31647. * @param url url string, ArrayBuffer, or Blob to load
  31648. * @param onSuccess callback called when the file successfully loads
  31649. * @param onProgress callback called while file is loading (if the server supports this mode)
  31650. * @param offlineProvider defines the offline provider for caching
  31651. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31652. * @param onError callback called when the file fails to load
  31653. * @returns a file request object
  31654. */
  31655. 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;
  31656. /**
  31657. * Load a script (identified by an url). When the url returns, the
  31658. * content of this file is added into a new script element, attached to the DOM (body element)
  31659. * @param scriptUrl defines the url of the script to laod
  31660. * @param onSuccess defines the callback called when the script is loaded
  31661. * @param onError defines the callback to call if an error occurs
  31662. * @param scriptId defines the id of the script element
  31663. */
  31664. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31665. /**
  31666. * Load an asynchronous script (identified by an url). When the url returns, the
  31667. * content of this file is added into a new script element, attached to the DOM (body element)
  31668. * @param scriptUrl defines the url of the script to laod
  31669. * @param scriptId defines the id of the script element
  31670. * @returns a promise request object
  31671. */
  31672. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31673. /**
  31674. * Loads a file from a blob
  31675. * @param fileToLoad defines the blob to use
  31676. * @param callback defines the callback to call when data is loaded
  31677. * @param progressCallback defines the callback to call during loading process
  31678. * @returns a file request object
  31679. */
  31680. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31681. /**
  31682. * Loads a file
  31683. * @param fileToLoad defines the file to load
  31684. * @param callback defines the callback to call when data is loaded
  31685. * @param progressCallBack defines the callback to call during loading process
  31686. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31687. * @returns a file request object
  31688. */
  31689. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31690. /**
  31691. * Creates a data url from a given string content
  31692. * @param content defines the content to convert
  31693. * @returns the new data url link
  31694. */
  31695. static FileAsURL(content: string): string;
  31696. /**
  31697. * Format the given number to a specific decimal format
  31698. * @param value defines the number to format
  31699. * @param decimals defines the number of decimals to use
  31700. * @returns the formatted string
  31701. */
  31702. static Format(value: number, decimals?: number): string;
  31703. /**
  31704. * Checks if a given vector is inside a specific range
  31705. * @param v defines the vector to test
  31706. * @param min defines the minimum range
  31707. * @param max defines the maximum range
  31708. */
  31709. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31710. /**
  31711. * Tries to copy an object by duplicating every property
  31712. * @param source defines the source object
  31713. * @param destination defines the target object
  31714. * @param doNotCopyList defines a list of properties to avoid
  31715. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31716. */
  31717. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31718. /**
  31719. * Gets a boolean indicating if the given object has no own property
  31720. * @param obj defines the object to test
  31721. * @returns true if object has no own property
  31722. */
  31723. static IsEmpty(obj: any): boolean;
  31724. /**
  31725. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31726. * @param str Source string
  31727. * @param suffix Suffix to search for in the source string
  31728. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31729. */
  31730. static EndsWith(str: string, suffix: string): boolean;
  31731. /**
  31732. * Function used to register events at window level
  31733. * @param events defines the events to register
  31734. */
  31735. static RegisterTopRootEvents(events: {
  31736. name: string;
  31737. handler: Nullable<(e: FocusEvent) => any>;
  31738. }[]): void;
  31739. /**
  31740. * Function used to unregister events from window level
  31741. * @param events defines the events to unregister
  31742. */
  31743. static UnregisterTopRootEvents(events: {
  31744. name: string;
  31745. handler: Nullable<(e: FocusEvent) => any>;
  31746. }[]): void;
  31747. /**
  31748. * @ignore
  31749. */
  31750. static _ScreenshotCanvas: HTMLCanvasElement;
  31751. /**
  31752. * Dumps the current bound framebuffer
  31753. * @param width defines the rendering width
  31754. * @param height defines the rendering height
  31755. * @param engine defines the hosting engine
  31756. * @param successCallback defines the callback triggered once the data are available
  31757. * @param mimeType defines the mime type of the result
  31758. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31759. */
  31760. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31761. /**
  31762. * Converts the canvas data to blob.
  31763. * This acts as a polyfill for browsers not supporting the to blob function.
  31764. * @param canvas Defines the canvas to extract the data from
  31765. * @param successCallback Defines the callback triggered once the data are available
  31766. * @param mimeType Defines the mime type of the result
  31767. */
  31768. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31769. /**
  31770. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31771. * @param successCallback defines the callback triggered once the data are available
  31772. * @param mimeType defines the mime type of the result
  31773. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31774. */
  31775. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31776. /**
  31777. * Downloads a blob in the browser
  31778. * @param blob defines the blob to download
  31779. * @param fileName defines the name of the downloaded file
  31780. */
  31781. static Download(blob: Blob, fileName: string): void;
  31782. /**
  31783. * Captures a screenshot of the current rendering
  31784. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31785. * @param engine defines the rendering engine
  31786. * @param camera defines the source camera
  31787. * @param size This parameter can be set to a single number or to an object with the
  31788. * following (optional) properties: precision, width, height. If a single number is passed,
  31789. * it will be used for both width and height. If an object is passed, the screenshot size
  31790. * will be derived from the parameters. The precision property is a multiplier allowing
  31791. * rendering at a higher or lower resolution
  31792. * @param successCallback defines the callback receives a single parameter which contains the
  31793. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31794. * src parameter of an <img> to display it
  31795. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31796. * Check your browser for supported MIME types
  31797. */
  31798. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31799. /**
  31800. * Generates an image screenshot from the specified camera.
  31801. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31802. * @param engine The engine to use for rendering
  31803. * @param camera The camera to use for rendering
  31804. * @param size This parameter can be set to a single number or to an object with the
  31805. * following (optional) properties: precision, width, height. If a single number is passed,
  31806. * it will be used for both width and height. If an object is passed, the screenshot size
  31807. * will be derived from the parameters. The precision property is a multiplier allowing
  31808. * rendering at a higher or lower resolution
  31809. * @param successCallback The callback receives a single parameter which contains the
  31810. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31811. * src parameter of an <img> to display it
  31812. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31813. * Check your browser for supported MIME types
  31814. * @param samples Texture samples (default: 1)
  31815. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31816. * @param fileName A name for for the downloaded file.
  31817. */
  31818. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31819. /**
  31820. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31821. * Be aware Math.random() could cause collisions, but:
  31822. * "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"
  31823. * @returns a pseudo random id
  31824. */
  31825. static RandomId(): string;
  31826. /**
  31827. * Test if the given uri is a base64 string
  31828. * @param uri The uri to test
  31829. * @return True if the uri is a base64 string or false otherwise
  31830. */
  31831. static IsBase64(uri: string): boolean;
  31832. /**
  31833. * Decode the given base64 uri.
  31834. * @param uri The uri to decode
  31835. * @return The decoded base64 data.
  31836. */
  31837. static DecodeBase64(uri: string): ArrayBuffer;
  31838. /**
  31839. * Gets the absolute url.
  31840. * @param url the input url
  31841. * @return the absolute url
  31842. */
  31843. static GetAbsoluteUrl(url: string): string;
  31844. /**
  31845. * No log
  31846. */
  31847. static readonly NoneLogLevel: number;
  31848. /**
  31849. * Only message logs
  31850. */
  31851. static readonly MessageLogLevel: number;
  31852. /**
  31853. * Only warning logs
  31854. */
  31855. static readonly WarningLogLevel: number;
  31856. /**
  31857. * Only error logs
  31858. */
  31859. static readonly ErrorLogLevel: number;
  31860. /**
  31861. * All logs
  31862. */
  31863. static readonly AllLogLevel: number;
  31864. /**
  31865. * Gets a value indicating the number of loading errors
  31866. * @ignorenaming
  31867. */
  31868. static readonly errorsCount: number;
  31869. /**
  31870. * Callback called when a new log is added
  31871. */
  31872. static OnNewCacheEntry: (entry: string) => void;
  31873. /**
  31874. * Log a message to the console
  31875. * @param message defines the message to log
  31876. */
  31877. static Log(message: string): void;
  31878. /**
  31879. * Write a warning message to the console
  31880. * @param message defines the message to log
  31881. */
  31882. static Warn(message: string): void;
  31883. /**
  31884. * Write an error message to the console
  31885. * @param message defines the message to log
  31886. */
  31887. static Error(message: string): void;
  31888. /**
  31889. * Gets current log cache (list of logs)
  31890. */
  31891. static readonly LogCache: string;
  31892. /**
  31893. * Clears the log cache
  31894. */
  31895. static ClearLogCache(): void;
  31896. /**
  31897. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31898. */
  31899. static LogLevels: number;
  31900. /**
  31901. * Checks if the loaded document was accessed via `file:`-Protocol.
  31902. * @returns boolean
  31903. */
  31904. static IsFileURL(): boolean;
  31905. /**
  31906. * Checks if the window object exists
  31907. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31908. */
  31909. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31910. /**
  31911. * No performance log
  31912. */
  31913. static readonly PerformanceNoneLogLevel: number;
  31914. /**
  31915. * Use user marks to log performance
  31916. */
  31917. static readonly PerformanceUserMarkLogLevel: number;
  31918. /**
  31919. * Log performance to the console
  31920. */
  31921. static readonly PerformanceConsoleLogLevel: number;
  31922. private static _performance;
  31923. /**
  31924. * Sets the current performance log level
  31925. */
  31926. static PerformanceLogLevel: number;
  31927. private static _StartPerformanceCounterDisabled;
  31928. private static _EndPerformanceCounterDisabled;
  31929. private static _StartUserMark;
  31930. private static _EndUserMark;
  31931. private static _StartPerformanceConsole;
  31932. private static _EndPerformanceConsole;
  31933. /**
  31934. * Starts a performance counter
  31935. */
  31936. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31937. /**
  31938. * Ends a specific performance coutner
  31939. */
  31940. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31941. /**
  31942. * Gets either window.performance.now() if supported or Date.now() else
  31943. */
  31944. static readonly Now: number;
  31945. /**
  31946. * This method will return the name of the class used to create the instance of the given object.
  31947. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31948. * @param object the object to get the class name from
  31949. * @param isType defines if the object is actually a type
  31950. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31951. */
  31952. static GetClassName(object: any, isType?: boolean): string;
  31953. /**
  31954. * Gets the first element of an array satisfying a given predicate
  31955. * @param array defines the array to browse
  31956. * @param predicate defines the predicate to use
  31957. * @returns null if not found or the element
  31958. */
  31959. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31960. /**
  31961. * This method will return the name of the full name of the class, including its owning module (if any).
  31962. * 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).
  31963. * @param object the object to get the class name from
  31964. * @param isType defines if the object is actually a type
  31965. * @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.
  31966. * @ignorenaming
  31967. */
  31968. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31969. /**
  31970. * Returns a promise that resolves after the given amount of time.
  31971. * @param delay Number of milliseconds to delay
  31972. * @returns Promise that resolves after the given amount of time
  31973. */
  31974. static DelayAsync(delay: number): Promise<void>;
  31975. /**
  31976. * Gets the current gradient from an array of IValueGradient
  31977. * @param ratio defines the current ratio to get
  31978. * @param gradients defines the array of IValueGradient
  31979. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31980. */
  31981. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31982. }
  31983. /**
  31984. * This class is used to track a performance counter which is number based.
  31985. * The user has access to many properties which give statistics of different nature.
  31986. *
  31987. * The implementer can track two kinds of Performance Counter: time and count.
  31988. * 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.
  31989. * 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.
  31990. */
  31991. export class PerfCounter {
  31992. /**
  31993. * Gets or sets a global boolean to turn on and off all the counters
  31994. */
  31995. static Enabled: boolean;
  31996. /**
  31997. * Returns the smallest value ever
  31998. */
  31999. readonly min: number;
  32000. /**
  32001. * Returns the biggest value ever
  32002. */
  32003. readonly max: number;
  32004. /**
  32005. * Returns the average value since the performance counter is running
  32006. */
  32007. readonly average: number;
  32008. /**
  32009. * Returns the average value of the last second the counter was monitored
  32010. */
  32011. readonly lastSecAverage: number;
  32012. /**
  32013. * Returns the current value
  32014. */
  32015. readonly current: number;
  32016. /**
  32017. * Gets the accumulated total
  32018. */
  32019. readonly total: number;
  32020. /**
  32021. * Gets the total value count
  32022. */
  32023. readonly count: number;
  32024. /**
  32025. * Creates a new counter
  32026. */
  32027. constructor();
  32028. /**
  32029. * Call this method to start monitoring a new frame.
  32030. * 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.
  32031. */
  32032. fetchNewFrame(): void;
  32033. /**
  32034. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32035. * @param newCount the count value to add to the monitored count
  32036. * @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.
  32037. */
  32038. addCount(newCount: number, fetchResult: boolean): void;
  32039. /**
  32040. * Start monitoring this performance counter
  32041. */
  32042. beginMonitoring(): void;
  32043. /**
  32044. * Compute the time lapsed since the previous beginMonitoring() call.
  32045. * @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
  32046. */
  32047. endMonitoring(newFrame?: boolean): void;
  32048. private _fetchResult;
  32049. private _startMonitoringTime;
  32050. private _min;
  32051. private _max;
  32052. private _average;
  32053. private _current;
  32054. private _totalValueCount;
  32055. private _totalAccumulated;
  32056. private _lastSecAverage;
  32057. private _lastSecAccumulated;
  32058. private _lastSecTime;
  32059. private _lastSecValueCount;
  32060. }
  32061. /**
  32062. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32063. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32064. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32065. * @param name The name of the class, case should be preserved
  32066. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32067. */
  32068. export function className(name: string, module?: string): (target: Object) => void;
  32069. /**
  32070. * An implementation of a loop for asynchronous functions.
  32071. */
  32072. export class AsyncLoop {
  32073. /**
  32074. * Defines the number of iterations for the loop
  32075. */
  32076. iterations: number;
  32077. /**
  32078. * Defines the current index of the loop.
  32079. */
  32080. index: number;
  32081. private _done;
  32082. private _fn;
  32083. private _successCallback;
  32084. /**
  32085. * Constructor.
  32086. * @param iterations the number of iterations.
  32087. * @param func the function to run each iteration
  32088. * @param successCallback the callback that will be called upon succesful execution
  32089. * @param offset starting offset.
  32090. */
  32091. constructor(
  32092. /**
  32093. * Defines the number of iterations for the loop
  32094. */
  32095. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32096. /**
  32097. * Execute the next iteration. Must be called after the last iteration was finished.
  32098. */
  32099. executeNext(): void;
  32100. /**
  32101. * Break the loop and run the success callback.
  32102. */
  32103. breakLoop(): void;
  32104. /**
  32105. * Create and run an async loop.
  32106. * @param iterations the number of iterations.
  32107. * @param fn the function to run each iteration
  32108. * @param successCallback the callback that will be called upon succesful execution
  32109. * @param offset starting offset.
  32110. * @returns the created async loop object
  32111. */
  32112. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32113. /**
  32114. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32115. * @param iterations total number of iterations
  32116. * @param syncedIterations number of synchronous iterations in each async iteration.
  32117. * @param fn the function to call each iteration.
  32118. * @param callback a success call back that will be called when iterating stops.
  32119. * @param breakFunction a break condition (optional)
  32120. * @param timeout timeout settings for the setTimeout function. default - 0.
  32121. * @returns the created async loop object
  32122. */
  32123. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32124. }
  32125. }
  32126. declare module "babylonjs/Collisions/collisionCoordinator" {
  32127. import { Nullable } from "babylonjs/types";
  32128. import { Scene } from "babylonjs/scene";
  32129. import { Vector3 } from "babylonjs/Maths/math";
  32130. import { Collider } from "babylonjs/Collisions/collider";
  32131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32132. /** @hidden */
  32133. export interface ICollisionCoordinator {
  32134. createCollider(): Collider;
  32135. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32136. init(scene: Scene): void;
  32137. }
  32138. /** @hidden */
  32139. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32140. private _scene;
  32141. private _scaledPosition;
  32142. private _scaledVelocity;
  32143. private _finalPosition;
  32144. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32145. createCollider(): Collider;
  32146. init(scene: Scene): void;
  32147. private _collideWithWorld;
  32148. }
  32149. }
  32150. declare module "babylonjs/Animations/animationGroup" {
  32151. import { Animatable } from "babylonjs/Animations/animatable";
  32152. import { Animation } from "babylonjs/Animations/animation";
  32153. import { Scene, IDisposable } from "babylonjs/scene";
  32154. import { Observable } from "babylonjs/Misc/observable";
  32155. import { Nullable } from "babylonjs/types";
  32156. /**
  32157. * This class defines the direct association between an animation and a target
  32158. */
  32159. export class TargetedAnimation {
  32160. /**
  32161. * Animation to perform
  32162. */
  32163. animation: Animation;
  32164. /**
  32165. * Target to animate
  32166. */
  32167. target: any;
  32168. }
  32169. /**
  32170. * Use this class to create coordinated animations on multiple targets
  32171. */
  32172. export class AnimationGroup implements IDisposable {
  32173. /** The name of the animation group */
  32174. name: string;
  32175. private _scene;
  32176. private _targetedAnimations;
  32177. private _animatables;
  32178. private _from;
  32179. private _to;
  32180. private _isStarted;
  32181. private _isPaused;
  32182. private _speedRatio;
  32183. /**
  32184. * Gets or sets the unique id of the node
  32185. */
  32186. uniqueId: number;
  32187. /**
  32188. * This observable will notify when one animation have ended
  32189. */
  32190. onAnimationEndObservable: Observable<TargetedAnimation>;
  32191. /**
  32192. * Observer raised when one animation loops
  32193. */
  32194. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32195. /**
  32196. * This observable will notify when all animations have ended.
  32197. */
  32198. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32199. /**
  32200. * This observable will notify when all animations have paused.
  32201. */
  32202. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32203. /**
  32204. * This observable will notify when all animations are playing.
  32205. */
  32206. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32207. /**
  32208. * Gets the first frame
  32209. */
  32210. readonly from: number;
  32211. /**
  32212. * Gets the last frame
  32213. */
  32214. readonly to: number;
  32215. /**
  32216. * Define if the animations are started
  32217. */
  32218. readonly isStarted: boolean;
  32219. /**
  32220. * Gets a value indicating that the current group is playing
  32221. */
  32222. readonly isPlaying: boolean;
  32223. /**
  32224. * Gets or sets the speed ratio to use for all animations
  32225. */
  32226. /**
  32227. * Gets or sets the speed ratio to use for all animations
  32228. */
  32229. speedRatio: number;
  32230. /**
  32231. * Gets the targeted animations for this animation group
  32232. */
  32233. readonly targetedAnimations: Array<TargetedAnimation>;
  32234. /**
  32235. * returning the list of animatables controlled by this animation group.
  32236. */
  32237. readonly animatables: Array<Animatable>;
  32238. /**
  32239. * Instantiates a new Animation Group.
  32240. * This helps managing several animations at once.
  32241. * @see http://doc.babylonjs.com/how_to/group
  32242. * @param name Defines the name of the group
  32243. * @param scene Defines the scene the group belongs to
  32244. */
  32245. constructor(
  32246. /** The name of the animation group */
  32247. name: string, scene?: Nullable<Scene>);
  32248. /**
  32249. * Add an animation (with its target) in the group
  32250. * @param animation defines the animation we want to add
  32251. * @param target defines the target of the animation
  32252. * @returns the TargetedAnimation object
  32253. */
  32254. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32255. /**
  32256. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32257. * It can add constant keys at begin or end
  32258. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32259. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32260. * @returns the animation group
  32261. */
  32262. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32263. /**
  32264. * Start all animations on given targets
  32265. * @param loop defines if animations must loop
  32266. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32267. * @param from defines the from key (optional)
  32268. * @param to defines the to key (optional)
  32269. * @returns the current animation group
  32270. */
  32271. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32272. /**
  32273. * Pause all animations
  32274. * @returns the animation group
  32275. */
  32276. pause(): AnimationGroup;
  32277. /**
  32278. * Play all animations to initial state
  32279. * This function will start() the animations if they were not started or will restart() them if they were paused
  32280. * @param loop defines if animations must loop
  32281. * @returns the animation group
  32282. */
  32283. play(loop?: boolean): AnimationGroup;
  32284. /**
  32285. * Reset all animations to initial state
  32286. * @returns the animation group
  32287. */
  32288. reset(): AnimationGroup;
  32289. /**
  32290. * Restart animations from key 0
  32291. * @returns the animation group
  32292. */
  32293. restart(): AnimationGroup;
  32294. /**
  32295. * Stop all animations
  32296. * @returns the animation group
  32297. */
  32298. stop(): AnimationGroup;
  32299. /**
  32300. * Set animation weight for all animatables
  32301. * @param weight defines the weight to use
  32302. * @return the animationGroup
  32303. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32304. */
  32305. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32306. /**
  32307. * Synchronize and normalize all animatables with a source animatable
  32308. * @param root defines the root animatable to synchronize with
  32309. * @return the animationGroup
  32310. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32311. */
  32312. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32313. /**
  32314. * Goes to a specific frame in this animation group
  32315. * @param frame the frame number to go to
  32316. * @return the animationGroup
  32317. */
  32318. goToFrame(frame: number): AnimationGroup;
  32319. /**
  32320. * Dispose all associated resources
  32321. */
  32322. dispose(): void;
  32323. private _checkAnimationGroupEnded;
  32324. /**
  32325. * Clone the current animation group and returns a copy
  32326. * @param newName defines the name of the new group
  32327. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32328. * @returns the new aniamtion group
  32329. */
  32330. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32331. /**
  32332. * Returns a new AnimationGroup object parsed from the source provided.
  32333. * @param parsedAnimationGroup defines the source
  32334. * @param scene defines the scene that will receive the animationGroup
  32335. * @returns a new AnimationGroup
  32336. */
  32337. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32338. /**
  32339. * Returns the string "AnimationGroup"
  32340. * @returns "AnimationGroup"
  32341. */
  32342. getClassName(): string;
  32343. /**
  32344. * Creates a detailled string about the object
  32345. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32346. * @returns a string representing the object
  32347. */
  32348. toString(fullDetails?: boolean): string;
  32349. }
  32350. }
  32351. declare module "babylonjs/scene" {
  32352. import { Nullable } from "babylonjs/types";
  32353. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32354. import { Observable } from "babylonjs/Misc/observable";
  32355. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32356. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32357. import { Geometry } from "babylonjs/Meshes/geometry";
  32358. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32359. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32361. import { Mesh } from "babylonjs/Meshes/mesh";
  32362. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32363. import { Bone } from "babylonjs/Bones/bone";
  32364. import { Skeleton } from "babylonjs/Bones/skeleton";
  32365. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32366. import { Camera } from "babylonjs/Cameras/camera";
  32367. import { AbstractScene } from "babylonjs/abstractScene";
  32368. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32369. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32370. import { Material } from "babylonjs/Materials/material";
  32371. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32372. import { Effect } from "babylonjs/Materials/effect";
  32373. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32374. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32375. import { Light } from "babylonjs/Lights/light";
  32376. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32377. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32378. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32379. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32380. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32381. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32382. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32383. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32384. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32385. import { Engine } from "babylonjs/Engines/engine";
  32386. import { Node } from "babylonjs/node";
  32387. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32388. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32389. import { WebRequest } from "babylonjs/Misc/webRequest";
  32390. import { Ray } from "babylonjs/Culling/ray";
  32391. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32392. import { Animation } from "babylonjs/Animations/animation";
  32393. import { Animatable } from "babylonjs/Animations/animatable";
  32394. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32395. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32396. import { Collider } from "babylonjs/Collisions/collider";
  32397. /**
  32398. * Define an interface for all classes that will hold resources
  32399. */
  32400. export interface IDisposable {
  32401. /**
  32402. * Releases all held resources
  32403. */
  32404. dispose(): void;
  32405. }
  32406. /** Interface defining initialization parameters for Scene class */
  32407. export interface SceneOptions {
  32408. /**
  32409. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32410. * It will improve performance when the number of geometries becomes important.
  32411. */
  32412. useGeometryUniqueIdsMap?: boolean;
  32413. /**
  32414. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32415. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32416. */
  32417. useMaterialMeshMap?: boolean;
  32418. /**
  32419. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32420. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32421. */
  32422. useClonedMeshhMap?: boolean;
  32423. }
  32424. /**
  32425. * Represents a scene to be rendered by the engine.
  32426. * @see http://doc.babylonjs.com/features/scene
  32427. */
  32428. export class Scene extends AbstractScene implements IAnimatable {
  32429. private static _uniqueIdCounter;
  32430. /** The fog is deactivated */
  32431. static readonly FOGMODE_NONE: number;
  32432. /** The fog density is following an exponential function */
  32433. static readonly FOGMODE_EXP: number;
  32434. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32435. static readonly FOGMODE_EXP2: number;
  32436. /** The fog density is following a linear function. */
  32437. static readonly FOGMODE_LINEAR: number;
  32438. /**
  32439. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32440. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32441. */
  32442. static MinDeltaTime: number;
  32443. /**
  32444. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32445. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32446. */
  32447. static MaxDeltaTime: number;
  32448. /**
  32449. * Factory used to create the default material.
  32450. * @param name The name of the material to create
  32451. * @param scene The scene to create the material for
  32452. * @returns The default material
  32453. */
  32454. static DefaultMaterialFactory(scene: Scene): Material;
  32455. /**
  32456. * Factory used to create the a collision coordinator.
  32457. * @returns The collision coordinator
  32458. */
  32459. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32460. /** @hidden */
  32461. readonly _isScene: boolean;
  32462. /**
  32463. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32464. */
  32465. autoClear: boolean;
  32466. /**
  32467. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32468. */
  32469. autoClearDepthAndStencil: boolean;
  32470. /**
  32471. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32472. */
  32473. clearColor: Color4;
  32474. /**
  32475. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32476. */
  32477. ambientColor: Color3;
  32478. /**
  32479. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32480. * It should only be one of the following (if not the default embedded one):
  32481. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32482. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32483. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32484. * The material properties need to be setup according to the type of texture in use.
  32485. */
  32486. environmentBRDFTexture: BaseTexture;
  32487. /** @hidden */
  32488. protected _environmentTexture: Nullable<BaseTexture>;
  32489. /**
  32490. * Texture used in all pbr material as the reflection texture.
  32491. * As in the majority of the scene they are the same (exception for multi room and so on),
  32492. * this is easier to reference from here than from all the materials.
  32493. */
  32494. /**
  32495. * Texture used in all pbr material as the reflection texture.
  32496. * As in the majority of the scene they are the same (exception for multi room and so on),
  32497. * this is easier to set here than in all the materials.
  32498. */
  32499. environmentTexture: Nullable<BaseTexture>;
  32500. /** @hidden */
  32501. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32502. /**
  32503. * Default image processing configuration used either in the rendering
  32504. * Forward main pass or through the imageProcessingPostProcess if present.
  32505. * As in the majority of the scene they are the same (exception for multi camera),
  32506. * this is easier to reference from here than from all the materials and post process.
  32507. *
  32508. * No setter as we it is a shared configuration, you can set the values instead.
  32509. */
  32510. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32511. private _forceWireframe;
  32512. /**
  32513. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32514. */
  32515. forceWireframe: boolean;
  32516. private _forcePointsCloud;
  32517. /**
  32518. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32519. */
  32520. forcePointsCloud: boolean;
  32521. /**
  32522. * Gets or sets the active clipplane 1
  32523. */
  32524. clipPlane: Nullable<Plane>;
  32525. /**
  32526. * Gets or sets the active clipplane 2
  32527. */
  32528. clipPlane2: Nullable<Plane>;
  32529. /**
  32530. * Gets or sets the active clipplane 3
  32531. */
  32532. clipPlane3: Nullable<Plane>;
  32533. /**
  32534. * Gets or sets the active clipplane 4
  32535. */
  32536. clipPlane4: Nullable<Plane>;
  32537. /**
  32538. * Gets or sets a boolean indicating if animations are enabled
  32539. */
  32540. animationsEnabled: boolean;
  32541. private _animationPropertiesOverride;
  32542. /**
  32543. * Gets or sets the animation properties override
  32544. */
  32545. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32546. /**
  32547. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32548. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32549. */
  32550. useConstantAnimationDeltaTime: boolean;
  32551. /**
  32552. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32553. * Please note that it requires to run a ray cast through the scene on every frame
  32554. */
  32555. constantlyUpdateMeshUnderPointer: boolean;
  32556. /**
  32557. * Defines the HTML cursor to use when hovering over interactive elements
  32558. */
  32559. hoverCursor: string;
  32560. /**
  32561. * Defines the HTML default cursor to use (empty by default)
  32562. */
  32563. defaultCursor: string;
  32564. /**
  32565. * This is used to call preventDefault() on pointer down
  32566. * in order to block unwanted artifacts like system double clicks
  32567. */
  32568. preventDefaultOnPointerDown: boolean;
  32569. /**
  32570. * This is used to call preventDefault() on pointer up
  32571. * in order to block unwanted artifacts like system double clicks
  32572. */
  32573. preventDefaultOnPointerUp: boolean;
  32574. /**
  32575. * Gets or sets user defined metadata
  32576. */
  32577. metadata: any;
  32578. /**
  32579. * For internal use only. Please do not use.
  32580. */
  32581. reservedDataStore: any;
  32582. /**
  32583. * Gets the name of the plugin used to load this scene (null by default)
  32584. */
  32585. loadingPluginName: string;
  32586. /**
  32587. * Use this array to add regular expressions used to disable offline support for specific urls
  32588. */
  32589. disableOfflineSupportExceptionRules: RegExp[];
  32590. /**
  32591. * An event triggered when the scene is disposed.
  32592. */
  32593. onDisposeObservable: Observable<Scene>;
  32594. private _onDisposeObserver;
  32595. /** Sets a function to be executed when this scene is disposed. */
  32596. onDispose: () => void;
  32597. /**
  32598. * An event triggered before rendering the scene (right after animations and physics)
  32599. */
  32600. onBeforeRenderObservable: Observable<Scene>;
  32601. private _onBeforeRenderObserver;
  32602. /** Sets a function to be executed before rendering this scene */
  32603. beforeRender: Nullable<() => void>;
  32604. /**
  32605. * An event triggered after rendering the scene
  32606. */
  32607. onAfterRenderObservable: Observable<Scene>;
  32608. private _onAfterRenderObserver;
  32609. /** Sets a function to be executed after rendering this scene */
  32610. afterRender: Nullable<() => void>;
  32611. /**
  32612. * An event triggered before animating the scene
  32613. */
  32614. onBeforeAnimationsObservable: Observable<Scene>;
  32615. /**
  32616. * An event triggered after animations processing
  32617. */
  32618. onAfterAnimationsObservable: Observable<Scene>;
  32619. /**
  32620. * An event triggered before draw calls are ready to be sent
  32621. */
  32622. onBeforeDrawPhaseObservable: Observable<Scene>;
  32623. /**
  32624. * An event triggered after draw calls have been sent
  32625. */
  32626. onAfterDrawPhaseObservable: Observable<Scene>;
  32627. /**
  32628. * An event triggered when the scene is ready
  32629. */
  32630. onReadyObservable: Observable<Scene>;
  32631. /**
  32632. * An event triggered before rendering a camera
  32633. */
  32634. onBeforeCameraRenderObservable: Observable<Camera>;
  32635. private _onBeforeCameraRenderObserver;
  32636. /** Sets a function to be executed before rendering a camera*/
  32637. beforeCameraRender: () => void;
  32638. /**
  32639. * An event triggered after rendering a camera
  32640. */
  32641. onAfterCameraRenderObservable: Observable<Camera>;
  32642. private _onAfterCameraRenderObserver;
  32643. /** Sets a function to be executed after rendering a camera*/
  32644. afterCameraRender: () => void;
  32645. /**
  32646. * An event triggered when active meshes evaluation is about to start
  32647. */
  32648. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32649. /**
  32650. * An event triggered when active meshes evaluation is done
  32651. */
  32652. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32653. /**
  32654. * An event triggered when particles rendering is about to start
  32655. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32656. */
  32657. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32658. /**
  32659. * An event triggered when particles rendering is done
  32660. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32661. */
  32662. onAfterParticlesRenderingObservable: Observable<Scene>;
  32663. /**
  32664. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32665. */
  32666. onDataLoadedObservable: Observable<Scene>;
  32667. /**
  32668. * An event triggered when a camera is created
  32669. */
  32670. onNewCameraAddedObservable: Observable<Camera>;
  32671. /**
  32672. * An event triggered when a camera is removed
  32673. */
  32674. onCameraRemovedObservable: Observable<Camera>;
  32675. /**
  32676. * An event triggered when a light is created
  32677. */
  32678. onNewLightAddedObservable: Observable<Light>;
  32679. /**
  32680. * An event triggered when a light is removed
  32681. */
  32682. onLightRemovedObservable: Observable<Light>;
  32683. /**
  32684. * An event triggered when a geometry is created
  32685. */
  32686. onNewGeometryAddedObservable: Observable<Geometry>;
  32687. /**
  32688. * An event triggered when a geometry is removed
  32689. */
  32690. onGeometryRemovedObservable: Observable<Geometry>;
  32691. /**
  32692. * An event triggered when a transform node is created
  32693. */
  32694. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32695. /**
  32696. * An event triggered when a transform node is removed
  32697. */
  32698. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32699. /**
  32700. * An event triggered when a mesh is created
  32701. */
  32702. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32703. /**
  32704. * An event triggered when a mesh is removed
  32705. */
  32706. onMeshRemovedObservable: Observable<AbstractMesh>;
  32707. /**
  32708. * An event triggered when a skeleton is created
  32709. */
  32710. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32711. /**
  32712. * An event triggered when a skeleton is removed
  32713. */
  32714. onSkeletonRemovedObservable: Observable<Skeleton>;
  32715. /**
  32716. * An event triggered when a material is created
  32717. */
  32718. onNewMaterialAddedObservable: Observable<Material>;
  32719. /**
  32720. * An event triggered when a material is removed
  32721. */
  32722. onMaterialRemovedObservable: Observable<Material>;
  32723. /**
  32724. * An event triggered when a texture is created
  32725. */
  32726. onNewTextureAddedObservable: Observable<BaseTexture>;
  32727. /**
  32728. * An event triggered when a texture is removed
  32729. */
  32730. onTextureRemovedObservable: Observable<BaseTexture>;
  32731. /**
  32732. * An event triggered when render targets are about to be rendered
  32733. * Can happen multiple times per frame.
  32734. */
  32735. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32736. /**
  32737. * An event triggered when render targets were rendered.
  32738. * Can happen multiple times per frame.
  32739. */
  32740. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32741. /**
  32742. * An event triggered before calculating deterministic simulation step
  32743. */
  32744. onBeforeStepObservable: Observable<Scene>;
  32745. /**
  32746. * An event triggered after calculating deterministic simulation step
  32747. */
  32748. onAfterStepObservable: Observable<Scene>;
  32749. /**
  32750. * An event triggered when the activeCamera property is updated
  32751. */
  32752. onActiveCameraChanged: Observable<Scene>;
  32753. /**
  32754. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32755. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32756. * 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)
  32757. */
  32758. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32759. /**
  32760. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32761. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32762. * 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)
  32763. */
  32764. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32765. /**
  32766. * This Observable will when a mesh has been imported into the scene.
  32767. */
  32768. onMeshImportedObservable: Observable<AbstractMesh>;
  32769. /**
  32770. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32771. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32772. */
  32773. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32774. /** @hidden */
  32775. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32776. /**
  32777. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32778. */
  32779. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32780. /**
  32781. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32782. */
  32783. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32784. /**
  32785. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32786. */
  32787. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32788. private _onPointerMove;
  32789. private _onPointerDown;
  32790. private _onPointerUp;
  32791. /** Callback called when a pointer move is detected */
  32792. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32793. /** Callback called when a pointer down is detected */
  32794. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32795. /** Callback called when a pointer up is detected */
  32796. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32797. /** Callback called when a pointer pick is detected */
  32798. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32799. /**
  32800. * 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).
  32801. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32802. */
  32803. onPrePointerObservable: Observable<PointerInfoPre>;
  32804. /**
  32805. * Observable event triggered each time an input event is received from the rendering canvas
  32806. */
  32807. onPointerObservable: Observable<PointerInfo>;
  32808. /**
  32809. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32810. */
  32811. readonly unTranslatedPointer: Vector2;
  32812. /** The distance in pixel that you have to move to prevent some events */
  32813. static DragMovementThreshold: number;
  32814. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32815. static LongPressDelay: number;
  32816. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32817. static DoubleClickDelay: number;
  32818. /** If you need to check double click without raising a single click at first click, enable this flag */
  32819. static ExclusiveDoubleClickMode: boolean;
  32820. private _initClickEvent;
  32821. private _initActionManager;
  32822. private _delayedSimpleClick;
  32823. private _delayedSimpleClickTimeout;
  32824. private _previousDelayedSimpleClickTimeout;
  32825. private _meshPickProceed;
  32826. private _previousButtonPressed;
  32827. private _currentPickResult;
  32828. private _previousPickResult;
  32829. private _totalPointersPressed;
  32830. private _doubleClickOccured;
  32831. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32832. cameraToUseForPointers: Nullable<Camera>;
  32833. private _pointerX;
  32834. private _pointerY;
  32835. private _unTranslatedPointerX;
  32836. private _unTranslatedPointerY;
  32837. private _startingPointerPosition;
  32838. private _previousStartingPointerPosition;
  32839. private _startingPointerTime;
  32840. private _previousStartingPointerTime;
  32841. private _pointerCaptures;
  32842. private _timeAccumulator;
  32843. private _currentStepId;
  32844. private _currentInternalStep;
  32845. /** @hidden */
  32846. _mirroredCameraPosition: Nullable<Vector3>;
  32847. /**
  32848. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32849. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32850. */
  32851. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32852. /**
  32853. * Observable event triggered each time an keyboard event is received from the hosting window
  32854. */
  32855. onKeyboardObservable: Observable<KeyboardInfo>;
  32856. private _onKeyDown;
  32857. private _onKeyUp;
  32858. private _onCanvasFocusObserver;
  32859. private _onCanvasBlurObserver;
  32860. private _useRightHandedSystem;
  32861. /**
  32862. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32863. */
  32864. useRightHandedSystem: boolean;
  32865. /**
  32866. * Sets the step Id used by deterministic lock step
  32867. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32868. * @param newStepId defines the step Id
  32869. */
  32870. setStepId(newStepId: number): void;
  32871. /**
  32872. * Gets the step Id used by deterministic lock step
  32873. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32874. * @returns the step Id
  32875. */
  32876. getStepId(): number;
  32877. /**
  32878. * Gets the internal step used by deterministic lock step
  32879. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32880. * @returns the internal step
  32881. */
  32882. getInternalStep(): number;
  32883. private _fogEnabled;
  32884. /**
  32885. * Gets or sets a boolean indicating if fog is enabled on this scene
  32886. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32887. * (Default is true)
  32888. */
  32889. fogEnabled: boolean;
  32890. private _fogMode;
  32891. /**
  32892. * Gets or sets the fog mode to use
  32893. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32894. * | mode | value |
  32895. * | --- | --- |
  32896. * | FOGMODE_NONE | 0 |
  32897. * | FOGMODE_EXP | 1 |
  32898. * | FOGMODE_EXP2 | 2 |
  32899. * | FOGMODE_LINEAR | 3 |
  32900. */
  32901. fogMode: number;
  32902. /**
  32903. * Gets or sets the fog color to use
  32904. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32905. * (Default is Color3(0.2, 0.2, 0.3))
  32906. */
  32907. fogColor: Color3;
  32908. /**
  32909. * Gets or sets the fog density to use
  32910. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32911. * (Default is 0.1)
  32912. */
  32913. fogDensity: number;
  32914. /**
  32915. * Gets or sets the fog start distance to use
  32916. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32917. * (Default is 0)
  32918. */
  32919. fogStart: number;
  32920. /**
  32921. * Gets or sets the fog end distance to use
  32922. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32923. * (Default is 1000)
  32924. */
  32925. fogEnd: number;
  32926. private _shadowsEnabled;
  32927. /**
  32928. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32929. */
  32930. shadowsEnabled: boolean;
  32931. private _lightsEnabled;
  32932. /**
  32933. * Gets or sets a boolean indicating if lights are enabled on this scene
  32934. */
  32935. lightsEnabled: boolean;
  32936. /** All of the active cameras added to this scene. */
  32937. activeCameras: Camera[];
  32938. /** @hidden */
  32939. _activeCamera: Nullable<Camera>;
  32940. /** Gets or sets the current active camera */
  32941. activeCamera: Nullable<Camera>;
  32942. private _defaultMaterial;
  32943. /** The default material used on meshes when no material is affected */
  32944. /** The default material used on meshes when no material is affected */
  32945. defaultMaterial: Material;
  32946. private _texturesEnabled;
  32947. /**
  32948. * Gets or sets a boolean indicating if textures are enabled on this scene
  32949. */
  32950. texturesEnabled: boolean;
  32951. /**
  32952. * Gets or sets a boolean indicating if particles are enabled on this scene
  32953. */
  32954. particlesEnabled: boolean;
  32955. /**
  32956. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32957. */
  32958. spritesEnabled: boolean;
  32959. private _skeletonsEnabled;
  32960. /**
  32961. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32962. */
  32963. skeletonsEnabled: boolean;
  32964. /**
  32965. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32966. */
  32967. lensFlaresEnabled: boolean;
  32968. /**
  32969. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32970. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32971. */
  32972. collisionsEnabled: boolean;
  32973. private _collisionCoordinator;
  32974. /** @hidden */
  32975. readonly collisionCoordinator: ICollisionCoordinator;
  32976. /**
  32977. * Defines the gravity applied to this scene (used only for collisions)
  32978. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32979. */
  32980. gravity: Vector3;
  32981. /**
  32982. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32983. */
  32984. postProcessesEnabled: boolean;
  32985. /**
  32986. * The list of postprocesses added to the scene
  32987. */
  32988. postProcesses: PostProcess[];
  32989. /**
  32990. * Gets the current postprocess manager
  32991. */
  32992. postProcessManager: PostProcessManager;
  32993. /**
  32994. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32995. */
  32996. renderTargetsEnabled: boolean;
  32997. /**
  32998. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32999. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33000. */
  33001. dumpNextRenderTargets: boolean;
  33002. /**
  33003. * The list of user defined render targets added to the scene
  33004. */
  33005. customRenderTargets: RenderTargetTexture[];
  33006. /**
  33007. * Defines if texture loading must be delayed
  33008. * If true, textures will only be loaded when they need to be rendered
  33009. */
  33010. useDelayedTextureLoading: boolean;
  33011. /**
  33012. * Gets the list of meshes imported to the scene through SceneLoader
  33013. */
  33014. importedMeshesFiles: String[];
  33015. /**
  33016. * Gets or sets a boolean indicating if probes are enabled on this scene
  33017. */
  33018. probesEnabled: boolean;
  33019. /**
  33020. * Gets or sets the current offline provider to use to store scene data
  33021. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33022. */
  33023. offlineProvider: IOfflineProvider;
  33024. /**
  33025. * Gets or sets the action manager associated with the scene
  33026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33027. */
  33028. actionManager: AbstractActionManager;
  33029. private _meshesForIntersections;
  33030. /**
  33031. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33032. */
  33033. proceduralTexturesEnabled: boolean;
  33034. private _engine;
  33035. private _totalVertices;
  33036. /** @hidden */
  33037. _activeIndices: PerfCounter;
  33038. /** @hidden */
  33039. _activeParticles: PerfCounter;
  33040. /** @hidden */
  33041. _activeBones: PerfCounter;
  33042. private _animationRatio;
  33043. /** @hidden */
  33044. _animationTimeLast: number;
  33045. /** @hidden */
  33046. _animationTime: number;
  33047. /**
  33048. * Gets or sets a general scale for animation speed
  33049. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33050. */
  33051. animationTimeScale: number;
  33052. /** @hidden */
  33053. _cachedMaterial: Nullable<Material>;
  33054. /** @hidden */
  33055. _cachedEffect: Nullable<Effect>;
  33056. /** @hidden */
  33057. _cachedVisibility: Nullable<number>;
  33058. private _renderId;
  33059. private _frameId;
  33060. private _executeWhenReadyTimeoutId;
  33061. private _intermediateRendering;
  33062. private _viewUpdateFlag;
  33063. private _projectionUpdateFlag;
  33064. /** @hidden */
  33065. _toBeDisposed: Nullable<IDisposable>[];
  33066. private _activeRequests;
  33067. /** @hidden */
  33068. _pendingData: any[];
  33069. private _isDisposed;
  33070. /**
  33071. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33072. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33073. */
  33074. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33075. private _activeMeshes;
  33076. private _processedMaterials;
  33077. private _renderTargets;
  33078. /** @hidden */
  33079. _activeParticleSystems: SmartArray<IParticleSystem>;
  33080. private _activeSkeletons;
  33081. private _softwareSkinnedMeshes;
  33082. private _renderingManager;
  33083. /** @hidden */
  33084. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33085. private _transformMatrix;
  33086. private _sceneUbo;
  33087. /** @hidden */
  33088. _viewMatrix: Matrix;
  33089. private _projectionMatrix;
  33090. private _wheelEventName;
  33091. /** @hidden */
  33092. _forcedViewPosition: Nullable<Vector3>;
  33093. /** @hidden */
  33094. _frustumPlanes: Plane[];
  33095. /**
  33096. * Gets the list of frustum planes (built from the active camera)
  33097. */
  33098. readonly frustumPlanes: Plane[];
  33099. /**
  33100. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33101. * This is useful if there are more lights that the maximum simulteanous authorized
  33102. */
  33103. requireLightSorting: boolean;
  33104. /** @hidden */
  33105. readonly useMaterialMeshMap: boolean;
  33106. /** @hidden */
  33107. readonly useClonedMeshhMap: boolean;
  33108. private _pointerOverMesh;
  33109. private _pickedDownMesh;
  33110. private _pickedUpMesh;
  33111. private _externalData;
  33112. private _uid;
  33113. /**
  33114. * @hidden
  33115. * Backing store of defined scene components.
  33116. */
  33117. _components: ISceneComponent[];
  33118. /**
  33119. * @hidden
  33120. * Backing store of defined scene components.
  33121. */
  33122. _serializableComponents: ISceneSerializableComponent[];
  33123. /**
  33124. * List of components to register on the next registration step.
  33125. */
  33126. private _transientComponents;
  33127. /**
  33128. * Registers the transient components if needed.
  33129. */
  33130. private _registerTransientComponents;
  33131. /**
  33132. * @hidden
  33133. * Add a component to the scene.
  33134. * Note that the ccomponent could be registered on th next frame if this is called after
  33135. * the register component stage.
  33136. * @param component Defines the component to add to the scene
  33137. */
  33138. _addComponent(component: ISceneComponent): void;
  33139. /**
  33140. * @hidden
  33141. * Gets a component from the scene.
  33142. * @param name defines the name of the component to retrieve
  33143. * @returns the component or null if not present
  33144. */
  33145. _getComponent(name: string): Nullable<ISceneComponent>;
  33146. /**
  33147. * @hidden
  33148. * Defines the actions happening before camera updates.
  33149. */
  33150. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33151. /**
  33152. * @hidden
  33153. * Defines the actions happening before clear the canvas.
  33154. */
  33155. _beforeClearStage: Stage<SimpleStageAction>;
  33156. /**
  33157. * @hidden
  33158. * Defines the actions when collecting render targets for the frame.
  33159. */
  33160. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33161. /**
  33162. * @hidden
  33163. * Defines the actions happening for one camera in the frame.
  33164. */
  33165. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33166. /**
  33167. * @hidden
  33168. * Defines the actions happening during the per mesh ready checks.
  33169. */
  33170. _isReadyForMeshStage: Stage<MeshStageAction>;
  33171. /**
  33172. * @hidden
  33173. * Defines the actions happening before evaluate active mesh checks.
  33174. */
  33175. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33176. /**
  33177. * @hidden
  33178. * Defines the actions happening during the evaluate sub mesh checks.
  33179. */
  33180. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33181. /**
  33182. * @hidden
  33183. * Defines the actions happening during the active mesh stage.
  33184. */
  33185. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33186. /**
  33187. * @hidden
  33188. * Defines the actions happening during the per camera render target step.
  33189. */
  33190. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  33191. /**
  33192. * @hidden
  33193. * Defines the actions happening just before the active camera is drawing.
  33194. */
  33195. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33196. /**
  33197. * @hidden
  33198. * Defines the actions happening just before a render target is drawing.
  33199. */
  33200. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33201. /**
  33202. * @hidden
  33203. * Defines the actions happening just before a rendering group is drawing.
  33204. */
  33205. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33206. /**
  33207. * @hidden
  33208. * Defines the actions happening just before a mesh is drawing.
  33209. */
  33210. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33211. /**
  33212. * @hidden
  33213. * Defines the actions happening just after a mesh has been drawn.
  33214. */
  33215. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33216. /**
  33217. * @hidden
  33218. * Defines the actions happening just after a rendering group has been drawn.
  33219. */
  33220. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33221. /**
  33222. * @hidden
  33223. * Defines the actions happening just after the active camera has been drawn.
  33224. */
  33225. _afterCameraDrawStage: Stage<CameraStageAction>;
  33226. /**
  33227. * @hidden
  33228. * Defines the actions happening just after a render target has been drawn.
  33229. */
  33230. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33231. /**
  33232. * @hidden
  33233. * Defines the actions happening just after rendering all cameras and computing intersections.
  33234. */
  33235. _afterRenderStage: Stage<SimpleStageAction>;
  33236. /**
  33237. * @hidden
  33238. * Defines the actions happening when a pointer move event happens.
  33239. */
  33240. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33241. /**
  33242. * @hidden
  33243. * Defines the actions happening when a pointer down event happens.
  33244. */
  33245. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33246. /**
  33247. * @hidden
  33248. * Defines the actions happening when a pointer up event happens.
  33249. */
  33250. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33251. /**
  33252. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33253. */
  33254. private geometriesByUniqueId;
  33255. /**
  33256. * Creates a new Scene
  33257. * @param engine defines the engine to use to render this scene
  33258. * @param options defines the scene options
  33259. */
  33260. constructor(engine: Engine, options?: SceneOptions);
  33261. /**
  33262. * Gets a string idenfifying the name of the class
  33263. * @returns "Scene" string
  33264. */
  33265. getClassName(): string;
  33266. private _defaultMeshCandidates;
  33267. /**
  33268. * @hidden
  33269. */
  33270. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33271. private _defaultSubMeshCandidates;
  33272. /**
  33273. * @hidden
  33274. */
  33275. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33276. /**
  33277. * Sets the default candidate providers for the scene.
  33278. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33279. * and getCollidingSubMeshCandidates to their default function
  33280. */
  33281. setDefaultCandidateProviders(): void;
  33282. /**
  33283. * Gets the mesh that is currently under the pointer
  33284. */
  33285. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33286. /**
  33287. * Gets or sets the current on-screen X position of the pointer
  33288. */
  33289. pointerX: number;
  33290. /**
  33291. * Gets or sets the current on-screen Y position of the pointer
  33292. */
  33293. pointerY: number;
  33294. /**
  33295. * Gets the cached material (ie. the latest rendered one)
  33296. * @returns the cached material
  33297. */
  33298. getCachedMaterial(): Nullable<Material>;
  33299. /**
  33300. * Gets the cached effect (ie. the latest rendered one)
  33301. * @returns the cached effect
  33302. */
  33303. getCachedEffect(): Nullable<Effect>;
  33304. /**
  33305. * Gets the cached visibility state (ie. the latest rendered one)
  33306. * @returns the cached visibility state
  33307. */
  33308. getCachedVisibility(): Nullable<number>;
  33309. /**
  33310. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33311. * @param material defines the current material
  33312. * @param effect defines the current effect
  33313. * @param visibility defines the current visibility state
  33314. * @returns true if one parameter is not cached
  33315. */
  33316. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33317. /**
  33318. * Gets the engine associated with the scene
  33319. * @returns an Engine
  33320. */
  33321. getEngine(): Engine;
  33322. /**
  33323. * Gets the total number of vertices rendered per frame
  33324. * @returns the total number of vertices rendered per frame
  33325. */
  33326. getTotalVertices(): number;
  33327. /**
  33328. * Gets the performance counter for total vertices
  33329. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33330. */
  33331. readonly totalVerticesPerfCounter: PerfCounter;
  33332. /**
  33333. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33334. * @returns the total number of active indices rendered per frame
  33335. */
  33336. getActiveIndices(): number;
  33337. /**
  33338. * Gets the performance counter for active indices
  33339. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33340. */
  33341. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33342. /**
  33343. * Gets the total number of active particles rendered per frame
  33344. * @returns the total number of active particles rendered per frame
  33345. */
  33346. getActiveParticles(): number;
  33347. /**
  33348. * Gets the performance counter for active particles
  33349. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33350. */
  33351. readonly activeParticlesPerfCounter: PerfCounter;
  33352. /**
  33353. * Gets the total number of active bones rendered per frame
  33354. * @returns the total number of active bones rendered per frame
  33355. */
  33356. getActiveBones(): number;
  33357. /**
  33358. * Gets the performance counter for active bones
  33359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33360. */
  33361. readonly activeBonesPerfCounter: PerfCounter;
  33362. /**
  33363. * Gets the array of active meshes
  33364. * @returns an array of AbstractMesh
  33365. */
  33366. getActiveMeshes(): SmartArray<AbstractMesh>;
  33367. /**
  33368. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33369. * @returns a number
  33370. */
  33371. getAnimationRatio(): number;
  33372. /**
  33373. * Gets an unique Id for the current render phase
  33374. * @returns a number
  33375. */
  33376. getRenderId(): number;
  33377. /**
  33378. * Gets an unique Id for the current frame
  33379. * @returns a number
  33380. */
  33381. getFrameId(): number;
  33382. /** Call this function if you want to manually increment the render Id*/
  33383. incrementRenderId(): void;
  33384. private _updatePointerPosition;
  33385. private _createUbo;
  33386. private _setRayOnPointerInfo;
  33387. /**
  33388. * Use this method to simulate a pointer move on a mesh
  33389. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33390. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33391. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33392. * @returns the current scene
  33393. */
  33394. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33395. private _processPointerMove;
  33396. private _checkPrePointerObservable;
  33397. /**
  33398. * Use this method to simulate a pointer down on a mesh
  33399. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33400. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33401. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33402. * @returns the current scene
  33403. */
  33404. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33405. private _processPointerDown;
  33406. /**
  33407. * Use this method to simulate a pointer up on a mesh
  33408. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33409. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33410. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33411. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33412. * @returns the current scene
  33413. */
  33414. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33415. private _processPointerUp;
  33416. /**
  33417. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33418. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33419. * @returns true if the pointer was captured
  33420. */
  33421. isPointerCaptured(pointerId?: number): boolean;
  33422. /** @hidden */
  33423. _isPointerSwiping(): boolean;
  33424. /**
  33425. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33426. * @param attachUp defines if you want to attach events to pointerup
  33427. * @param attachDown defines if you want to attach events to pointerdown
  33428. * @param attachMove defines if you want to attach events to pointermove
  33429. */
  33430. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33431. /** Detaches all event handlers*/
  33432. detachControl(): void;
  33433. /**
  33434. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33435. * Delay loaded resources are not taking in account
  33436. * @return true if all required resources are ready
  33437. */
  33438. isReady(): boolean;
  33439. /** Resets all cached information relative to material (including effect and visibility) */
  33440. resetCachedMaterial(): void;
  33441. /**
  33442. * Registers a function to be called before every frame render
  33443. * @param func defines the function to register
  33444. */
  33445. registerBeforeRender(func: () => void): void;
  33446. /**
  33447. * Unregisters a function called before every frame render
  33448. * @param func defines the function to unregister
  33449. */
  33450. unregisterBeforeRender(func: () => void): void;
  33451. /**
  33452. * Registers a function to be called after every frame render
  33453. * @param func defines the function to register
  33454. */
  33455. registerAfterRender(func: () => void): void;
  33456. /**
  33457. * Unregisters a function called after every frame render
  33458. * @param func defines the function to unregister
  33459. */
  33460. unregisterAfterRender(func: () => void): void;
  33461. private _executeOnceBeforeRender;
  33462. /**
  33463. * The provided function will run before render once and will be disposed afterwards.
  33464. * A timeout delay can be provided so that the function will be executed in N ms.
  33465. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33466. * @param func The function to be executed.
  33467. * @param timeout optional delay in ms
  33468. */
  33469. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33470. /** @hidden */
  33471. _addPendingData(data: any): void;
  33472. /** @hidden */
  33473. _removePendingData(data: any): void;
  33474. /**
  33475. * Returns the number of items waiting to be loaded
  33476. * @returns the number of items waiting to be loaded
  33477. */
  33478. getWaitingItemsCount(): number;
  33479. /**
  33480. * Returns a boolean indicating if the scene is still loading data
  33481. */
  33482. readonly isLoading: boolean;
  33483. /**
  33484. * Registers a function to be executed when the scene is ready
  33485. * @param {Function} func - the function to be executed
  33486. */
  33487. executeWhenReady(func: () => void): void;
  33488. /**
  33489. * Returns a promise that resolves when the scene is ready
  33490. * @returns A promise that resolves when the scene is ready
  33491. */
  33492. whenReadyAsync(): Promise<void>;
  33493. /** @hidden */
  33494. _checkIsReady(): void;
  33495. /**
  33496. * Gets all animatable attached to the scene
  33497. */
  33498. readonly animatables: Animatable[];
  33499. /**
  33500. * Resets the last animation time frame.
  33501. * Useful to override when animations start running when loading a scene for the first time.
  33502. */
  33503. resetLastAnimationTimeFrame(): void;
  33504. /**
  33505. * Gets the current view matrix
  33506. * @returns a Matrix
  33507. */
  33508. getViewMatrix(): Matrix;
  33509. /**
  33510. * Gets the current projection matrix
  33511. * @returns a Matrix
  33512. */
  33513. getProjectionMatrix(): Matrix;
  33514. /**
  33515. * Gets the current transform matrix
  33516. * @returns a Matrix made of View * Projection
  33517. */
  33518. getTransformMatrix(): Matrix;
  33519. /**
  33520. * Sets the current transform matrix
  33521. * @param viewL defines the View matrix to use
  33522. * @param projectionL defines the Projection matrix to use
  33523. * @param viewR defines the right View matrix to use (if provided)
  33524. * @param projectionR defines the right Projection matrix to use (if provided)
  33525. */
  33526. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33527. /**
  33528. * Gets the uniform buffer used to store scene data
  33529. * @returns a UniformBuffer
  33530. */
  33531. getSceneUniformBuffer(): UniformBuffer;
  33532. /**
  33533. * Gets an unique (relatively to the current scene) Id
  33534. * @returns an unique number for the scene
  33535. */
  33536. getUniqueId(): number;
  33537. /**
  33538. * Add a mesh to the list of scene's meshes
  33539. * @param newMesh defines the mesh to add
  33540. * @param recursive if all child meshes should also be added to the scene
  33541. */
  33542. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33543. /**
  33544. * Remove a mesh for the list of scene's meshes
  33545. * @param toRemove defines the mesh to remove
  33546. * @param recursive if all child meshes should also be removed from the scene
  33547. * @returns the index where the mesh was in the mesh list
  33548. */
  33549. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33550. /**
  33551. * Add a transform node to the list of scene's transform nodes
  33552. * @param newTransformNode defines the transform node to add
  33553. */
  33554. addTransformNode(newTransformNode: TransformNode): void;
  33555. /**
  33556. * Remove a transform node for the list of scene's transform nodes
  33557. * @param toRemove defines the transform node to remove
  33558. * @returns the index where the transform node was in the transform node list
  33559. */
  33560. removeTransformNode(toRemove: TransformNode): number;
  33561. /**
  33562. * Remove a skeleton for the list of scene's skeletons
  33563. * @param toRemove defines the skeleton to remove
  33564. * @returns the index where the skeleton was in the skeleton list
  33565. */
  33566. removeSkeleton(toRemove: Skeleton): number;
  33567. /**
  33568. * Remove a morph target for the list of scene's morph targets
  33569. * @param toRemove defines the morph target to remove
  33570. * @returns the index where the morph target was in the morph target list
  33571. */
  33572. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33573. /**
  33574. * Remove a light for the list of scene's lights
  33575. * @param toRemove defines the light to remove
  33576. * @returns the index where the light was in the light list
  33577. */
  33578. removeLight(toRemove: Light): number;
  33579. /**
  33580. * Remove a camera for the list of scene's cameras
  33581. * @param toRemove defines the camera to remove
  33582. * @returns the index where the camera was in the camera list
  33583. */
  33584. removeCamera(toRemove: Camera): number;
  33585. /**
  33586. * Remove a particle system for the list of scene's particle systems
  33587. * @param toRemove defines the particle system to remove
  33588. * @returns the index where the particle system was in the particle system list
  33589. */
  33590. removeParticleSystem(toRemove: IParticleSystem): number;
  33591. /**
  33592. * Remove a animation for the list of scene's animations
  33593. * @param toRemove defines the animation to remove
  33594. * @returns the index where the animation was in the animation list
  33595. */
  33596. removeAnimation(toRemove: Animation): number;
  33597. /**
  33598. * Removes the given animation group from this scene.
  33599. * @param toRemove The animation group to remove
  33600. * @returns The index of the removed animation group
  33601. */
  33602. removeAnimationGroup(toRemove: AnimationGroup): number;
  33603. /**
  33604. * Removes the given multi-material from this scene.
  33605. * @param toRemove The multi-material to remove
  33606. * @returns The index of the removed multi-material
  33607. */
  33608. removeMultiMaterial(toRemove: MultiMaterial): number;
  33609. /**
  33610. * Removes the given material from this scene.
  33611. * @param toRemove The material to remove
  33612. * @returns The index of the removed material
  33613. */
  33614. removeMaterial(toRemove: Material): number;
  33615. /**
  33616. * Removes the given action manager from this scene.
  33617. * @param toRemove The action manager to remove
  33618. * @returns The index of the removed action manager
  33619. */
  33620. removeActionManager(toRemove: AbstractActionManager): number;
  33621. /**
  33622. * Removes the given texture from this scene.
  33623. * @param toRemove The texture to remove
  33624. * @returns The index of the removed texture
  33625. */
  33626. removeTexture(toRemove: BaseTexture): number;
  33627. /**
  33628. * Adds the given light to this scene
  33629. * @param newLight The light to add
  33630. */
  33631. addLight(newLight: Light): void;
  33632. /**
  33633. * Sorts the list list based on light priorities
  33634. */
  33635. sortLightsByPriority(): void;
  33636. /**
  33637. * Adds the given camera to this scene
  33638. * @param newCamera The camera to add
  33639. */
  33640. addCamera(newCamera: Camera): void;
  33641. /**
  33642. * Adds the given skeleton to this scene
  33643. * @param newSkeleton The skeleton to add
  33644. */
  33645. addSkeleton(newSkeleton: Skeleton): void;
  33646. /**
  33647. * Adds the given particle system to this scene
  33648. * @param newParticleSystem The particle system to add
  33649. */
  33650. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33651. /**
  33652. * Adds the given animation to this scene
  33653. * @param newAnimation The animation to add
  33654. */
  33655. addAnimation(newAnimation: Animation): void;
  33656. /**
  33657. * Adds the given animation group to this scene.
  33658. * @param newAnimationGroup The animation group to add
  33659. */
  33660. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33661. /**
  33662. * Adds the given multi-material to this scene
  33663. * @param newMultiMaterial The multi-material to add
  33664. */
  33665. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33666. /**
  33667. * Adds the given material to this scene
  33668. * @param newMaterial The material to add
  33669. */
  33670. addMaterial(newMaterial: Material): void;
  33671. /**
  33672. * Adds the given morph target to this scene
  33673. * @param newMorphTargetManager The morph target to add
  33674. */
  33675. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33676. /**
  33677. * Adds the given geometry to this scene
  33678. * @param newGeometry The geometry to add
  33679. */
  33680. addGeometry(newGeometry: Geometry): void;
  33681. /**
  33682. * Adds the given action manager to this scene
  33683. * @param newActionManager The action manager to add
  33684. */
  33685. addActionManager(newActionManager: AbstractActionManager): void;
  33686. /**
  33687. * Adds the given texture to this scene.
  33688. * @param newTexture The texture to add
  33689. */
  33690. addTexture(newTexture: BaseTexture): void;
  33691. /**
  33692. * Switch active camera
  33693. * @param newCamera defines the new active camera
  33694. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33695. */
  33696. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33697. /**
  33698. * sets the active camera of the scene using its ID
  33699. * @param id defines the camera's ID
  33700. * @return the new active camera or null if none found.
  33701. */
  33702. setActiveCameraByID(id: string): Nullable<Camera>;
  33703. /**
  33704. * sets the active camera of the scene using its name
  33705. * @param name defines the camera's name
  33706. * @returns the new active camera or null if none found.
  33707. */
  33708. setActiveCameraByName(name: string): Nullable<Camera>;
  33709. /**
  33710. * get an animation group using its name
  33711. * @param name defines the material's name
  33712. * @return the animation group or null if none found.
  33713. */
  33714. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33715. /**
  33716. * Get a material using its unique id
  33717. * @param uniqueId defines the material's unique id
  33718. * @return the material or null if none found.
  33719. */
  33720. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33721. /**
  33722. * get a material using its id
  33723. * @param id defines the material's ID
  33724. * @return the material or null if none found.
  33725. */
  33726. getMaterialByID(id: string): Nullable<Material>;
  33727. /**
  33728. * Gets a material using its name
  33729. * @param name defines the material's name
  33730. * @return the material or null if none found.
  33731. */
  33732. getMaterialByName(name: string): Nullable<Material>;
  33733. /**
  33734. * Gets a camera using its id
  33735. * @param id defines the id to look for
  33736. * @returns the camera or null if not found
  33737. */
  33738. getCameraByID(id: string): Nullable<Camera>;
  33739. /**
  33740. * Gets a camera using its unique id
  33741. * @param uniqueId defines the unique id to look for
  33742. * @returns the camera or null if not found
  33743. */
  33744. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33745. /**
  33746. * Gets a camera using its name
  33747. * @param name defines the camera's name
  33748. * @return the camera or null if none found.
  33749. */
  33750. getCameraByName(name: string): Nullable<Camera>;
  33751. /**
  33752. * Gets a bone using its id
  33753. * @param id defines the bone's id
  33754. * @return the bone or null if not found
  33755. */
  33756. getBoneByID(id: string): Nullable<Bone>;
  33757. /**
  33758. * Gets a bone using its id
  33759. * @param name defines the bone's name
  33760. * @return the bone or null if not found
  33761. */
  33762. getBoneByName(name: string): Nullable<Bone>;
  33763. /**
  33764. * Gets a light node using its name
  33765. * @param name defines the the light's name
  33766. * @return the light or null if none found.
  33767. */
  33768. getLightByName(name: string): Nullable<Light>;
  33769. /**
  33770. * Gets a light node using its id
  33771. * @param id defines the light's id
  33772. * @return the light or null if none found.
  33773. */
  33774. getLightByID(id: string): Nullable<Light>;
  33775. /**
  33776. * Gets a light node using its scene-generated unique ID
  33777. * @param uniqueId defines the light's unique id
  33778. * @return the light or null if none found.
  33779. */
  33780. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33781. /**
  33782. * Gets a particle system by id
  33783. * @param id defines the particle system id
  33784. * @return the corresponding system or null if none found
  33785. */
  33786. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33787. /**
  33788. * Gets a geometry using its ID
  33789. * @param id defines the geometry's id
  33790. * @return the geometry or null if none found.
  33791. */
  33792. getGeometryByID(id: string): Nullable<Geometry>;
  33793. private _getGeometryByUniqueID;
  33794. /**
  33795. * Add a new geometry to this scene
  33796. * @param geometry defines the geometry to be added to the scene.
  33797. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33798. * @return a boolean defining if the geometry was added or not
  33799. */
  33800. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33801. /**
  33802. * Removes an existing geometry
  33803. * @param geometry defines the geometry to be removed from the scene
  33804. * @return a boolean defining if the geometry was removed or not
  33805. */
  33806. removeGeometry(geometry: Geometry): boolean;
  33807. /**
  33808. * Gets the list of geometries attached to the scene
  33809. * @returns an array of Geometry
  33810. */
  33811. getGeometries(): Geometry[];
  33812. /**
  33813. * Gets the first added mesh found of a given ID
  33814. * @param id defines the id to search for
  33815. * @return the mesh found or null if not found at all
  33816. */
  33817. getMeshByID(id: string): Nullable<AbstractMesh>;
  33818. /**
  33819. * Gets a list of meshes using their id
  33820. * @param id defines the id to search for
  33821. * @returns a list of meshes
  33822. */
  33823. getMeshesByID(id: string): Array<AbstractMesh>;
  33824. /**
  33825. * Gets the first added transform node found of a given ID
  33826. * @param id defines the id to search for
  33827. * @return the found transform node or null if not found at all.
  33828. */
  33829. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33830. /**
  33831. * Gets a transform node with its auto-generated unique id
  33832. * @param uniqueId efines the unique id to search for
  33833. * @return the found transform node or null if not found at all.
  33834. */
  33835. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33836. /**
  33837. * Gets a list of transform nodes using their id
  33838. * @param id defines the id to search for
  33839. * @returns a list of transform nodes
  33840. */
  33841. getTransformNodesByID(id: string): Array<TransformNode>;
  33842. /**
  33843. * Gets a mesh with its auto-generated unique id
  33844. * @param uniqueId defines the unique id to search for
  33845. * @return the found mesh or null if not found at all.
  33846. */
  33847. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33848. /**
  33849. * Gets a the last added mesh using a given id
  33850. * @param id defines the id to search for
  33851. * @return the found mesh or null if not found at all.
  33852. */
  33853. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33854. /**
  33855. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33856. * @param id defines the id to search for
  33857. * @return the found node or null if not found at all
  33858. */
  33859. getLastEntryByID(id: string): Nullable<Node>;
  33860. /**
  33861. * Gets a node (Mesh, Camera, Light) using a given id
  33862. * @param id defines the id to search for
  33863. * @return the found node or null if not found at all
  33864. */
  33865. getNodeByID(id: string): Nullable<Node>;
  33866. /**
  33867. * Gets a node (Mesh, Camera, Light) using a given name
  33868. * @param name defines the name to search for
  33869. * @return the found node or null if not found at all.
  33870. */
  33871. getNodeByName(name: string): Nullable<Node>;
  33872. /**
  33873. * Gets a mesh using a given name
  33874. * @param name defines the name to search for
  33875. * @return the found mesh or null if not found at all.
  33876. */
  33877. getMeshByName(name: string): Nullable<AbstractMesh>;
  33878. /**
  33879. * Gets a transform node using a given name
  33880. * @param name defines the name to search for
  33881. * @return the found transform node or null if not found at all.
  33882. */
  33883. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33884. /**
  33885. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33886. * @param id defines the id to search for
  33887. * @return the found skeleton or null if not found at all.
  33888. */
  33889. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33890. /**
  33891. * Gets a skeleton using a given auto generated unique id
  33892. * @param uniqueId defines the unique id to search for
  33893. * @return the found skeleton or null if not found at all.
  33894. */
  33895. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33896. /**
  33897. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33898. * @param id defines the id to search for
  33899. * @return the found skeleton or null if not found at all.
  33900. */
  33901. getSkeletonById(id: string): Nullable<Skeleton>;
  33902. /**
  33903. * Gets a skeleton using a given name
  33904. * @param name defines the name to search for
  33905. * @return the found skeleton or null if not found at all.
  33906. */
  33907. getSkeletonByName(name: string): Nullable<Skeleton>;
  33908. /**
  33909. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33910. * @param id defines the id to search for
  33911. * @return the found morph target manager or null if not found at all.
  33912. */
  33913. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33914. /**
  33915. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33916. * @param id defines the id to search for
  33917. * @return the found morph target or null if not found at all.
  33918. */
  33919. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33920. /**
  33921. * Gets a boolean indicating if the given mesh is active
  33922. * @param mesh defines the mesh to look for
  33923. * @returns true if the mesh is in the active list
  33924. */
  33925. isActiveMesh(mesh: AbstractMesh): boolean;
  33926. /**
  33927. * Return a unique id as a string which can serve as an identifier for the scene
  33928. */
  33929. readonly uid: string;
  33930. /**
  33931. * Add an externaly attached data from its key.
  33932. * This method call will fail and return false, if such key already exists.
  33933. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33934. * @param key the unique key that identifies the data
  33935. * @param data the data object to associate to the key for this Engine instance
  33936. * @return true if no such key were already present and the data was added successfully, false otherwise
  33937. */
  33938. addExternalData<T>(key: string, data: T): boolean;
  33939. /**
  33940. * Get an externaly attached data from its key
  33941. * @param key the unique key that identifies the data
  33942. * @return the associated data, if present (can be null), or undefined if not present
  33943. */
  33944. getExternalData<T>(key: string): Nullable<T>;
  33945. /**
  33946. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33947. * @param key the unique key that identifies the data
  33948. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33949. * @return the associated data, can be null if the factory returned null.
  33950. */
  33951. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33952. /**
  33953. * Remove an externaly attached data from the Engine instance
  33954. * @param key the unique key that identifies the data
  33955. * @return true if the data was successfully removed, false if it doesn't exist
  33956. */
  33957. removeExternalData(key: string): boolean;
  33958. private _evaluateSubMesh;
  33959. /**
  33960. * Clear the processed materials smart array preventing retention point in material dispose.
  33961. */
  33962. freeProcessedMaterials(): void;
  33963. private _preventFreeActiveMeshesAndRenderingGroups;
  33964. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33965. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33966. * when disposing several meshes in a row or a hierarchy of meshes.
  33967. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33968. */
  33969. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33970. /**
  33971. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33972. */
  33973. freeActiveMeshes(): void;
  33974. /**
  33975. * Clear the info related to rendering groups preventing retention points during dispose.
  33976. */
  33977. freeRenderingGroups(): void;
  33978. /** @hidden */
  33979. _isInIntermediateRendering(): boolean;
  33980. /**
  33981. * Lambda returning the list of potentially active meshes.
  33982. */
  33983. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33984. /**
  33985. * Lambda returning the list of potentially active sub meshes.
  33986. */
  33987. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33988. /**
  33989. * Lambda returning the list of potentially intersecting sub meshes.
  33990. */
  33991. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33992. /**
  33993. * Lambda returning the list of potentially colliding sub meshes.
  33994. */
  33995. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33996. private _activeMeshesFrozen;
  33997. /**
  33998. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33999. * @returns the current scene
  34000. */
  34001. freezeActiveMeshes(): Scene;
  34002. /**
  34003. * Use this function to restart evaluating active meshes on every frame
  34004. * @returns the current scene
  34005. */
  34006. unfreezeActiveMeshes(): Scene;
  34007. private _evaluateActiveMeshes;
  34008. private _activeMesh;
  34009. /**
  34010. * Update the transform matrix to update from the current active camera
  34011. * @param force defines a boolean used to force the update even if cache is up to date
  34012. */
  34013. updateTransformMatrix(force?: boolean): void;
  34014. private _bindFrameBuffer;
  34015. /** @hidden */
  34016. _allowPostProcessClearColor: boolean;
  34017. /** @hidden */
  34018. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34019. private _processSubCameras;
  34020. private _checkIntersections;
  34021. /** @hidden */
  34022. _advancePhysicsEngineStep(step: number): void;
  34023. /**
  34024. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34025. */
  34026. getDeterministicFrameTime: () => number;
  34027. /** @hidden */
  34028. _animate(): void;
  34029. /**
  34030. * Render the scene
  34031. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34032. */
  34033. render(updateCameras?: boolean): void;
  34034. /**
  34035. * Freeze all materials
  34036. * A frozen material will not be updatable but should be faster to render
  34037. */
  34038. freezeMaterials(): void;
  34039. /**
  34040. * Unfreeze all materials
  34041. * A frozen material will not be updatable but should be faster to render
  34042. */
  34043. unfreezeMaterials(): void;
  34044. /**
  34045. * Releases all held ressources
  34046. */
  34047. dispose(): void;
  34048. /**
  34049. * Gets if the scene is already disposed
  34050. */
  34051. readonly isDisposed: boolean;
  34052. /**
  34053. * Call this function to reduce memory footprint of the scene.
  34054. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34055. */
  34056. clearCachedVertexData(): void;
  34057. /**
  34058. * This function will remove the local cached buffer data from texture.
  34059. * It will save memory but will prevent the texture from being rebuilt
  34060. */
  34061. cleanCachedTextureBuffer(): void;
  34062. /**
  34063. * Get the world extend vectors with an optional filter
  34064. *
  34065. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34066. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34067. */
  34068. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34069. min: Vector3;
  34070. max: Vector3;
  34071. };
  34072. /**
  34073. * Creates a ray that can be used to pick in the scene
  34074. * @param x defines the x coordinate of the origin (on-screen)
  34075. * @param y defines the y coordinate of the origin (on-screen)
  34076. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34077. * @param camera defines the camera to use for the picking
  34078. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34079. * @returns a Ray
  34080. */
  34081. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34082. /**
  34083. * Creates a ray that can be used to pick in the scene
  34084. * @param x defines the x coordinate of the origin (on-screen)
  34085. * @param y defines the y coordinate of the origin (on-screen)
  34086. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34087. * @param result defines the ray where to store the picking ray
  34088. * @param camera defines the camera to use for the picking
  34089. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34090. * @returns the current scene
  34091. */
  34092. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34093. /**
  34094. * Creates a ray that can be used to pick in the scene
  34095. * @param x defines the x coordinate of the origin (on-screen)
  34096. * @param y defines the y coordinate of the origin (on-screen)
  34097. * @param camera defines the camera to use for the picking
  34098. * @returns a Ray
  34099. */
  34100. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34101. /**
  34102. * Creates a ray that can be used to pick in the scene
  34103. * @param x defines the x coordinate of the origin (on-screen)
  34104. * @param y defines the y coordinate of the origin (on-screen)
  34105. * @param result defines the ray where to store the picking ray
  34106. * @param camera defines the camera to use for the picking
  34107. * @returns the current scene
  34108. */
  34109. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34110. /** Launch a ray to try to pick a mesh in the scene
  34111. * @param x position on screen
  34112. * @param y position on screen
  34113. * @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
  34114. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34115. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34116. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34117. * @returns a PickingInfo
  34118. */
  34119. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34120. /** Use the given ray to pick a mesh in the scene
  34121. * @param ray The ray to use to pick meshes
  34122. * @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
  34123. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34124. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34125. * @returns a PickingInfo
  34126. */
  34127. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34128. /**
  34129. * Launch a ray to try to pick a mesh in the scene
  34130. * @param x X position on screen
  34131. * @param y Y position on screen
  34132. * @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
  34133. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34134. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34135. * @returns an array of PickingInfo
  34136. */
  34137. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34138. /**
  34139. * Launch a ray to try to pick a mesh in the scene
  34140. * @param ray Ray to use
  34141. * @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
  34142. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34143. * @returns an array of PickingInfo
  34144. */
  34145. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34146. /**
  34147. * Force the value of meshUnderPointer
  34148. * @param mesh defines the mesh to use
  34149. */
  34150. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34151. /**
  34152. * Gets the mesh under the pointer
  34153. * @returns a Mesh or null if no mesh is under the pointer
  34154. */
  34155. getPointerOverMesh(): Nullable<AbstractMesh>;
  34156. /** @hidden */
  34157. _rebuildGeometries(): void;
  34158. /** @hidden */
  34159. _rebuildTextures(): void;
  34160. private _getByTags;
  34161. /**
  34162. * Get a list of meshes by tags
  34163. * @param tagsQuery defines the tags query to use
  34164. * @param forEach defines a predicate used to filter results
  34165. * @returns an array of Mesh
  34166. */
  34167. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34168. /**
  34169. * Get a list of cameras by tags
  34170. * @param tagsQuery defines the tags query to use
  34171. * @param forEach defines a predicate used to filter results
  34172. * @returns an array of Camera
  34173. */
  34174. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34175. /**
  34176. * Get a list of lights by tags
  34177. * @param tagsQuery defines the tags query to use
  34178. * @param forEach defines a predicate used to filter results
  34179. * @returns an array of Light
  34180. */
  34181. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34182. /**
  34183. * Get a list of materials by tags
  34184. * @param tagsQuery defines the tags query to use
  34185. * @param forEach defines a predicate used to filter results
  34186. * @returns an array of Material
  34187. */
  34188. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34189. /**
  34190. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34191. * This allowed control for front to back rendering or reversly depending of the special needs.
  34192. *
  34193. * @param renderingGroupId The rendering group id corresponding to its index
  34194. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34195. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34196. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34197. */
  34198. 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;
  34199. /**
  34200. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34201. *
  34202. * @param renderingGroupId The rendering group id corresponding to its index
  34203. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34204. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34205. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34206. */
  34207. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34208. /**
  34209. * Gets the current auto clear configuration for one rendering group of the rendering
  34210. * manager.
  34211. * @param index the rendering group index to get the information for
  34212. * @returns The auto clear setup for the requested rendering group
  34213. */
  34214. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34215. private _blockMaterialDirtyMechanism;
  34216. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34217. blockMaterialDirtyMechanism: boolean;
  34218. /**
  34219. * Will flag all materials as dirty to trigger new shader compilation
  34220. * @param flag defines the flag used to specify which material part must be marked as dirty
  34221. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34222. */
  34223. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34224. /** @hidden */
  34225. _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;
  34226. /** @hidden */
  34227. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34228. }
  34229. }
  34230. declare module "babylonjs/assetContainer" {
  34231. import { AbstractScene } from "babylonjs/abstractScene";
  34232. import { Scene } from "babylonjs/scene";
  34233. import { Mesh } from "babylonjs/Meshes/mesh";
  34234. /**
  34235. * Set of assets to keep when moving a scene into an asset container.
  34236. */
  34237. export class KeepAssets extends AbstractScene {
  34238. }
  34239. /**
  34240. * Container with a set of assets that can be added or removed from a scene.
  34241. */
  34242. export class AssetContainer extends AbstractScene {
  34243. /**
  34244. * The scene the AssetContainer belongs to.
  34245. */
  34246. scene: Scene;
  34247. /**
  34248. * Instantiates an AssetContainer.
  34249. * @param scene The scene the AssetContainer belongs to.
  34250. */
  34251. constructor(scene: Scene);
  34252. /**
  34253. * Adds all the assets from the container to the scene.
  34254. */
  34255. addAllToScene(): void;
  34256. /**
  34257. * Removes all the assets in the container from the scene
  34258. */
  34259. removeAllFromScene(): void;
  34260. /**
  34261. * Disposes all the assets in the container
  34262. */
  34263. dispose(): void;
  34264. private _moveAssets;
  34265. /**
  34266. * Removes all the assets contained in the scene and adds them to the container.
  34267. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34268. */
  34269. moveAllFromScene(keepAssets?: KeepAssets): void;
  34270. /**
  34271. * 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.
  34272. * @returns the root mesh
  34273. */
  34274. createRootMesh(): Mesh;
  34275. }
  34276. }
  34277. declare module "babylonjs/abstractScene" {
  34278. import { Scene } from "babylonjs/scene";
  34279. import { Nullable } from "babylonjs/types";
  34280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34281. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34282. import { Geometry } from "babylonjs/Meshes/geometry";
  34283. import { Skeleton } from "babylonjs/Bones/skeleton";
  34284. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34285. import { AssetContainer } from "babylonjs/assetContainer";
  34286. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34287. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34288. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34289. import { Material } from "babylonjs/Materials/material";
  34290. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34291. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34292. import { Camera } from "babylonjs/Cameras/camera";
  34293. import { Light } from "babylonjs/Lights/light";
  34294. import { Node } from "babylonjs/node";
  34295. import { Animation } from "babylonjs/Animations/animation";
  34296. /**
  34297. * Defines how the parser contract is defined.
  34298. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34299. */
  34300. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34301. /**
  34302. * Defines how the individual parser contract is defined.
  34303. * These parser can parse an individual asset
  34304. */
  34305. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34306. /**
  34307. * Base class of the scene acting as a container for the different elements composing a scene.
  34308. * This class is dynamically extended by the different components of the scene increasing
  34309. * flexibility and reducing coupling
  34310. */
  34311. export abstract class AbstractScene {
  34312. /**
  34313. * Stores the list of available parsers in the application.
  34314. */
  34315. private static _BabylonFileParsers;
  34316. /**
  34317. * Stores the list of available individual parsers in the application.
  34318. */
  34319. private static _IndividualBabylonFileParsers;
  34320. /**
  34321. * Adds a parser in the list of available ones
  34322. * @param name Defines the name of the parser
  34323. * @param parser Defines the parser to add
  34324. */
  34325. static AddParser(name: string, parser: BabylonFileParser): void;
  34326. /**
  34327. * Gets a general parser from the list of avaialble ones
  34328. * @param name Defines the name of the parser
  34329. * @returns the requested parser or null
  34330. */
  34331. static GetParser(name: string): Nullable<BabylonFileParser>;
  34332. /**
  34333. * Adds n individual parser in the list of available ones
  34334. * @param name Defines the name of the parser
  34335. * @param parser Defines the parser to add
  34336. */
  34337. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34338. /**
  34339. * Gets an individual parser from the list of avaialble ones
  34340. * @param name Defines the name of the parser
  34341. * @returns the requested parser or null
  34342. */
  34343. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34344. /**
  34345. * Parser json data and populate both a scene and its associated container object
  34346. * @param jsonData Defines the data to parse
  34347. * @param scene Defines the scene to parse the data for
  34348. * @param container Defines the container attached to the parsing sequence
  34349. * @param rootUrl Defines the root url of the data
  34350. */
  34351. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34352. /**
  34353. * Gets the list of root nodes (ie. nodes with no parent)
  34354. */
  34355. rootNodes: Node[];
  34356. /** All of the cameras added to this scene
  34357. * @see http://doc.babylonjs.com/babylon101/cameras
  34358. */
  34359. cameras: Camera[];
  34360. /**
  34361. * All of the lights added to this scene
  34362. * @see http://doc.babylonjs.com/babylon101/lights
  34363. */
  34364. lights: Light[];
  34365. /**
  34366. * All of the (abstract) meshes added to this scene
  34367. */
  34368. meshes: AbstractMesh[];
  34369. /**
  34370. * The list of skeletons added to the scene
  34371. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34372. */
  34373. skeletons: Skeleton[];
  34374. /**
  34375. * All of the particle systems added to this scene
  34376. * @see http://doc.babylonjs.com/babylon101/particles
  34377. */
  34378. particleSystems: IParticleSystem[];
  34379. /**
  34380. * Gets a list of Animations associated with the scene
  34381. */
  34382. animations: Animation[];
  34383. /**
  34384. * All of the animation groups added to this scene
  34385. * @see http://doc.babylonjs.com/how_to/group
  34386. */
  34387. animationGroups: AnimationGroup[];
  34388. /**
  34389. * All of the multi-materials added to this scene
  34390. * @see http://doc.babylonjs.com/how_to/multi_materials
  34391. */
  34392. multiMaterials: MultiMaterial[];
  34393. /**
  34394. * All of the materials added to this scene
  34395. * In the context of a Scene, it is not supposed to be modified manually.
  34396. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34397. * Note also that the order of the Material wihin the array is not significant and might change.
  34398. * @see http://doc.babylonjs.com/babylon101/materials
  34399. */
  34400. materials: Material[];
  34401. /**
  34402. * The list of morph target managers added to the scene
  34403. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34404. */
  34405. morphTargetManagers: MorphTargetManager[];
  34406. /**
  34407. * The list of geometries used in the scene.
  34408. */
  34409. geometries: Geometry[];
  34410. /**
  34411. * All of the tranform nodes added to this scene
  34412. * In the context of a Scene, it is not supposed to be modified manually.
  34413. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34414. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34415. * @see http://doc.babylonjs.com/how_to/transformnode
  34416. */
  34417. transformNodes: TransformNode[];
  34418. /**
  34419. * ActionManagers available on the scene.
  34420. */
  34421. actionManagers: AbstractActionManager[];
  34422. /**
  34423. * Textures to keep.
  34424. */
  34425. textures: BaseTexture[];
  34426. /**
  34427. * Environment texture for the scene
  34428. */
  34429. environmentTexture: Nullable<BaseTexture>;
  34430. }
  34431. }
  34432. declare module "babylonjs/Audio/sound" {
  34433. import { Observable } from "babylonjs/Misc/observable";
  34434. import { Vector3 } from "babylonjs/Maths/math";
  34435. import { Nullable } from "babylonjs/types";
  34436. import { Scene } from "babylonjs/scene";
  34437. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34438. /**
  34439. * Defines a sound that can be played in the application.
  34440. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34442. */
  34443. export class Sound {
  34444. /**
  34445. * The name of the sound in the scene.
  34446. */
  34447. name: string;
  34448. /**
  34449. * Does the sound autoplay once loaded.
  34450. */
  34451. autoplay: boolean;
  34452. /**
  34453. * Does the sound loop after it finishes playing once.
  34454. */
  34455. loop: boolean;
  34456. /**
  34457. * Does the sound use a custom attenuation curve to simulate the falloff
  34458. * happening when the source gets further away from the camera.
  34459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34460. */
  34461. useCustomAttenuation: boolean;
  34462. /**
  34463. * The sound track id this sound belongs to.
  34464. */
  34465. soundTrackId: number;
  34466. /**
  34467. * Is this sound currently played.
  34468. */
  34469. isPlaying: boolean;
  34470. /**
  34471. * Is this sound currently paused.
  34472. */
  34473. isPaused: boolean;
  34474. /**
  34475. * Does this sound enables spatial sound.
  34476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34477. */
  34478. spatialSound: boolean;
  34479. /**
  34480. * Define the reference distance the sound should be heard perfectly.
  34481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34482. */
  34483. refDistance: number;
  34484. /**
  34485. * Define the roll off factor of spatial sounds.
  34486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34487. */
  34488. rolloffFactor: number;
  34489. /**
  34490. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34491. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34492. */
  34493. maxDistance: number;
  34494. /**
  34495. * Define the distance attenuation model the sound will follow.
  34496. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34497. */
  34498. distanceModel: string;
  34499. /**
  34500. * @hidden
  34501. * Back Compat
  34502. **/
  34503. onended: () => any;
  34504. /**
  34505. * Observable event when the current playing sound finishes.
  34506. */
  34507. onEndedObservable: Observable<Sound>;
  34508. private _panningModel;
  34509. private _playbackRate;
  34510. private _streaming;
  34511. private _startTime;
  34512. private _startOffset;
  34513. private _position;
  34514. /** @hidden */
  34515. _positionInEmitterSpace: boolean;
  34516. private _localDirection;
  34517. private _volume;
  34518. private _isReadyToPlay;
  34519. private _isDirectional;
  34520. private _readyToPlayCallback;
  34521. private _audioBuffer;
  34522. private _soundSource;
  34523. private _streamingSource;
  34524. private _soundPanner;
  34525. private _soundGain;
  34526. private _inputAudioNode;
  34527. private _outputAudioNode;
  34528. private _coneInnerAngle;
  34529. private _coneOuterAngle;
  34530. private _coneOuterGain;
  34531. private _scene;
  34532. private _connectedTransformNode;
  34533. private _customAttenuationFunction;
  34534. private _registerFunc;
  34535. private _isOutputConnected;
  34536. private _htmlAudioElement;
  34537. private _urlType;
  34538. /** @hidden */
  34539. static _SceneComponentInitialization: (scene: Scene) => void;
  34540. /**
  34541. * Create a sound and attach it to a scene
  34542. * @param name Name of your sound
  34543. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34544. * @param scene defines the scene the sound belongs to
  34545. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34546. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34547. */
  34548. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34549. /**
  34550. * Release the sound and its associated resources
  34551. */
  34552. dispose(): void;
  34553. /**
  34554. * Gets if the sounds is ready to be played or not.
  34555. * @returns true if ready, otherwise false
  34556. */
  34557. isReady(): boolean;
  34558. private _soundLoaded;
  34559. /**
  34560. * Sets the data of the sound from an audiobuffer
  34561. * @param audioBuffer The audioBuffer containing the data
  34562. */
  34563. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34564. /**
  34565. * Updates the current sounds options such as maxdistance, loop...
  34566. * @param options A JSON object containing values named as the object properties
  34567. */
  34568. updateOptions(options: any): void;
  34569. private _createSpatialParameters;
  34570. private _updateSpatialParameters;
  34571. /**
  34572. * Switch the panning model to HRTF:
  34573. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34575. */
  34576. switchPanningModelToHRTF(): void;
  34577. /**
  34578. * Switch the panning model to Equal Power:
  34579. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34581. */
  34582. switchPanningModelToEqualPower(): void;
  34583. private _switchPanningModel;
  34584. /**
  34585. * Connect this sound to a sound track audio node like gain...
  34586. * @param soundTrackAudioNode the sound track audio node to connect to
  34587. */
  34588. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34589. /**
  34590. * Transform this sound into a directional source
  34591. * @param coneInnerAngle Size of the inner cone in degree
  34592. * @param coneOuterAngle Size of the outer cone in degree
  34593. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34594. */
  34595. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34596. /**
  34597. * Gets or sets the inner angle for the directional cone.
  34598. */
  34599. /**
  34600. * Gets or sets the inner angle for the directional cone.
  34601. */
  34602. directionalConeInnerAngle: number;
  34603. /**
  34604. * Gets or sets the outer angle for the directional cone.
  34605. */
  34606. /**
  34607. * Gets or sets the outer angle for the directional cone.
  34608. */
  34609. directionalConeOuterAngle: number;
  34610. /**
  34611. * Sets the position of the emitter if spatial sound is enabled
  34612. * @param newPosition Defines the new posisiton
  34613. */
  34614. setPosition(newPosition: Vector3): void;
  34615. /**
  34616. * Sets the local direction of the emitter if spatial sound is enabled
  34617. * @param newLocalDirection Defines the new local direction
  34618. */
  34619. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34620. private _updateDirection;
  34621. /** @hidden */
  34622. updateDistanceFromListener(): void;
  34623. /**
  34624. * Sets a new custom attenuation function for the sound.
  34625. * @param callback Defines the function used for the attenuation
  34626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34627. */
  34628. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34629. /**
  34630. * Play the sound
  34631. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34632. * @param offset (optional) Start the sound setting it at a specific time
  34633. */
  34634. play(time?: number, offset?: number): void;
  34635. private _onended;
  34636. /**
  34637. * Stop the sound
  34638. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34639. */
  34640. stop(time?: number): void;
  34641. /**
  34642. * Put the sound in pause
  34643. */
  34644. pause(): void;
  34645. /**
  34646. * Sets a dedicated volume for this sounds
  34647. * @param newVolume Define the new volume of the sound
  34648. * @param time Define in how long the sound should be at this value
  34649. */
  34650. setVolume(newVolume: number, time?: number): void;
  34651. /**
  34652. * Set the sound play back rate
  34653. * @param newPlaybackRate Define the playback rate the sound should be played at
  34654. */
  34655. setPlaybackRate(newPlaybackRate: number): void;
  34656. /**
  34657. * Gets the volume of the sound.
  34658. * @returns the volume of the sound
  34659. */
  34660. getVolume(): number;
  34661. /**
  34662. * Attach the sound to a dedicated mesh
  34663. * @param transformNode The transform node to connect the sound with
  34664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34665. */
  34666. attachToMesh(transformNode: TransformNode): void;
  34667. /**
  34668. * Detach the sound from the previously attached mesh
  34669. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34670. */
  34671. detachFromMesh(): void;
  34672. private _onRegisterAfterWorldMatrixUpdate;
  34673. /**
  34674. * Clone the current sound in the scene.
  34675. * @returns the new sound clone
  34676. */
  34677. clone(): Nullable<Sound>;
  34678. /**
  34679. * Gets the current underlying audio buffer containing the data
  34680. * @returns the audio buffer
  34681. */
  34682. getAudioBuffer(): Nullable<AudioBuffer>;
  34683. /**
  34684. * Serializes the Sound in a JSON representation
  34685. * @returns the JSON representation of the sound
  34686. */
  34687. serialize(): any;
  34688. /**
  34689. * Parse a JSON representation of a sound to innstantiate in a given scene
  34690. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34691. * @param scene Define the scene the new parsed sound should be created in
  34692. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34693. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34694. * @returns the newly parsed sound
  34695. */
  34696. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34697. }
  34698. }
  34699. declare module "babylonjs/Actions/directAudioActions" {
  34700. import { Action } from "babylonjs/Actions/action";
  34701. import { Condition } from "babylonjs/Actions/condition";
  34702. import { Sound } from "babylonjs/Audio/sound";
  34703. /**
  34704. * This defines an action helpful to play a defined sound on a triggered action.
  34705. */
  34706. export class PlaySoundAction extends Action {
  34707. private _sound;
  34708. /**
  34709. * Instantiate the action
  34710. * @param triggerOptions defines the trigger options
  34711. * @param sound defines the sound to play
  34712. * @param condition defines the trigger related conditions
  34713. */
  34714. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34715. /** @hidden */
  34716. _prepare(): void;
  34717. /**
  34718. * Execute the action and play the sound.
  34719. */
  34720. execute(): void;
  34721. /**
  34722. * Serializes the actions and its related information.
  34723. * @param parent defines the object to serialize in
  34724. * @returns the serialized object
  34725. */
  34726. serialize(parent: any): any;
  34727. }
  34728. /**
  34729. * This defines an action helpful to stop a defined sound on a triggered action.
  34730. */
  34731. export class StopSoundAction extends Action {
  34732. private _sound;
  34733. /**
  34734. * Instantiate the action
  34735. * @param triggerOptions defines the trigger options
  34736. * @param sound defines the sound to stop
  34737. * @param condition defines the trigger related conditions
  34738. */
  34739. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34740. /** @hidden */
  34741. _prepare(): void;
  34742. /**
  34743. * Execute the action and stop the sound.
  34744. */
  34745. execute(): void;
  34746. /**
  34747. * Serializes the actions and its related information.
  34748. * @param parent defines the object to serialize in
  34749. * @returns the serialized object
  34750. */
  34751. serialize(parent: any): any;
  34752. }
  34753. }
  34754. declare module "babylonjs/Actions/interpolateValueAction" {
  34755. import { Action } from "babylonjs/Actions/action";
  34756. import { Condition } from "babylonjs/Actions/condition";
  34757. import { Observable } from "babylonjs/Misc/observable";
  34758. /**
  34759. * This defines an action responsible to change the value of a property
  34760. * by interpolating between its current value and the newly set one once triggered.
  34761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34762. */
  34763. export class InterpolateValueAction extends Action {
  34764. /**
  34765. * Defines the path of the property where the value should be interpolated
  34766. */
  34767. propertyPath: string;
  34768. /**
  34769. * Defines the target value at the end of the interpolation.
  34770. */
  34771. value: any;
  34772. /**
  34773. * Defines the time it will take for the property to interpolate to the value.
  34774. */
  34775. duration: number;
  34776. /**
  34777. * Defines if the other scene animations should be stopped when the action has been triggered
  34778. */
  34779. stopOtherAnimations?: boolean;
  34780. /**
  34781. * Defines a callback raised once the interpolation animation has been done.
  34782. */
  34783. onInterpolationDone?: () => void;
  34784. /**
  34785. * Observable triggered once the interpolation animation has been done.
  34786. */
  34787. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34788. private _target;
  34789. private _effectiveTarget;
  34790. private _property;
  34791. /**
  34792. * Instantiate the action
  34793. * @param triggerOptions defines the trigger options
  34794. * @param target defines the object containing the value to interpolate
  34795. * @param propertyPath defines the path to the property in the target object
  34796. * @param value defines the target value at the end of the interpolation
  34797. * @param duration deines the time it will take for the property to interpolate to the value.
  34798. * @param condition defines the trigger related conditions
  34799. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34800. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34801. */
  34802. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34803. /** @hidden */
  34804. _prepare(): void;
  34805. /**
  34806. * Execute the action starts the value interpolation.
  34807. */
  34808. execute(): void;
  34809. /**
  34810. * Serializes the actions and its related information.
  34811. * @param parent defines the object to serialize in
  34812. * @returns the serialized object
  34813. */
  34814. serialize(parent: any): any;
  34815. }
  34816. }
  34817. declare module "babylonjs/Actions/index" {
  34818. export * from "babylonjs/Actions/action";
  34819. export * from "babylonjs/Actions/actionEvent";
  34820. export * from "babylonjs/Actions/actionManager";
  34821. export * from "babylonjs/Actions/condition";
  34822. export * from "babylonjs/Actions/directActions";
  34823. export * from "babylonjs/Actions/directAudioActions";
  34824. export * from "babylonjs/Actions/interpolateValueAction";
  34825. }
  34826. declare module "babylonjs/Animations/index" {
  34827. export * from "babylonjs/Animations/animatable";
  34828. export * from "babylonjs/Animations/animation";
  34829. export * from "babylonjs/Animations/animationGroup";
  34830. export * from "babylonjs/Animations/animationPropertiesOverride";
  34831. export * from "babylonjs/Animations/easing";
  34832. export * from "babylonjs/Animations/runtimeAnimation";
  34833. export * from "babylonjs/Animations/animationEvent";
  34834. export * from "babylonjs/Animations/animationGroup";
  34835. export * from "babylonjs/Animations/animationKey";
  34836. export * from "babylonjs/Animations/animationRange";
  34837. }
  34838. declare module "babylonjs/Audio/soundTrack" {
  34839. import { Sound } from "babylonjs/Audio/sound";
  34840. import { Analyser } from "babylonjs/Audio/analyser";
  34841. import { Scene } from "babylonjs/scene";
  34842. /**
  34843. * Options allowed during the creation of a sound track.
  34844. */
  34845. export interface ISoundTrackOptions {
  34846. /**
  34847. * The volume the sound track should take during creation
  34848. */
  34849. volume?: number;
  34850. /**
  34851. * Define if the sound track is the main sound track of the scene
  34852. */
  34853. mainTrack?: boolean;
  34854. }
  34855. /**
  34856. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34857. * It will be also used in a future release to apply effects on a specific track.
  34858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34859. */
  34860. export class SoundTrack {
  34861. /**
  34862. * The unique identifier of the sound track in the scene.
  34863. */
  34864. id: number;
  34865. /**
  34866. * The list of sounds included in the sound track.
  34867. */
  34868. soundCollection: Array<Sound>;
  34869. private _outputAudioNode;
  34870. private _scene;
  34871. private _isMainTrack;
  34872. private _connectedAnalyser;
  34873. private _options;
  34874. private _isInitialized;
  34875. /**
  34876. * Creates a new sound track.
  34877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34878. * @param scene Define the scene the sound track belongs to
  34879. * @param options
  34880. */
  34881. constructor(scene: Scene, options?: ISoundTrackOptions);
  34882. private _initializeSoundTrackAudioGraph;
  34883. /**
  34884. * Release the sound track and its associated resources
  34885. */
  34886. dispose(): void;
  34887. /**
  34888. * Adds a sound to this sound track
  34889. * @param sound define the cound to add
  34890. * @ignoreNaming
  34891. */
  34892. AddSound(sound: Sound): void;
  34893. /**
  34894. * Removes a sound to this sound track
  34895. * @param sound define the cound to remove
  34896. * @ignoreNaming
  34897. */
  34898. RemoveSound(sound: Sound): void;
  34899. /**
  34900. * Set a global volume for the full sound track.
  34901. * @param newVolume Define the new volume of the sound track
  34902. */
  34903. setVolume(newVolume: number): void;
  34904. /**
  34905. * Switch the panning model to HRTF:
  34906. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34908. */
  34909. switchPanningModelToHRTF(): void;
  34910. /**
  34911. * Switch the panning model to Equal Power:
  34912. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34914. */
  34915. switchPanningModelToEqualPower(): void;
  34916. /**
  34917. * Connect the sound track to an audio analyser allowing some amazing
  34918. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34919. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34920. * @param analyser The analyser to connect to the engine
  34921. */
  34922. connectToAnalyser(analyser: Analyser): void;
  34923. }
  34924. }
  34925. declare module "babylonjs/Audio/audioSceneComponent" {
  34926. import { Sound } from "babylonjs/Audio/sound";
  34927. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34928. import { Nullable } from "babylonjs/types";
  34929. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34930. import { Scene } from "babylonjs/scene";
  34931. import { AbstractScene } from "babylonjs/abstractScene";
  34932. module "babylonjs/abstractScene" {
  34933. interface AbstractScene {
  34934. /**
  34935. * The list of sounds used in the scene.
  34936. */
  34937. sounds: Nullable<Array<Sound>>;
  34938. }
  34939. }
  34940. module "babylonjs/scene" {
  34941. interface Scene {
  34942. /**
  34943. * @hidden
  34944. * Backing field
  34945. */
  34946. _mainSoundTrack: SoundTrack;
  34947. /**
  34948. * The main sound track played by the scene.
  34949. * It cotains your primary collection of sounds.
  34950. */
  34951. mainSoundTrack: SoundTrack;
  34952. /**
  34953. * The list of sound tracks added to the scene
  34954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34955. */
  34956. soundTracks: Nullable<Array<SoundTrack>>;
  34957. /**
  34958. * Gets a sound using a given name
  34959. * @param name defines the name to search for
  34960. * @return the found sound or null if not found at all.
  34961. */
  34962. getSoundByName(name: string): Nullable<Sound>;
  34963. /**
  34964. * Gets or sets if audio support is enabled
  34965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34966. */
  34967. audioEnabled: boolean;
  34968. /**
  34969. * Gets or sets if audio will be output to headphones
  34970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34971. */
  34972. headphone: boolean;
  34973. }
  34974. }
  34975. /**
  34976. * Defines the sound scene component responsible to manage any sounds
  34977. * in a given scene.
  34978. */
  34979. export class AudioSceneComponent implements ISceneSerializableComponent {
  34980. /**
  34981. * The component name helpfull to identify the component in the list of scene components.
  34982. */
  34983. readonly name: string;
  34984. /**
  34985. * The scene the component belongs to.
  34986. */
  34987. scene: Scene;
  34988. private _audioEnabled;
  34989. /**
  34990. * Gets whether audio is enabled or not.
  34991. * Please use related enable/disable method to switch state.
  34992. */
  34993. readonly audioEnabled: boolean;
  34994. private _headphone;
  34995. /**
  34996. * Gets whether audio is outputing to headphone or not.
  34997. * Please use the according Switch methods to change output.
  34998. */
  34999. readonly headphone: boolean;
  35000. /**
  35001. * Creates a new instance of the component for the given scene
  35002. * @param scene Defines the scene to register the component in
  35003. */
  35004. constructor(scene: Scene);
  35005. /**
  35006. * Registers the component in a given scene
  35007. */
  35008. register(): void;
  35009. /**
  35010. * Rebuilds the elements related to this component in case of
  35011. * context lost for instance.
  35012. */
  35013. rebuild(): void;
  35014. /**
  35015. * Serializes the component data to the specified json object
  35016. * @param serializationObject The object to serialize to
  35017. */
  35018. serialize(serializationObject: any): void;
  35019. /**
  35020. * Adds all the element from the container to the scene
  35021. * @param container the container holding the elements
  35022. */
  35023. addFromContainer(container: AbstractScene): void;
  35024. /**
  35025. * Removes all the elements in the container from the scene
  35026. * @param container contains the elements to remove
  35027. * @param dispose if the removed element should be disposed (default: false)
  35028. */
  35029. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35030. /**
  35031. * Disposes the component and the associated ressources.
  35032. */
  35033. dispose(): void;
  35034. /**
  35035. * Disables audio in the associated scene.
  35036. */
  35037. disableAudio(): void;
  35038. /**
  35039. * Enables audio in the associated scene.
  35040. */
  35041. enableAudio(): void;
  35042. /**
  35043. * Switch audio to headphone output.
  35044. */
  35045. switchAudioModeForHeadphones(): void;
  35046. /**
  35047. * Switch audio to normal speakers.
  35048. */
  35049. switchAudioModeForNormalSpeakers(): void;
  35050. private _afterRender;
  35051. }
  35052. }
  35053. declare module "babylonjs/Audio/weightedsound" {
  35054. import { Sound } from "babylonjs/Audio/sound";
  35055. /**
  35056. * Wraps one or more Sound objects and selects one with random weight for playback.
  35057. */
  35058. export class WeightedSound {
  35059. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35060. loop: boolean;
  35061. private _coneInnerAngle;
  35062. private _coneOuterAngle;
  35063. private _volume;
  35064. /** A Sound is currently playing. */
  35065. isPlaying: boolean;
  35066. /** A Sound is currently paused. */
  35067. isPaused: boolean;
  35068. private _sounds;
  35069. private _weights;
  35070. private _currentIndex?;
  35071. /**
  35072. * Creates a new WeightedSound from the list of sounds given.
  35073. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35074. * @param sounds Array of Sounds that will be selected from.
  35075. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35076. */
  35077. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35078. /**
  35079. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35080. */
  35081. /**
  35082. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35083. */
  35084. directionalConeInnerAngle: number;
  35085. /**
  35086. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35087. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35088. */
  35089. /**
  35090. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35091. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35092. */
  35093. directionalConeOuterAngle: number;
  35094. /**
  35095. * Playback volume.
  35096. */
  35097. /**
  35098. * Playback volume.
  35099. */
  35100. volume: number;
  35101. private _onended;
  35102. /**
  35103. * Suspend playback
  35104. */
  35105. pause(): void;
  35106. /**
  35107. * Stop playback
  35108. */
  35109. stop(): void;
  35110. /**
  35111. * Start playback.
  35112. * @param startOffset Position the clip head at a specific time in seconds.
  35113. */
  35114. play(startOffset?: number): void;
  35115. }
  35116. }
  35117. declare module "babylonjs/Audio/index" {
  35118. export * from "babylonjs/Audio/analyser";
  35119. export * from "babylonjs/Audio/audioEngine";
  35120. export * from "babylonjs/Audio/audioSceneComponent";
  35121. export * from "babylonjs/Audio/sound";
  35122. export * from "babylonjs/Audio/soundTrack";
  35123. export * from "babylonjs/Audio/weightedsound";
  35124. }
  35125. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35126. import { Behavior } from "babylonjs/Behaviors/behavior";
  35127. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35128. import { BackEase } from "babylonjs/Animations/easing";
  35129. /**
  35130. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35131. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35132. */
  35133. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35134. /**
  35135. * Gets the name of the behavior.
  35136. */
  35137. readonly name: string;
  35138. /**
  35139. * The easing function used by animations
  35140. */
  35141. static EasingFunction: BackEase;
  35142. /**
  35143. * The easing mode used by animations
  35144. */
  35145. static EasingMode: number;
  35146. /**
  35147. * The duration of the animation, in milliseconds
  35148. */
  35149. transitionDuration: number;
  35150. /**
  35151. * Length of the distance animated by the transition when lower radius is reached
  35152. */
  35153. lowerRadiusTransitionRange: number;
  35154. /**
  35155. * Length of the distance animated by the transition when upper radius is reached
  35156. */
  35157. upperRadiusTransitionRange: number;
  35158. private _autoTransitionRange;
  35159. /**
  35160. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35161. */
  35162. /**
  35163. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35164. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35165. */
  35166. autoTransitionRange: boolean;
  35167. private _attachedCamera;
  35168. private _onAfterCheckInputsObserver;
  35169. private _onMeshTargetChangedObserver;
  35170. /**
  35171. * Initializes the behavior.
  35172. */
  35173. init(): void;
  35174. /**
  35175. * Attaches the behavior to its arc rotate camera.
  35176. * @param camera Defines the camera to attach the behavior to
  35177. */
  35178. attach(camera: ArcRotateCamera): void;
  35179. /**
  35180. * Detaches the behavior from its current arc rotate camera.
  35181. */
  35182. detach(): void;
  35183. private _radiusIsAnimating;
  35184. private _radiusBounceTransition;
  35185. private _animatables;
  35186. private _cachedWheelPrecision;
  35187. /**
  35188. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35189. * @param radiusLimit The limit to check against.
  35190. * @return Bool to indicate if at limit.
  35191. */
  35192. private _isRadiusAtLimit;
  35193. /**
  35194. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35195. * @param radiusDelta The delta by which to animate to. Can be negative.
  35196. */
  35197. private _applyBoundRadiusAnimation;
  35198. /**
  35199. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35200. */
  35201. protected _clearAnimationLocks(): void;
  35202. /**
  35203. * Stops and removes all animations that have been applied to the camera
  35204. */
  35205. stopAllAnimations(): void;
  35206. }
  35207. }
  35208. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35209. import { Behavior } from "babylonjs/Behaviors/behavior";
  35210. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35211. import { ExponentialEase } from "babylonjs/Animations/easing";
  35212. import { Nullable } from "babylonjs/types";
  35213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35214. import { Vector3 } from "babylonjs/Maths/math";
  35215. /**
  35216. * 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.
  35217. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35218. */
  35219. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35220. /**
  35221. * Gets the name of the behavior.
  35222. */
  35223. readonly name: string;
  35224. private _mode;
  35225. private _radiusScale;
  35226. private _positionScale;
  35227. private _defaultElevation;
  35228. private _elevationReturnTime;
  35229. private _elevationReturnWaitTime;
  35230. private _zoomStopsAnimation;
  35231. private _framingTime;
  35232. /**
  35233. * The easing function used by animations
  35234. */
  35235. static EasingFunction: ExponentialEase;
  35236. /**
  35237. * The easing mode used by animations
  35238. */
  35239. static EasingMode: number;
  35240. /**
  35241. * Sets the current mode used by the behavior
  35242. */
  35243. /**
  35244. * Gets current mode used by the behavior.
  35245. */
  35246. mode: number;
  35247. /**
  35248. * Sets the scale applied to the radius (1 by default)
  35249. */
  35250. /**
  35251. * Gets the scale applied to the radius
  35252. */
  35253. radiusScale: number;
  35254. /**
  35255. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35256. */
  35257. /**
  35258. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35259. */
  35260. positionScale: number;
  35261. /**
  35262. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35263. * behaviour is triggered, in radians.
  35264. */
  35265. /**
  35266. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35267. * behaviour is triggered, in radians.
  35268. */
  35269. defaultElevation: number;
  35270. /**
  35271. * Sets the time (in milliseconds) taken to return to the default beta position.
  35272. * Negative value indicates camera should not return to default.
  35273. */
  35274. /**
  35275. * Gets the time (in milliseconds) taken to return to the default beta position.
  35276. * Negative value indicates camera should not return to default.
  35277. */
  35278. elevationReturnTime: number;
  35279. /**
  35280. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35281. */
  35282. /**
  35283. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35284. */
  35285. elevationReturnWaitTime: number;
  35286. /**
  35287. * Sets the flag that indicates if user zooming should stop animation.
  35288. */
  35289. /**
  35290. * Gets the flag that indicates if user zooming should stop animation.
  35291. */
  35292. zoomStopsAnimation: boolean;
  35293. /**
  35294. * Sets the transition time when framing the mesh, in milliseconds
  35295. */
  35296. /**
  35297. * Gets the transition time when framing the mesh, in milliseconds
  35298. */
  35299. framingTime: number;
  35300. /**
  35301. * Define if the behavior should automatically change the configured
  35302. * camera limits and sensibilities.
  35303. */
  35304. autoCorrectCameraLimitsAndSensibility: boolean;
  35305. private _onPrePointerObservableObserver;
  35306. private _onAfterCheckInputsObserver;
  35307. private _onMeshTargetChangedObserver;
  35308. private _attachedCamera;
  35309. private _isPointerDown;
  35310. private _lastInteractionTime;
  35311. /**
  35312. * Initializes the behavior.
  35313. */
  35314. init(): void;
  35315. /**
  35316. * Attaches the behavior to its arc rotate camera.
  35317. * @param camera Defines the camera to attach the behavior to
  35318. */
  35319. attach(camera: ArcRotateCamera): void;
  35320. /**
  35321. * Detaches the behavior from its current arc rotate camera.
  35322. */
  35323. detach(): void;
  35324. private _animatables;
  35325. private _betaIsAnimating;
  35326. private _betaTransition;
  35327. private _radiusTransition;
  35328. private _vectorTransition;
  35329. /**
  35330. * Targets the given mesh and updates zoom level accordingly.
  35331. * @param mesh The mesh to target.
  35332. * @param radius Optional. If a cached radius position already exists, overrides default.
  35333. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35334. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35335. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35336. */
  35337. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35338. /**
  35339. * Targets the given mesh with its children and updates zoom level accordingly.
  35340. * @param mesh The mesh to target.
  35341. * @param radius Optional. If a cached radius position already exists, overrides default.
  35342. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35343. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35344. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35345. */
  35346. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35347. /**
  35348. * Targets the given meshes with their children and updates zoom level accordingly.
  35349. * @param meshes The mesh to target.
  35350. * @param radius Optional. If a cached radius position already exists, overrides default.
  35351. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35352. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35353. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35354. */
  35355. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35356. /**
  35357. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35358. * @param minimumWorld Determines the smaller position of the bounding box extend
  35359. * @param maximumWorld Determines the bigger position of the bounding box extend
  35360. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35361. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35362. */
  35363. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35364. /**
  35365. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35366. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35367. * frustum width.
  35368. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35369. * to fully enclose the mesh in the viewing frustum.
  35370. */
  35371. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35372. /**
  35373. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35374. * is automatically returned to its default position (expected to be above ground plane).
  35375. */
  35376. private _maintainCameraAboveGround;
  35377. /**
  35378. * Returns the frustum slope based on the canvas ratio and camera FOV
  35379. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35380. */
  35381. private _getFrustumSlope;
  35382. /**
  35383. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35384. */
  35385. private _clearAnimationLocks;
  35386. /**
  35387. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35388. */
  35389. private _applyUserInteraction;
  35390. /**
  35391. * Stops and removes all animations that have been applied to the camera
  35392. */
  35393. stopAllAnimations(): void;
  35394. /**
  35395. * Gets a value indicating if the user is moving the camera
  35396. */
  35397. readonly isUserIsMoving: boolean;
  35398. /**
  35399. * The camera can move all the way towards the mesh.
  35400. */
  35401. static IgnoreBoundsSizeMode: number;
  35402. /**
  35403. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35404. */
  35405. static FitFrustumSidesMode: number;
  35406. }
  35407. }
  35408. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35409. import { Nullable } from "babylonjs/types";
  35410. import { Camera } from "babylonjs/Cameras/camera";
  35411. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35412. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35413. /**
  35414. * Base class for Camera Pointer Inputs.
  35415. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35416. * for example usage.
  35417. */
  35418. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35419. /**
  35420. * Defines the camera the input is attached to.
  35421. */
  35422. abstract camera: Camera;
  35423. /**
  35424. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35425. */
  35426. protected _altKey: boolean;
  35427. protected _ctrlKey: boolean;
  35428. protected _metaKey: boolean;
  35429. protected _shiftKey: boolean;
  35430. /**
  35431. * Which mouse buttons were pressed at time of last mouse event.
  35432. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35433. */
  35434. protected _buttonsPressed: number;
  35435. /**
  35436. * Defines the buttons associated with the input to handle camera move.
  35437. */
  35438. buttons: number[];
  35439. /**
  35440. * Attach the input controls to a specific dom element to get the input from.
  35441. * @param element Defines the element the controls should be listened from
  35442. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35443. */
  35444. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35445. /**
  35446. * Detach the current controls from the specified dom element.
  35447. * @param element Defines the element to stop listening the inputs from
  35448. */
  35449. detachControl(element: Nullable<HTMLElement>): void;
  35450. /**
  35451. * Gets the class name of the current input.
  35452. * @returns the class name
  35453. */
  35454. getClassName(): string;
  35455. /**
  35456. * Get the friendly name associated with the input class.
  35457. * @returns the input friendly name
  35458. */
  35459. getSimpleName(): string;
  35460. /**
  35461. * Called on pointer POINTERDOUBLETAP event.
  35462. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35463. */
  35464. protected onDoubleTap(type: string): void;
  35465. /**
  35466. * Called on pointer POINTERMOVE event if only a single touch is active.
  35467. * Override this method to provide functionality.
  35468. */
  35469. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35470. /**
  35471. * Called on pointer POINTERMOVE event if multiple touches are active.
  35472. * Override this method to provide functionality.
  35473. */
  35474. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35475. /**
  35476. * Called on JS contextmenu event.
  35477. * Override this method to provide functionality.
  35478. */
  35479. protected onContextMenu(evt: PointerEvent): void;
  35480. /**
  35481. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35482. * press.
  35483. * Override this method to provide functionality.
  35484. */
  35485. protected onButtonDown(evt: PointerEvent): void;
  35486. /**
  35487. * Called each time a new POINTERUP event occurs. Ie, for each button
  35488. * release.
  35489. * Override this method to provide functionality.
  35490. */
  35491. protected onButtonUp(evt: PointerEvent): void;
  35492. /**
  35493. * Called when window becomes inactive.
  35494. * Override this method to provide functionality.
  35495. */
  35496. protected onLostFocus(): void;
  35497. private _pointerInput;
  35498. private _observer;
  35499. private _onLostFocus;
  35500. private pointA;
  35501. private pointB;
  35502. }
  35503. }
  35504. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35505. import { Nullable } from "babylonjs/types";
  35506. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35507. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35508. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35509. /**
  35510. * Manage the pointers inputs to control an arc rotate camera.
  35511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35512. */
  35513. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35514. /**
  35515. * Defines the camera the input is attached to.
  35516. */
  35517. camera: ArcRotateCamera;
  35518. /**
  35519. * Gets the class name of the current input.
  35520. * @returns the class name
  35521. */
  35522. getClassName(): string;
  35523. /**
  35524. * Defines the buttons associated with the input to handle camera move.
  35525. */
  35526. buttons: number[];
  35527. /**
  35528. * Defines the pointer angular sensibility along the X axis or how fast is
  35529. * the camera rotating.
  35530. */
  35531. angularSensibilityX: number;
  35532. /**
  35533. * Defines the pointer angular sensibility along the Y axis or how fast is
  35534. * the camera rotating.
  35535. */
  35536. angularSensibilityY: number;
  35537. /**
  35538. * Defines the pointer pinch precision or how fast is the camera zooming.
  35539. */
  35540. pinchPrecision: number;
  35541. /**
  35542. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35543. * from 0.
  35544. * It defines the percentage of current camera.radius to use as delta when
  35545. * pinch zoom is used.
  35546. */
  35547. pinchDeltaPercentage: number;
  35548. /**
  35549. * Defines the pointer panning sensibility or how fast is the camera moving.
  35550. */
  35551. panningSensibility: number;
  35552. /**
  35553. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35554. */
  35555. multiTouchPanning: boolean;
  35556. /**
  35557. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35558. * zoom (pinch) through multitouch.
  35559. */
  35560. multiTouchPanAndZoom: boolean;
  35561. /**
  35562. * Revers pinch action direction.
  35563. */
  35564. pinchInwards: boolean;
  35565. private _isPanClick;
  35566. private _twoFingerActivityCount;
  35567. private _isPinching;
  35568. /**
  35569. * Called on pointer POINTERMOVE event if only a single touch is active.
  35570. */
  35571. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35572. /**
  35573. * Called on pointer POINTERDOUBLETAP event.
  35574. */
  35575. protected onDoubleTap(type: string): void;
  35576. /**
  35577. * Called on pointer POINTERMOVE event if multiple touches are active.
  35578. */
  35579. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35580. /**
  35581. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35582. * press.
  35583. */
  35584. protected onButtonDown(evt: PointerEvent): void;
  35585. /**
  35586. * Called each time a new POINTERUP event occurs. Ie, for each button
  35587. * release.
  35588. */
  35589. protected onButtonUp(evt: PointerEvent): void;
  35590. /**
  35591. * Called when window becomes inactive.
  35592. */
  35593. protected onLostFocus(): void;
  35594. }
  35595. }
  35596. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35597. import { Nullable } from "babylonjs/types";
  35598. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35599. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35600. /**
  35601. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35602. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35603. */
  35604. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35605. /**
  35606. * Defines the camera the input is attached to.
  35607. */
  35608. camera: ArcRotateCamera;
  35609. /**
  35610. * Defines the list of key codes associated with the up action (increase alpha)
  35611. */
  35612. keysUp: number[];
  35613. /**
  35614. * Defines the list of key codes associated with the down action (decrease alpha)
  35615. */
  35616. keysDown: number[];
  35617. /**
  35618. * Defines the list of key codes associated with the left action (increase beta)
  35619. */
  35620. keysLeft: number[];
  35621. /**
  35622. * Defines the list of key codes associated with the right action (decrease beta)
  35623. */
  35624. keysRight: number[];
  35625. /**
  35626. * Defines the list of key codes associated with the reset action.
  35627. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35628. */
  35629. keysReset: number[];
  35630. /**
  35631. * Defines the panning sensibility of the inputs.
  35632. * (How fast is the camera paning)
  35633. */
  35634. panningSensibility: number;
  35635. /**
  35636. * Defines the zooming sensibility of the inputs.
  35637. * (How fast is the camera zooming)
  35638. */
  35639. zoomingSensibility: number;
  35640. /**
  35641. * Defines wether maintaining the alt key down switch the movement mode from
  35642. * orientation to zoom.
  35643. */
  35644. useAltToZoom: boolean;
  35645. /**
  35646. * Rotation speed of the camera
  35647. */
  35648. angularSpeed: number;
  35649. private _keys;
  35650. private _ctrlPressed;
  35651. private _altPressed;
  35652. private _onCanvasBlurObserver;
  35653. private _onKeyboardObserver;
  35654. private _engine;
  35655. private _scene;
  35656. /**
  35657. * Attach the input controls to a specific dom element to get the input from.
  35658. * @param element Defines the element the controls should be listened from
  35659. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35660. */
  35661. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35662. /**
  35663. * Detach the current controls from the specified dom element.
  35664. * @param element Defines the element to stop listening the inputs from
  35665. */
  35666. detachControl(element: Nullable<HTMLElement>): void;
  35667. /**
  35668. * Update the current camera state depending on the inputs that have been used this frame.
  35669. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35670. */
  35671. checkInputs(): void;
  35672. /**
  35673. * Gets the class name of the current intput.
  35674. * @returns the class name
  35675. */
  35676. getClassName(): string;
  35677. /**
  35678. * Get the friendly name associated with the input class.
  35679. * @returns the input friendly name
  35680. */
  35681. getSimpleName(): string;
  35682. }
  35683. }
  35684. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35685. import { Nullable } from "babylonjs/types";
  35686. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35687. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35688. /**
  35689. * Manage the mouse wheel inputs to control an arc rotate camera.
  35690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35691. */
  35692. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35693. /**
  35694. * Defines the camera the input is attached to.
  35695. */
  35696. camera: ArcRotateCamera;
  35697. /**
  35698. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35699. */
  35700. wheelPrecision: number;
  35701. /**
  35702. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35703. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35704. */
  35705. wheelDeltaPercentage: number;
  35706. private _wheel;
  35707. private _observer;
  35708. /**
  35709. * Attach the input controls to a specific dom element to get the input from.
  35710. * @param element Defines the element the controls should be listened from
  35711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35712. */
  35713. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35714. /**
  35715. * Detach the current controls from the specified dom element.
  35716. * @param element Defines the element to stop listening the inputs from
  35717. */
  35718. detachControl(element: Nullable<HTMLElement>): void;
  35719. /**
  35720. * Gets the class name of the current intput.
  35721. * @returns the class name
  35722. */
  35723. getClassName(): string;
  35724. /**
  35725. * Get the friendly name associated with the input class.
  35726. * @returns the input friendly name
  35727. */
  35728. getSimpleName(): string;
  35729. }
  35730. }
  35731. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35732. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35733. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35734. /**
  35735. * Default Inputs manager for the ArcRotateCamera.
  35736. * It groups all the default supported inputs for ease of use.
  35737. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35738. */
  35739. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35740. /**
  35741. * Instantiates a new ArcRotateCameraInputsManager.
  35742. * @param camera Defines the camera the inputs belong to
  35743. */
  35744. constructor(camera: ArcRotateCamera);
  35745. /**
  35746. * Add mouse wheel input support to the input manager.
  35747. * @returns the current input manager
  35748. */
  35749. addMouseWheel(): ArcRotateCameraInputsManager;
  35750. /**
  35751. * Add pointers input support to the input manager.
  35752. * @returns the current input manager
  35753. */
  35754. addPointers(): ArcRotateCameraInputsManager;
  35755. /**
  35756. * Add keyboard input support to the input manager.
  35757. * @returns the current input manager
  35758. */
  35759. addKeyboard(): ArcRotateCameraInputsManager;
  35760. }
  35761. }
  35762. declare module "babylonjs/Cameras/arcRotateCamera" {
  35763. import { Observable } from "babylonjs/Misc/observable";
  35764. import { Nullable } from "babylonjs/types";
  35765. import { Scene } from "babylonjs/scene";
  35766. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35768. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35769. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35770. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35771. import { Camera } from "babylonjs/Cameras/camera";
  35772. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35773. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35774. import { Collider } from "babylonjs/Collisions/collider";
  35775. /**
  35776. * This represents an orbital type of camera.
  35777. *
  35778. * 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.
  35779. * 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.
  35780. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35781. */
  35782. export class ArcRotateCamera extends TargetCamera {
  35783. /**
  35784. * Defines the rotation angle of the camera along the longitudinal axis.
  35785. */
  35786. alpha: number;
  35787. /**
  35788. * Defines the rotation angle of the camera along the latitudinal axis.
  35789. */
  35790. beta: number;
  35791. /**
  35792. * Defines the radius of the camera from it s target point.
  35793. */
  35794. radius: number;
  35795. protected _target: Vector3;
  35796. protected _targetHost: Nullable<AbstractMesh>;
  35797. /**
  35798. * Defines the target point of the camera.
  35799. * The camera looks towards it form the radius distance.
  35800. */
  35801. target: Vector3;
  35802. /**
  35803. * Define the current local position of the camera in the scene
  35804. */
  35805. position: Vector3;
  35806. protected _upVector: Vector3;
  35807. protected _upToYMatrix: Matrix;
  35808. protected _YToUpMatrix: Matrix;
  35809. /**
  35810. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35811. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35812. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35813. */
  35814. upVector: Vector3;
  35815. /**
  35816. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35817. */
  35818. setMatUp(): void;
  35819. /**
  35820. * Current inertia value on the longitudinal axis.
  35821. * The bigger this number the longer it will take for the camera to stop.
  35822. */
  35823. inertialAlphaOffset: number;
  35824. /**
  35825. * Current inertia value on the latitudinal axis.
  35826. * The bigger this number the longer it will take for the camera to stop.
  35827. */
  35828. inertialBetaOffset: number;
  35829. /**
  35830. * Current inertia value on the radius axis.
  35831. * The bigger this number the longer it will take for the camera to stop.
  35832. */
  35833. inertialRadiusOffset: number;
  35834. /**
  35835. * Minimum allowed angle on the longitudinal axis.
  35836. * This can help limiting how the Camera is able to move in the scene.
  35837. */
  35838. lowerAlphaLimit: Nullable<number>;
  35839. /**
  35840. * Maximum allowed angle on the longitudinal axis.
  35841. * This can help limiting how the Camera is able to move in the scene.
  35842. */
  35843. upperAlphaLimit: Nullable<number>;
  35844. /**
  35845. * Minimum allowed angle on the latitudinal axis.
  35846. * This can help limiting how the Camera is able to move in the scene.
  35847. */
  35848. lowerBetaLimit: number;
  35849. /**
  35850. * Maximum allowed angle on the latitudinal axis.
  35851. * This can help limiting how the Camera is able to move in the scene.
  35852. */
  35853. upperBetaLimit: number;
  35854. /**
  35855. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35856. * This can help limiting how the Camera is able to move in the scene.
  35857. */
  35858. lowerRadiusLimit: Nullable<number>;
  35859. /**
  35860. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35861. * This can help limiting how the Camera is able to move in the scene.
  35862. */
  35863. upperRadiusLimit: Nullable<number>;
  35864. /**
  35865. * Defines the current inertia value used during panning of the camera along the X axis.
  35866. */
  35867. inertialPanningX: number;
  35868. /**
  35869. * Defines the current inertia value used during panning of the camera along the Y axis.
  35870. */
  35871. inertialPanningY: number;
  35872. /**
  35873. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35874. * Basically if your fingers moves away from more than this distance you will be considered
  35875. * in pinch mode.
  35876. */
  35877. pinchToPanMaxDistance: number;
  35878. /**
  35879. * Defines the maximum distance the camera can pan.
  35880. * This could help keeping the cammera always in your scene.
  35881. */
  35882. panningDistanceLimit: Nullable<number>;
  35883. /**
  35884. * Defines the target of the camera before paning.
  35885. */
  35886. panningOriginTarget: Vector3;
  35887. /**
  35888. * Defines the value of the inertia used during panning.
  35889. * 0 would mean stop inertia and one would mean no decelleration at all.
  35890. */
  35891. panningInertia: number;
  35892. /**
  35893. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35894. */
  35895. angularSensibilityX: number;
  35896. /**
  35897. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35898. */
  35899. angularSensibilityY: number;
  35900. /**
  35901. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35902. */
  35903. pinchPrecision: number;
  35904. /**
  35905. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35906. * It will be used instead of pinchDeltaPrecision if different from 0.
  35907. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35908. */
  35909. pinchDeltaPercentage: number;
  35910. /**
  35911. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35912. */
  35913. panningSensibility: number;
  35914. /**
  35915. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35916. */
  35917. keysUp: number[];
  35918. /**
  35919. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35920. */
  35921. keysDown: number[];
  35922. /**
  35923. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35924. */
  35925. keysLeft: number[];
  35926. /**
  35927. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35928. */
  35929. keysRight: number[];
  35930. /**
  35931. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35932. */
  35933. wheelPrecision: number;
  35934. /**
  35935. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35936. * It will be used instead of pinchDeltaPrecision if different from 0.
  35937. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35938. */
  35939. wheelDeltaPercentage: number;
  35940. /**
  35941. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35942. */
  35943. zoomOnFactor: number;
  35944. /**
  35945. * Defines a screen offset for the camera position.
  35946. */
  35947. targetScreenOffset: Vector2;
  35948. /**
  35949. * Allows the camera to be completely reversed.
  35950. * If false the camera can not arrive upside down.
  35951. */
  35952. allowUpsideDown: boolean;
  35953. /**
  35954. * Define if double tap/click is used to restore the previously saved state of the camera.
  35955. */
  35956. useInputToRestoreState: boolean;
  35957. /** @hidden */
  35958. _viewMatrix: Matrix;
  35959. /** @hidden */
  35960. _useCtrlForPanning: boolean;
  35961. /** @hidden */
  35962. _panningMouseButton: number;
  35963. /**
  35964. * Defines the input associated to the camera.
  35965. */
  35966. inputs: ArcRotateCameraInputsManager;
  35967. /** @hidden */
  35968. _reset: () => void;
  35969. /**
  35970. * Defines the allowed panning axis.
  35971. */
  35972. panningAxis: Vector3;
  35973. protected _localDirection: Vector3;
  35974. protected _transformedDirection: Vector3;
  35975. private _bouncingBehavior;
  35976. /**
  35977. * Gets the bouncing behavior of the camera if it has been enabled.
  35978. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35979. */
  35980. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35981. /**
  35982. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35983. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35984. */
  35985. useBouncingBehavior: boolean;
  35986. private _framingBehavior;
  35987. /**
  35988. * Gets the framing behavior of the camera if it has been enabled.
  35989. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35990. */
  35991. readonly framingBehavior: Nullable<FramingBehavior>;
  35992. /**
  35993. * Defines if the framing behavior of the camera is enabled on the camera.
  35994. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35995. */
  35996. useFramingBehavior: boolean;
  35997. private _autoRotationBehavior;
  35998. /**
  35999. * Gets the auto rotation behavior of the camera if it has been enabled.
  36000. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36001. */
  36002. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36003. /**
  36004. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36005. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36006. */
  36007. useAutoRotationBehavior: boolean;
  36008. /**
  36009. * Observable triggered when the mesh target has been changed on the camera.
  36010. */
  36011. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36012. /**
  36013. * Event raised when the camera is colliding with a mesh.
  36014. */
  36015. onCollide: (collidedMesh: AbstractMesh) => void;
  36016. /**
  36017. * Defines whether the camera should check collision with the objects oh the scene.
  36018. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36019. */
  36020. checkCollisions: boolean;
  36021. /**
  36022. * Defines the collision radius of the camera.
  36023. * This simulates a sphere around the camera.
  36024. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36025. */
  36026. collisionRadius: Vector3;
  36027. protected _collider: Collider;
  36028. protected _previousPosition: Vector3;
  36029. protected _collisionVelocity: Vector3;
  36030. protected _newPosition: Vector3;
  36031. protected _previousAlpha: number;
  36032. protected _previousBeta: number;
  36033. protected _previousRadius: number;
  36034. protected _collisionTriggered: boolean;
  36035. protected _targetBoundingCenter: Nullable<Vector3>;
  36036. private _computationVector;
  36037. /**
  36038. * Instantiates a new ArcRotateCamera in a given scene
  36039. * @param name Defines the name of the camera
  36040. * @param alpha Defines the camera rotation along the logitudinal axis
  36041. * @param beta Defines the camera rotation along the latitudinal axis
  36042. * @param radius Defines the camera distance from its target
  36043. * @param target Defines the camera target
  36044. * @param scene Defines the scene the camera belongs to
  36045. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36046. */
  36047. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36048. /** @hidden */
  36049. _initCache(): void;
  36050. /** @hidden */
  36051. _updateCache(ignoreParentClass?: boolean): void;
  36052. protected _getTargetPosition(): Vector3;
  36053. private _storedAlpha;
  36054. private _storedBeta;
  36055. private _storedRadius;
  36056. private _storedTarget;
  36057. /**
  36058. * Stores the current state of the camera (alpha, beta, radius and target)
  36059. * @returns the camera itself
  36060. */
  36061. storeState(): Camera;
  36062. /**
  36063. * @hidden
  36064. * Restored camera state. You must call storeState() first
  36065. */
  36066. _restoreStateValues(): boolean;
  36067. /** @hidden */
  36068. _isSynchronizedViewMatrix(): boolean;
  36069. /**
  36070. * Attached controls to the current camera.
  36071. * @param element Defines the element the controls should be listened from
  36072. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36073. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36074. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36075. */
  36076. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36077. /**
  36078. * Detach the current controls from the camera.
  36079. * The camera will stop reacting to inputs.
  36080. * @param element Defines the element to stop listening the inputs from
  36081. */
  36082. detachControl(element: HTMLElement): void;
  36083. /** @hidden */
  36084. _checkInputs(): void;
  36085. protected _checkLimits(): void;
  36086. /**
  36087. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36088. */
  36089. rebuildAnglesAndRadius(): void;
  36090. /**
  36091. * Use a position to define the current camera related information like aplha, beta and radius
  36092. * @param position Defines the position to set the camera at
  36093. */
  36094. setPosition(position: Vector3): void;
  36095. /**
  36096. * Defines the target the camera should look at.
  36097. * This will automatically adapt alpha beta and radius to fit within the new target.
  36098. * @param target Defines the new target as a Vector or a mesh
  36099. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36100. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36101. */
  36102. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36103. /** @hidden */
  36104. _getViewMatrix(): Matrix;
  36105. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36106. /**
  36107. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36108. * @param meshes Defines the mesh to zoom on
  36109. * @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)
  36110. */
  36111. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36112. /**
  36113. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36114. * The target will be changed but the radius
  36115. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36116. * @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)
  36117. */
  36118. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36119. min: Vector3;
  36120. max: Vector3;
  36121. distance: number;
  36122. }, doNotUpdateMaxZ?: boolean): void;
  36123. /**
  36124. * @override
  36125. * Override Camera.createRigCamera
  36126. */
  36127. createRigCamera(name: string, cameraIndex: number): Camera;
  36128. /**
  36129. * @hidden
  36130. * @override
  36131. * Override Camera._updateRigCameras
  36132. */
  36133. _updateRigCameras(): void;
  36134. /**
  36135. * Destroy the camera and release the current resources hold by it.
  36136. */
  36137. dispose(): void;
  36138. /**
  36139. * Gets the current object class name.
  36140. * @return the class name
  36141. */
  36142. getClassName(): string;
  36143. }
  36144. }
  36145. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36146. import { Behavior } from "babylonjs/Behaviors/behavior";
  36147. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36148. /**
  36149. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36150. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36151. */
  36152. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36153. /**
  36154. * Gets the name of the behavior.
  36155. */
  36156. readonly name: string;
  36157. private _zoomStopsAnimation;
  36158. private _idleRotationSpeed;
  36159. private _idleRotationWaitTime;
  36160. private _idleRotationSpinupTime;
  36161. /**
  36162. * Sets the flag that indicates if user zooming should stop animation.
  36163. */
  36164. /**
  36165. * Gets the flag that indicates if user zooming should stop animation.
  36166. */
  36167. zoomStopsAnimation: boolean;
  36168. /**
  36169. * Sets the default speed at which the camera rotates around the model.
  36170. */
  36171. /**
  36172. * Gets the default speed at which the camera rotates around the model.
  36173. */
  36174. idleRotationSpeed: number;
  36175. /**
  36176. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36177. */
  36178. /**
  36179. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36180. */
  36181. idleRotationWaitTime: number;
  36182. /**
  36183. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36184. */
  36185. /**
  36186. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36187. */
  36188. idleRotationSpinupTime: number;
  36189. /**
  36190. * Gets a value indicating if the camera is currently rotating because of this behavior
  36191. */
  36192. readonly rotationInProgress: boolean;
  36193. private _onPrePointerObservableObserver;
  36194. private _onAfterCheckInputsObserver;
  36195. private _attachedCamera;
  36196. private _isPointerDown;
  36197. private _lastFrameTime;
  36198. private _lastInteractionTime;
  36199. private _cameraRotationSpeed;
  36200. /**
  36201. * Initializes the behavior.
  36202. */
  36203. init(): void;
  36204. /**
  36205. * Attaches the behavior to its arc rotate camera.
  36206. * @param camera Defines the camera to attach the behavior to
  36207. */
  36208. attach(camera: ArcRotateCamera): void;
  36209. /**
  36210. * Detaches the behavior from its current arc rotate camera.
  36211. */
  36212. detach(): void;
  36213. /**
  36214. * Returns true if user is scrolling.
  36215. * @return true if user is scrolling.
  36216. */
  36217. private _userIsZooming;
  36218. private _lastFrameRadius;
  36219. private _shouldAnimationStopForInteraction;
  36220. /**
  36221. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36222. */
  36223. private _applyUserInteraction;
  36224. private _userIsMoving;
  36225. }
  36226. }
  36227. declare module "babylonjs/Behaviors/Cameras/index" {
  36228. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36229. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36230. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36231. }
  36232. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36233. import { Mesh } from "babylonjs/Meshes/mesh";
  36234. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36235. import { Behavior } from "babylonjs/Behaviors/behavior";
  36236. /**
  36237. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36238. */
  36239. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36240. private ui;
  36241. /**
  36242. * The name of the behavior
  36243. */
  36244. name: string;
  36245. /**
  36246. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36247. */
  36248. distanceAwayFromFace: number;
  36249. /**
  36250. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36251. */
  36252. distanceAwayFromBottomOfFace: number;
  36253. private _faceVectors;
  36254. private _target;
  36255. private _scene;
  36256. private _onRenderObserver;
  36257. private _tmpMatrix;
  36258. private _tmpVector;
  36259. /**
  36260. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36261. * @param ui The transform node that should be attched to the mesh
  36262. */
  36263. constructor(ui: TransformNode);
  36264. /**
  36265. * Initializes the behavior
  36266. */
  36267. init(): void;
  36268. private _closestFace;
  36269. private _zeroVector;
  36270. private _lookAtTmpMatrix;
  36271. private _lookAtToRef;
  36272. /**
  36273. * Attaches the AttachToBoxBehavior to the passed in mesh
  36274. * @param target The mesh that the specified node will be attached to
  36275. */
  36276. attach(target: Mesh): void;
  36277. /**
  36278. * Detaches the behavior from the mesh
  36279. */
  36280. detach(): void;
  36281. }
  36282. }
  36283. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36284. import { Behavior } from "babylonjs/Behaviors/behavior";
  36285. import { Mesh } from "babylonjs/Meshes/mesh";
  36286. /**
  36287. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36288. */
  36289. export class FadeInOutBehavior implements Behavior<Mesh> {
  36290. /**
  36291. * Time in milliseconds to delay before fading in (Default: 0)
  36292. */
  36293. delay: number;
  36294. /**
  36295. * Time in milliseconds for the mesh to fade in (Default: 300)
  36296. */
  36297. fadeInTime: number;
  36298. private _millisecondsPerFrame;
  36299. private _hovered;
  36300. private _hoverValue;
  36301. private _ownerNode;
  36302. /**
  36303. * Instatiates the FadeInOutBehavior
  36304. */
  36305. constructor();
  36306. /**
  36307. * The name of the behavior
  36308. */
  36309. readonly name: string;
  36310. /**
  36311. * Initializes the behavior
  36312. */
  36313. init(): void;
  36314. /**
  36315. * Attaches the fade behavior on the passed in mesh
  36316. * @param ownerNode The mesh that will be faded in/out once attached
  36317. */
  36318. attach(ownerNode: Mesh): void;
  36319. /**
  36320. * Detaches the behavior from the mesh
  36321. */
  36322. detach(): void;
  36323. /**
  36324. * Triggers the mesh to begin fading in or out
  36325. * @param value if the object should fade in or out (true to fade in)
  36326. */
  36327. fadeIn(value: boolean): void;
  36328. private _update;
  36329. private _setAllVisibility;
  36330. }
  36331. }
  36332. declare module "babylonjs/Misc/pivotTools" {
  36333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36334. /**
  36335. * Class containing a set of static utilities functions for managing Pivots
  36336. * @hidden
  36337. */
  36338. export class PivotTools {
  36339. private static _PivotCached;
  36340. private static _OldPivotPoint;
  36341. private static _PivotTranslation;
  36342. private static _PivotTmpVector;
  36343. /** @hidden */
  36344. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36345. /** @hidden */
  36346. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36347. }
  36348. }
  36349. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36350. import { Scene } from "babylonjs/scene";
  36351. import { Vector4, Plane } from "babylonjs/Maths/math";
  36352. import { Mesh } from "babylonjs/Meshes/mesh";
  36353. import { Nullable } from "babylonjs/types";
  36354. /**
  36355. * Class containing static functions to help procedurally build meshes
  36356. */
  36357. export class PlaneBuilder {
  36358. /**
  36359. * Creates a plane mesh
  36360. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36361. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36362. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36364. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36366. * @param name defines the name of the mesh
  36367. * @param options defines the options used to create the mesh
  36368. * @param scene defines the hosting scene
  36369. * @returns the plane mesh
  36370. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36371. */
  36372. static CreatePlane(name: string, options: {
  36373. size?: number;
  36374. width?: number;
  36375. height?: number;
  36376. sideOrientation?: number;
  36377. frontUVs?: Vector4;
  36378. backUVs?: Vector4;
  36379. updatable?: boolean;
  36380. sourcePlane?: Plane;
  36381. }, scene?: Nullable<Scene>): Mesh;
  36382. }
  36383. }
  36384. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36385. import { Behavior } from "babylonjs/Behaviors/behavior";
  36386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36387. import { Observable } from "babylonjs/Misc/observable";
  36388. import { Vector3 } from "babylonjs/Maths/math";
  36389. import { Ray } from "babylonjs/Culling/ray";
  36390. import "babylonjs/Meshes/Builders/planeBuilder";
  36391. /**
  36392. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36393. */
  36394. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36395. private static _AnyMouseID;
  36396. private _attachedNode;
  36397. private _dragPlane;
  36398. private _scene;
  36399. private _pointerObserver;
  36400. private _beforeRenderObserver;
  36401. private static _planeScene;
  36402. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36403. /**
  36404. * 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)
  36405. */
  36406. maxDragAngle: number;
  36407. /**
  36408. * @hidden
  36409. */
  36410. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36411. /**
  36412. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36413. */
  36414. currentDraggingPointerID: number;
  36415. /**
  36416. * The last position where the pointer hit the drag plane in world space
  36417. */
  36418. lastDragPosition: Vector3;
  36419. /**
  36420. * If the behavior is currently in a dragging state
  36421. */
  36422. dragging: boolean;
  36423. /**
  36424. * 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)
  36425. */
  36426. dragDeltaRatio: number;
  36427. /**
  36428. * If the drag plane orientation should be updated during the dragging (Default: true)
  36429. */
  36430. updateDragPlane: boolean;
  36431. private _debugMode;
  36432. private _moving;
  36433. /**
  36434. * Fires each time the attached mesh is dragged with the pointer
  36435. * * delta between last drag position and current drag position in world space
  36436. * * dragDistance along the drag axis
  36437. * * dragPlaneNormal normal of the current drag plane used during the drag
  36438. * * dragPlanePoint in world space where the drag intersects the drag plane
  36439. */
  36440. onDragObservable: Observable<{
  36441. delta: Vector3;
  36442. dragPlanePoint: Vector3;
  36443. dragPlaneNormal: Vector3;
  36444. dragDistance: number;
  36445. pointerId: number;
  36446. }>;
  36447. /**
  36448. * Fires each time a drag begins (eg. mouse down on mesh)
  36449. */
  36450. onDragStartObservable: Observable<{
  36451. dragPlanePoint: Vector3;
  36452. pointerId: number;
  36453. }>;
  36454. /**
  36455. * Fires each time a drag ends (eg. mouse release after drag)
  36456. */
  36457. onDragEndObservable: Observable<{
  36458. dragPlanePoint: Vector3;
  36459. pointerId: number;
  36460. }>;
  36461. /**
  36462. * If the attached mesh should be moved when dragged
  36463. */
  36464. moveAttached: boolean;
  36465. /**
  36466. * If the drag behavior will react to drag events (Default: true)
  36467. */
  36468. enabled: boolean;
  36469. /**
  36470. * If camera controls should be detached during the drag
  36471. */
  36472. detachCameraControls: boolean;
  36473. /**
  36474. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36475. */
  36476. useObjectOrienationForDragging: boolean;
  36477. private _options;
  36478. /**
  36479. * Creates a pointer drag behavior that can be attached to a mesh
  36480. * @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)
  36481. */
  36482. constructor(options?: {
  36483. dragAxis?: Vector3;
  36484. dragPlaneNormal?: Vector3;
  36485. });
  36486. /**
  36487. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36488. */
  36489. validateDrag: (targetPosition: Vector3) => boolean;
  36490. /**
  36491. * The name of the behavior
  36492. */
  36493. readonly name: string;
  36494. /**
  36495. * Initializes the behavior
  36496. */
  36497. init(): void;
  36498. private _tmpVector;
  36499. private _alternatePickedPoint;
  36500. private _worldDragAxis;
  36501. private _targetPosition;
  36502. private _attachedElement;
  36503. /**
  36504. * Attaches the drag behavior the passed in mesh
  36505. * @param ownerNode The mesh that will be dragged around once attached
  36506. */
  36507. attach(ownerNode: AbstractMesh): void;
  36508. /**
  36509. * Force relase the drag action by code.
  36510. */
  36511. releaseDrag(): void;
  36512. private _startDragRay;
  36513. private _lastPointerRay;
  36514. /**
  36515. * Simulates the start of a pointer drag event on the behavior
  36516. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36517. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36518. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36519. */
  36520. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36521. private _startDrag;
  36522. private _dragDelta;
  36523. private _moveDrag;
  36524. private _pickWithRayOnDragPlane;
  36525. private _pointA;
  36526. private _pointB;
  36527. private _pointC;
  36528. private _lineA;
  36529. private _lineB;
  36530. private _localAxis;
  36531. private _lookAt;
  36532. private _updateDragPlanePosition;
  36533. /**
  36534. * Detaches the behavior from the mesh
  36535. */
  36536. detach(): void;
  36537. }
  36538. }
  36539. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36540. import { Mesh } from "babylonjs/Meshes/mesh";
  36541. import { Behavior } from "babylonjs/Behaviors/behavior";
  36542. /**
  36543. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36544. */
  36545. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36546. private _dragBehaviorA;
  36547. private _dragBehaviorB;
  36548. private _startDistance;
  36549. private _initialScale;
  36550. private _targetScale;
  36551. private _ownerNode;
  36552. private _sceneRenderObserver;
  36553. /**
  36554. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36555. */
  36556. constructor();
  36557. /**
  36558. * The name of the behavior
  36559. */
  36560. readonly name: string;
  36561. /**
  36562. * Initializes the behavior
  36563. */
  36564. init(): void;
  36565. private _getCurrentDistance;
  36566. /**
  36567. * Attaches the scale behavior the passed in mesh
  36568. * @param ownerNode The mesh that will be scaled around once attached
  36569. */
  36570. attach(ownerNode: Mesh): void;
  36571. /**
  36572. * Detaches the behavior from the mesh
  36573. */
  36574. detach(): void;
  36575. }
  36576. }
  36577. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36578. import { Behavior } from "babylonjs/Behaviors/behavior";
  36579. import { Mesh } from "babylonjs/Meshes/mesh";
  36580. import { Observable } from "babylonjs/Misc/observable";
  36581. /**
  36582. * 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
  36583. */
  36584. export class SixDofDragBehavior implements Behavior<Mesh> {
  36585. private static _virtualScene;
  36586. private _ownerNode;
  36587. private _sceneRenderObserver;
  36588. private _scene;
  36589. private _targetPosition;
  36590. private _virtualOriginMesh;
  36591. private _virtualDragMesh;
  36592. private _pointerObserver;
  36593. private _moving;
  36594. private _startingOrientation;
  36595. /**
  36596. * 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)
  36597. */
  36598. private zDragFactor;
  36599. /**
  36600. * If the object should rotate to face the drag origin
  36601. */
  36602. rotateDraggedObject: boolean;
  36603. /**
  36604. * If the behavior is currently in a dragging state
  36605. */
  36606. dragging: boolean;
  36607. /**
  36608. * 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)
  36609. */
  36610. dragDeltaRatio: number;
  36611. /**
  36612. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36613. */
  36614. currentDraggingPointerID: number;
  36615. /**
  36616. * If camera controls should be detached during the drag
  36617. */
  36618. detachCameraControls: boolean;
  36619. /**
  36620. * Fires each time a drag starts
  36621. */
  36622. onDragStartObservable: Observable<{}>;
  36623. /**
  36624. * Fires each time a drag ends (eg. mouse release after drag)
  36625. */
  36626. onDragEndObservable: Observable<{}>;
  36627. /**
  36628. * 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
  36629. */
  36630. constructor();
  36631. /**
  36632. * The name of the behavior
  36633. */
  36634. readonly name: string;
  36635. /**
  36636. * Initializes the behavior
  36637. */
  36638. init(): void;
  36639. /**
  36640. * Attaches the scale behavior the passed in mesh
  36641. * @param ownerNode The mesh that will be scaled around once attached
  36642. */
  36643. attach(ownerNode: Mesh): void;
  36644. /**
  36645. * Detaches the behavior from the mesh
  36646. */
  36647. detach(): void;
  36648. }
  36649. }
  36650. declare module "babylonjs/Behaviors/Meshes/index" {
  36651. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36652. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36653. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36654. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36655. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36656. }
  36657. declare module "babylonjs/Behaviors/index" {
  36658. export * from "babylonjs/Behaviors/behavior";
  36659. export * from "babylonjs/Behaviors/Cameras/index";
  36660. export * from "babylonjs/Behaviors/Meshes/index";
  36661. }
  36662. declare module "babylonjs/Bones/boneIKController" {
  36663. import { Bone } from "babylonjs/Bones/bone";
  36664. import { Vector3 } from "babylonjs/Maths/math";
  36665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36666. import { Nullable } from "babylonjs/types";
  36667. /**
  36668. * Class used to apply inverse kinematics to bones
  36669. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36670. */
  36671. export class BoneIKController {
  36672. private static _tmpVecs;
  36673. private static _tmpQuat;
  36674. private static _tmpMats;
  36675. /**
  36676. * Gets or sets the target mesh
  36677. */
  36678. targetMesh: AbstractMesh;
  36679. /** Gets or sets the mesh used as pole */
  36680. poleTargetMesh: AbstractMesh;
  36681. /**
  36682. * Gets or sets the bone used as pole
  36683. */
  36684. poleTargetBone: Nullable<Bone>;
  36685. /**
  36686. * Gets or sets the target position
  36687. */
  36688. targetPosition: Vector3;
  36689. /**
  36690. * Gets or sets the pole target position
  36691. */
  36692. poleTargetPosition: Vector3;
  36693. /**
  36694. * Gets or sets the pole target local offset
  36695. */
  36696. poleTargetLocalOffset: Vector3;
  36697. /**
  36698. * Gets or sets the pole angle
  36699. */
  36700. poleAngle: number;
  36701. /**
  36702. * Gets or sets the mesh associated with the controller
  36703. */
  36704. mesh: AbstractMesh;
  36705. /**
  36706. * 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)
  36707. */
  36708. slerpAmount: number;
  36709. private _bone1Quat;
  36710. private _bone1Mat;
  36711. private _bone2Ang;
  36712. private _bone1;
  36713. private _bone2;
  36714. private _bone1Length;
  36715. private _bone2Length;
  36716. private _maxAngle;
  36717. private _maxReach;
  36718. private _rightHandedSystem;
  36719. private _bendAxis;
  36720. private _slerping;
  36721. private _adjustRoll;
  36722. /**
  36723. * Gets or sets maximum allowed angle
  36724. */
  36725. maxAngle: number;
  36726. /**
  36727. * Creates a new BoneIKController
  36728. * @param mesh defines the mesh to control
  36729. * @param bone defines the bone to control
  36730. * @param options defines options to set up the controller
  36731. */
  36732. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36733. targetMesh?: AbstractMesh;
  36734. poleTargetMesh?: AbstractMesh;
  36735. poleTargetBone?: Bone;
  36736. poleTargetLocalOffset?: Vector3;
  36737. poleAngle?: number;
  36738. bendAxis?: Vector3;
  36739. maxAngle?: number;
  36740. slerpAmount?: number;
  36741. });
  36742. private _setMaxAngle;
  36743. /**
  36744. * Force the controller to update the bones
  36745. */
  36746. update(): void;
  36747. }
  36748. }
  36749. declare module "babylonjs/Bones/boneLookController" {
  36750. import { Vector3, Space } from "babylonjs/Maths/math";
  36751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36752. import { Bone } from "babylonjs/Bones/bone";
  36753. /**
  36754. * Class used to make a bone look toward a point in space
  36755. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36756. */
  36757. export class BoneLookController {
  36758. private static _tmpVecs;
  36759. private static _tmpQuat;
  36760. private static _tmpMats;
  36761. /**
  36762. * The target Vector3 that the bone will look at
  36763. */
  36764. target: Vector3;
  36765. /**
  36766. * The mesh that the bone is attached to
  36767. */
  36768. mesh: AbstractMesh;
  36769. /**
  36770. * The bone that will be looking to the target
  36771. */
  36772. bone: Bone;
  36773. /**
  36774. * The up axis of the coordinate system that is used when the bone is rotated
  36775. */
  36776. upAxis: Vector3;
  36777. /**
  36778. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36779. */
  36780. upAxisSpace: Space;
  36781. /**
  36782. * Used to make an adjustment to the yaw of the bone
  36783. */
  36784. adjustYaw: number;
  36785. /**
  36786. * Used to make an adjustment to the pitch of the bone
  36787. */
  36788. adjustPitch: number;
  36789. /**
  36790. * Used to make an adjustment to the roll of the bone
  36791. */
  36792. adjustRoll: number;
  36793. /**
  36794. * 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)
  36795. */
  36796. slerpAmount: number;
  36797. private _minYaw;
  36798. private _maxYaw;
  36799. private _minPitch;
  36800. private _maxPitch;
  36801. private _minYawSin;
  36802. private _minYawCos;
  36803. private _maxYawSin;
  36804. private _maxYawCos;
  36805. private _midYawConstraint;
  36806. private _minPitchTan;
  36807. private _maxPitchTan;
  36808. private _boneQuat;
  36809. private _slerping;
  36810. private _transformYawPitch;
  36811. private _transformYawPitchInv;
  36812. private _firstFrameSkipped;
  36813. private _yawRange;
  36814. private _fowardAxis;
  36815. /**
  36816. * Gets or sets the minimum yaw angle that the bone can look to
  36817. */
  36818. minYaw: number;
  36819. /**
  36820. * Gets or sets the maximum yaw angle that the bone can look to
  36821. */
  36822. maxYaw: number;
  36823. /**
  36824. * Gets or sets the minimum pitch angle that the bone can look to
  36825. */
  36826. minPitch: number;
  36827. /**
  36828. * Gets or sets the maximum pitch angle that the bone can look to
  36829. */
  36830. maxPitch: number;
  36831. /**
  36832. * Create a BoneLookController
  36833. * @param mesh the mesh that the bone belongs to
  36834. * @param bone the bone that will be looking to the target
  36835. * @param target the target Vector3 to look at
  36836. * @param options optional settings:
  36837. * * maxYaw: the maximum angle the bone will yaw to
  36838. * * minYaw: the minimum angle the bone will yaw to
  36839. * * maxPitch: the maximum angle the bone will pitch to
  36840. * * minPitch: the minimum angle the bone will yaw to
  36841. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36842. * * upAxis: the up axis of the coordinate system
  36843. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36844. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36845. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36846. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36847. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36848. * * adjustRoll: used to make an adjustment to the roll of the bone
  36849. **/
  36850. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36851. maxYaw?: number;
  36852. minYaw?: number;
  36853. maxPitch?: number;
  36854. minPitch?: number;
  36855. slerpAmount?: number;
  36856. upAxis?: Vector3;
  36857. upAxisSpace?: Space;
  36858. yawAxis?: Vector3;
  36859. pitchAxis?: Vector3;
  36860. adjustYaw?: number;
  36861. adjustPitch?: number;
  36862. adjustRoll?: number;
  36863. });
  36864. /**
  36865. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36866. */
  36867. update(): void;
  36868. private _getAngleDiff;
  36869. private _getAngleBetween;
  36870. private _isAngleBetween;
  36871. }
  36872. }
  36873. declare module "babylonjs/Bones/index" {
  36874. export * from "babylonjs/Bones/bone";
  36875. export * from "babylonjs/Bones/boneIKController";
  36876. export * from "babylonjs/Bones/boneLookController";
  36877. export * from "babylonjs/Bones/skeleton";
  36878. }
  36879. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36880. import { Nullable } from "babylonjs/types";
  36881. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36882. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36883. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36884. /**
  36885. * Manage the gamepad inputs to control an arc rotate camera.
  36886. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36887. */
  36888. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36889. /**
  36890. * Defines the camera the input is attached to.
  36891. */
  36892. camera: ArcRotateCamera;
  36893. /**
  36894. * Defines the gamepad the input is gathering event from.
  36895. */
  36896. gamepad: Nullable<Gamepad>;
  36897. /**
  36898. * Defines the gamepad rotation sensiblity.
  36899. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36900. */
  36901. gamepadRotationSensibility: number;
  36902. /**
  36903. * Defines the gamepad move sensiblity.
  36904. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36905. */
  36906. gamepadMoveSensibility: number;
  36907. private _onGamepadConnectedObserver;
  36908. private _onGamepadDisconnectedObserver;
  36909. /**
  36910. * Attach the input controls to a specific dom element to get the input from.
  36911. * @param element Defines the element the controls should be listened from
  36912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36913. */
  36914. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36915. /**
  36916. * Detach the current controls from the specified dom element.
  36917. * @param element Defines the element to stop listening the inputs from
  36918. */
  36919. detachControl(element: Nullable<HTMLElement>): void;
  36920. /**
  36921. * Update the current camera state depending on the inputs that have been used this frame.
  36922. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36923. */
  36924. checkInputs(): void;
  36925. /**
  36926. * Gets the class name of the current intput.
  36927. * @returns the class name
  36928. */
  36929. getClassName(): string;
  36930. /**
  36931. * Get the friendly name associated with the input class.
  36932. * @returns the input friendly name
  36933. */
  36934. getSimpleName(): string;
  36935. }
  36936. }
  36937. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36938. import { Nullable } from "babylonjs/types";
  36939. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36940. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36941. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36942. interface ArcRotateCameraInputsManager {
  36943. /**
  36944. * Add orientation input support to the input manager.
  36945. * @returns the current input manager
  36946. */
  36947. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36948. }
  36949. }
  36950. /**
  36951. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36953. */
  36954. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36955. /**
  36956. * Defines the camera the input is attached to.
  36957. */
  36958. camera: ArcRotateCamera;
  36959. /**
  36960. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36961. */
  36962. alphaCorrection: number;
  36963. /**
  36964. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36965. */
  36966. gammaCorrection: number;
  36967. private _alpha;
  36968. private _gamma;
  36969. private _dirty;
  36970. private _deviceOrientationHandler;
  36971. /**
  36972. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36973. */
  36974. constructor();
  36975. /**
  36976. * Attach the input controls to a specific dom element to get the input from.
  36977. * @param element Defines the element the controls should be listened from
  36978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36979. */
  36980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36981. /** @hidden */
  36982. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36983. /**
  36984. * Update the current camera state depending on the inputs that have been used this frame.
  36985. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36986. */
  36987. checkInputs(): void;
  36988. /**
  36989. * Detach the current controls from the specified dom element.
  36990. * @param element Defines the element to stop listening the inputs from
  36991. */
  36992. detachControl(element: Nullable<HTMLElement>): void;
  36993. /**
  36994. * Gets the class name of the current intput.
  36995. * @returns the class name
  36996. */
  36997. getClassName(): string;
  36998. /**
  36999. * Get the friendly name associated with the input class.
  37000. * @returns the input friendly name
  37001. */
  37002. getSimpleName(): string;
  37003. }
  37004. }
  37005. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37006. import { Nullable } from "babylonjs/types";
  37007. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37008. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37009. /**
  37010. * Listen to mouse events to control the camera.
  37011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37012. */
  37013. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37014. /**
  37015. * Defines the camera the input is attached to.
  37016. */
  37017. camera: FlyCamera;
  37018. /**
  37019. * Defines if touch is enabled. (Default is true.)
  37020. */
  37021. touchEnabled: boolean;
  37022. /**
  37023. * Defines the buttons associated with the input to handle camera rotation.
  37024. */
  37025. buttons: number[];
  37026. /**
  37027. * Assign buttons for Yaw control.
  37028. */
  37029. buttonsYaw: number[];
  37030. /**
  37031. * Assign buttons for Pitch control.
  37032. */
  37033. buttonsPitch: number[];
  37034. /**
  37035. * Assign buttons for Roll control.
  37036. */
  37037. buttonsRoll: number[];
  37038. /**
  37039. * Detect if any button is being pressed while mouse is moved.
  37040. * -1 = Mouse locked.
  37041. * 0 = Left button.
  37042. * 1 = Middle Button.
  37043. * 2 = Right Button.
  37044. */
  37045. activeButton: number;
  37046. /**
  37047. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37048. * Higher values reduce its sensitivity.
  37049. */
  37050. angularSensibility: number;
  37051. private _mousemoveCallback;
  37052. private _observer;
  37053. private _rollObserver;
  37054. private previousPosition;
  37055. private noPreventDefault;
  37056. private element;
  37057. /**
  37058. * Listen to mouse events to control the camera.
  37059. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37060. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37061. */
  37062. constructor(touchEnabled?: boolean);
  37063. /**
  37064. * Attach the mouse control to the HTML DOM element.
  37065. * @param element Defines the element that listens to the input events.
  37066. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37067. */
  37068. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37069. /**
  37070. * Detach the current controls from the specified dom element.
  37071. * @param element Defines the element to stop listening the inputs from
  37072. */
  37073. detachControl(element: Nullable<HTMLElement>): void;
  37074. /**
  37075. * Gets the class name of the current input.
  37076. * @returns the class name.
  37077. */
  37078. getClassName(): string;
  37079. /**
  37080. * Get the friendly name associated with the input class.
  37081. * @returns the input's friendly name.
  37082. */
  37083. getSimpleName(): string;
  37084. private _pointerInput;
  37085. private _onMouseMove;
  37086. /**
  37087. * Rotate camera by mouse offset.
  37088. */
  37089. private rotateCamera;
  37090. }
  37091. }
  37092. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37093. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37094. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37095. /**
  37096. * Default Inputs manager for the FlyCamera.
  37097. * It groups all the default supported inputs for ease of use.
  37098. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37099. */
  37100. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37101. /**
  37102. * Instantiates a new FlyCameraInputsManager.
  37103. * @param camera Defines the camera the inputs belong to.
  37104. */
  37105. constructor(camera: FlyCamera);
  37106. /**
  37107. * Add keyboard input support to the input manager.
  37108. * @returns the new FlyCameraKeyboardMoveInput().
  37109. */
  37110. addKeyboard(): FlyCameraInputsManager;
  37111. /**
  37112. * Add mouse input support to the input manager.
  37113. * @param touchEnabled Enable touch screen support.
  37114. * @returns the new FlyCameraMouseInput().
  37115. */
  37116. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37117. }
  37118. }
  37119. declare module "babylonjs/Cameras/flyCamera" {
  37120. import { Scene } from "babylonjs/scene";
  37121. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37123. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37124. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37125. /**
  37126. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37127. * such as in a 3D Space Shooter or a Flight Simulator.
  37128. */
  37129. export class FlyCamera extends TargetCamera {
  37130. /**
  37131. * Define the collision ellipsoid of the camera.
  37132. * This is helpful for simulating a camera body, like a player's body.
  37133. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37134. */
  37135. ellipsoid: Vector3;
  37136. /**
  37137. * Define an offset for the position of the ellipsoid around the camera.
  37138. * This can be helpful if the camera is attached away from the player's body center,
  37139. * such as at its head.
  37140. */
  37141. ellipsoidOffset: Vector3;
  37142. /**
  37143. * Enable or disable collisions of the camera with the rest of the scene objects.
  37144. */
  37145. checkCollisions: boolean;
  37146. /**
  37147. * Enable or disable gravity on the camera.
  37148. */
  37149. applyGravity: boolean;
  37150. /**
  37151. * Define the current direction the camera is moving to.
  37152. */
  37153. cameraDirection: Vector3;
  37154. /**
  37155. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37156. * This overrides and empties cameraRotation.
  37157. */
  37158. rotationQuaternion: Quaternion;
  37159. /**
  37160. * Track Roll to maintain the wanted Rolling when looking around.
  37161. */
  37162. _trackRoll: number;
  37163. /**
  37164. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37165. */
  37166. rollCorrect: number;
  37167. /**
  37168. * Mimic a banked turn, Rolling the camera when Yawing.
  37169. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37170. */
  37171. bankedTurn: boolean;
  37172. /**
  37173. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37174. */
  37175. bankedTurnLimit: number;
  37176. /**
  37177. * Value of 0 disables the banked Roll.
  37178. * Value of 1 is equal to the Yaw angle in radians.
  37179. */
  37180. bankedTurnMultiplier: number;
  37181. /**
  37182. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37183. */
  37184. inputs: FlyCameraInputsManager;
  37185. /**
  37186. * Gets the input sensibility for mouse input.
  37187. * Higher values reduce sensitivity.
  37188. */
  37189. /**
  37190. * Sets the input sensibility for a mouse input.
  37191. * Higher values reduce sensitivity.
  37192. */
  37193. angularSensibility: number;
  37194. /**
  37195. * Get the keys for camera movement forward.
  37196. */
  37197. /**
  37198. * Set the keys for camera movement forward.
  37199. */
  37200. keysForward: number[];
  37201. /**
  37202. * Get the keys for camera movement backward.
  37203. */
  37204. keysBackward: number[];
  37205. /**
  37206. * Get the keys for camera movement up.
  37207. */
  37208. /**
  37209. * Set the keys for camera movement up.
  37210. */
  37211. keysUp: number[];
  37212. /**
  37213. * Get the keys for camera movement down.
  37214. */
  37215. /**
  37216. * Set the keys for camera movement down.
  37217. */
  37218. keysDown: number[];
  37219. /**
  37220. * Get the keys for camera movement left.
  37221. */
  37222. /**
  37223. * Set the keys for camera movement left.
  37224. */
  37225. keysLeft: number[];
  37226. /**
  37227. * Set the keys for camera movement right.
  37228. */
  37229. /**
  37230. * Set the keys for camera movement right.
  37231. */
  37232. keysRight: number[];
  37233. /**
  37234. * Event raised when the camera collides with a mesh in the scene.
  37235. */
  37236. onCollide: (collidedMesh: AbstractMesh) => void;
  37237. private _collider;
  37238. private _needMoveForGravity;
  37239. private _oldPosition;
  37240. private _diffPosition;
  37241. private _newPosition;
  37242. /** @hidden */
  37243. _localDirection: Vector3;
  37244. /** @hidden */
  37245. _transformedDirection: Vector3;
  37246. /**
  37247. * Instantiates a FlyCamera.
  37248. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37249. * such as in a 3D Space Shooter or a Flight Simulator.
  37250. * @param name Define the name of the camera in the scene.
  37251. * @param position Define the starting position of the camera in the scene.
  37252. * @param scene Define the scene the camera belongs to.
  37253. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37254. */
  37255. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37256. /**
  37257. * Attach a control to the HTML DOM element.
  37258. * @param element Defines the element that listens to the input events.
  37259. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37260. */
  37261. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37262. /**
  37263. * Detach a control from the HTML DOM element.
  37264. * The camera will stop reacting to that input.
  37265. * @param element Defines the element that listens to the input events.
  37266. */
  37267. detachControl(element: HTMLElement): void;
  37268. private _collisionMask;
  37269. /**
  37270. * Get the mask that the camera ignores in collision events.
  37271. */
  37272. /**
  37273. * Set the mask that the camera ignores in collision events.
  37274. */
  37275. collisionMask: number;
  37276. /** @hidden */
  37277. _collideWithWorld(displacement: Vector3): void;
  37278. /** @hidden */
  37279. private _onCollisionPositionChange;
  37280. /** @hidden */
  37281. _checkInputs(): void;
  37282. /** @hidden */
  37283. _decideIfNeedsToMove(): boolean;
  37284. /** @hidden */
  37285. _updatePosition(): void;
  37286. /**
  37287. * Restore the Roll to its target value at the rate specified.
  37288. * @param rate - Higher means slower restoring.
  37289. * @hidden
  37290. */
  37291. restoreRoll(rate: number): void;
  37292. /**
  37293. * Destroy the camera and release the current resources held by it.
  37294. */
  37295. dispose(): void;
  37296. /**
  37297. * Get the current object class name.
  37298. * @returns the class name.
  37299. */
  37300. getClassName(): string;
  37301. }
  37302. }
  37303. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37304. import { Nullable } from "babylonjs/types";
  37305. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37306. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37307. /**
  37308. * Listen to keyboard events to control the camera.
  37309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37310. */
  37311. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37312. /**
  37313. * Defines the camera the input is attached to.
  37314. */
  37315. camera: FlyCamera;
  37316. /**
  37317. * The list of keyboard keys used to control the forward move of the camera.
  37318. */
  37319. keysForward: number[];
  37320. /**
  37321. * The list of keyboard keys used to control the backward move of the camera.
  37322. */
  37323. keysBackward: number[];
  37324. /**
  37325. * The list of keyboard keys used to control the forward move of the camera.
  37326. */
  37327. keysUp: number[];
  37328. /**
  37329. * The list of keyboard keys used to control the backward move of the camera.
  37330. */
  37331. keysDown: number[];
  37332. /**
  37333. * The list of keyboard keys used to control the right strafe move of the camera.
  37334. */
  37335. keysRight: number[];
  37336. /**
  37337. * The list of keyboard keys used to control the left strafe move of the camera.
  37338. */
  37339. keysLeft: number[];
  37340. private _keys;
  37341. private _onCanvasBlurObserver;
  37342. private _onKeyboardObserver;
  37343. private _engine;
  37344. private _scene;
  37345. /**
  37346. * Attach the input controls to a specific dom element to get the input from.
  37347. * @param element Defines the element the controls should be listened from
  37348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37349. */
  37350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37351. /**
  37352. * Detach the current controls from the specified dom element.
  37353. * @param element Defines the element to stop listening the inputs from
  37354. */
  37355. detachControl(element: Nullable<HTMLElement>): void;
  37356. /**
  37357. * Gets the class name of the current intput.
  37358. * @returns the class name
  37359. */
  37360. getClassName(): string;
  37361. /** @hidden */
  37362. _onLostFocus(e: FocusEvent): void;
  37363. /**
  37364. * Get the friendly name associated with the input class.
  37365. * @returns the input friendly name
  37366. */
  37367. getSimpleName(): string;
  37368. /**
  37369. * Update the current camera state depending on the inputs that have been used this frame.
  37370. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37371. */
  37372. checkInputs(): void;
  37373. }
  37374. }
  37375. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37376. import { Nullable } from "babylonjs/types";
  37377. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37378. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37379. /**
  37380. * Manage the mouse wheel inputs to control a follow camera.
  37381. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37382. */
  37383. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37384. /**
  37385. * Defines the camera the input is attached to.
  37386. */
  37387. camera: FollowCamera;
  37388. /**
  37389. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37390. */
  37391. axisControlRadius: boolean;
  37392. /**
  37393. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37394. */
  37395. axisControlHeight: boolean;
  37396. /**
  37397. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37398. */
  37399. axisControlRotation: boolean;
  37400. /**
  37401. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37402. * relation to mouseWheel events.
  37403. */
  37404. wheelPrecision: number;
  37405. /**
  37406. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37407. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37408. */
  37409. wheelDeltaPercentage: number;
  37410. private _wheel;
  37411. private _observer;
  37412. /**
  37413. * Attach the input controls to a specific dom element to get the input from.
  37414. * @param element Defines the element the controls should be listened from
  37415. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37416. */
  37417. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37418. /**
  37419. * Detach the current controls from the specified dom element.
  37420. * @param element Defines the element to stop listening the inputs from
  37421. */
  37422. detachControl(element: Nullable<HTMLElement>): void;
  37423. /**
  37424. * Gets the class name of the current intput.
  37425. * @returns the class name
  37426. */
  37427. getClassName(): string;
  37428. /**
  37429. * Get the friendly name associated with the input class.
  37430. * @returns the input friendly name
  37431. */
  37432. getSimpleName(): string;
  37433. }
  37434. }
  37435. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37436. import { Nullable } from "babylonjs/types";
  37437. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37438. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37439. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37440. /**
  37441. * Manage the pointers inputs to control an follow camera.
  37442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37443. */
  37444. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37445. /**
  37446. * Defines the camera the input is attached to.
  37447. */
  37448. camera: FollowCamera;
  37449. /**
  37450. * Gets the class name of the current input.
  37451. * @returns the class name
  37452. */
  37453. getClassName(): string;
  37454. /**
  37455. * Defines the pointer angular sensibility along the X axis or how fast is
  37456. * the camera rotating.
  37457. * A negative number will reverse the axis direction.
  37458. */
  37459. angularSensibilityX: number;
  37460. /**
  37461. * Defines the pointer angular sensibility along the Y axis or how fast is
  37462. * the camera rotating.
  37463. * A negative number will reverse the axis direction.
  37464. */
  37465. angularSensibilityY: number;
  37466. /**
  37467. * Defines the pointer pinch precision or how fast is the camera zooming.
  37468. * A negative number will reverse the axis direction.
  37469. */
  37470. pinchPrecision: number;
  37471. /**
  37472. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37473. * from 0.
  37474. * It defines the percentage of current camera.radius to use as delta when
  37475. * pinch zoom is used.
  37476. */
  37477. pinchDeltaPercentage: number;
  37478. /**
  37479. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37480. */
  37481. axisXControlRadius: boolean;
  37482. /**
  37483. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37484. */
  37485. axisXControlHeight: boolean;
  37486. /**
  37487. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37488. */
  37489. axisXControlRotation: boolean;
  37490. /**
  37491. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37492. */
  37493. axisYControlRadius: boolean;
  37494. /**
  37495. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37496. */
  37497. axisYControlHeight: boolean;
  37498. /**
  37499. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37500. */
  37501. axisYControlRotation: boolean;
  37502. /**
  37503. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37504. */
  37505. axisPinchControlRadius: boolean;
  37506. /**
  37507. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37508. */
  37509. axisPinchControlHeight: boolean;
  37510. /**
  37511. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37512. */
  37513. axisPinchControlRotation: boolean;
  37514. /**
  37515. * Log error messages if basic misconfiguration has occurred.
  37516. */
  37517. warningEnable: boolean;
  37518. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37519. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37520. private _warningCounter;
  37521. private _warning;
  37522. }
  37523. }
  37524. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37525. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37526. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37527. /**
  37528. * Default Inputs manager for the FollowCamera.
  37529. * It groups all the default supported inputs for ease of use.
  37530. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37531. */
  37532. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37533. /**
  37534. * Instantiates a new FollowCameraInputsManager.
  37535. * @param camera Defines the camera the inputs belong to
  37536. */
  37537. constructor(camera: FollowCamera);
  37538. /**
  37539. * Add keyboard input support to the input manager.
  37540. * @returns the current input manager
  37541. */
  37542. addKeyboard(): FollowCameraInputsManager;
  37543. /**
  37544. * Add mouse wheel input support to the input manager.
  37545. * @returns the current input manager
  37546. */
  37547. addMouseWheel(): FollowCameraInputsManager;
  37548. /**
  37549. * Add pointers input support to the input manager.
  37550. * @returns the current input manager
  37551. */
  37552. addPointers(): FollowCameraInputsManager;
  37553. /**
  37554. * Add orientation input support to the input manager.
  37555. * @returns the current input manager
  37556. */
  37557. addVRDeviceOrientation(): FollowCameraInputsManager;
  37558. }
  37559. }
  37560. declare module "babylonjs/Cameras/followCamera" {
  37561. import { Nullable } from "babylonjs/types";
  37562. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37563. import { Scene } from "babylonjs/scene";
  37564. import { Vector3 } from "babylonjs/Maths/math";
  37565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37566. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37567. /**
  37568. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37569. * an arc rotate version arcFollowCamera are available.
  37570. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37571. */
  37572. export class FollowCamera extends TargetCamera {
  37573. /**
  37574. * Distance the follow camera should follow an object at
  37575. */
  37576. radius: number;
  37577. /**
  37578. * Minimum allowed distance of the camera to the axis of rotation
  37579. * (The camera can not get closer).
  37580. * This can help limiting how the Camera is able to move in the scene.
  37581. */
  37582. lowerRadiusLimit: Nullable<number>;
  37583. /**
  37584. * Maximum allowed distance of the camera to the axis of rotation
  37585. * (The camera can not get further).
  37586. * This can help limiting how the Camera is able to move in the scene.
  37587. */
  37588. upperRadiusLimit: Nullable<number>;
  37589. /**
  37590. * Define a rotation offset between the camera and the object it follows
  37591. */
  37592. rotationOffset: number;
  37593. /**
  37594. * Minimum allowed angle to camera position relative to target object.
  37595. * This can help limiting how the Camera is able to move in the scene.
  37596. */
  37597. lowerRotationOffsetLimit: Nullable<number>;
  37598. /**
  37599. * Maximum allowed angle to camera position relative to target object.
  37600. * This can help limiting how the Camera is able to move in the scene.
  37601. */
  37602. upperRotationOffsetLimit: Nullable<number>;
  37603. /**
  37604. * Define a height offset between the camera and the object it follows.
  37605. * It can help following an object from the top (like a car chaing a plane)
  37606. */
  37607. heightOffset: number;
  37608. /**
  37609. * Minimum allowed height of camera position relative to target object.
  37610. * This can help limiting how the Camera is able to move in the scene.
  37611. */
  37612. lowerHeightOffsetLimit: Nullable<number>;
  37613. /**
  37614. * Maximum allowed height of camera position relative to target object.
  37615. * This can help limiting how the Camera is able to move in the scene.
  37616. */
  37617. upperHeightOffsetLimit: Nullable<number>;
  37618. /**
  37619. * Define how fast the camera can accelerate to follow it s target.
  37620. */
  37621. cameraAcceleration: number;
  37622. /**
  37623. * Define the speed limit of the camera following an object.
  37624. */
  37625. maxCameraSpeed: number;
  37626. /**
  37627. * Define the target of the camera.
  37628. */
  37629. lockedTarget: Nullable<AbstractMesh>;
  37630. /**
  37631. * Defines the input associated with the camera.
  37632. */
  37633. inputs: FollowCameraInputsManager;
  37634. /**
  37635. * Instantiates the follow camera.
  37636. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37637. * @param name Define the name of the camera in the scene
  37638. * @param position Define the position of the camera
  37639. * @param scene Define the scene the camera belong to
  37640. * @param lockedTarget Define the target of the camera
  37641. */
  37642. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37643. private _follow;
  37644. /**
  37645. * Attached controls to the current camera.
  37646. * @param element Defines the element the controls should be listened from
  37647. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37648. */
  37649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37650. /**
  37651. * Detach the current controls from the camera.
  37652. * The camera will stop reacting to inputs.
  37653. * @param element Defines the element to stop listening the inputs from
  37654. */
  37655. detachControl(element: HTMLElement): void;
  37656. /** @hidden */
  37657. _checkInputs(): void;
  37658. private _checkLimits;
  37659. /**
  37660. * Gets the camera class name.
  37661. * @returns the class name
  37662. */
  37663. getClassName(): string;
  37664. }
  37665. /**
  37666. * Arc Rotate version of the follow camera.
  37667. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37668. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37669. */
  37670. export class ArcFollowCamera extends TargetCamera {
  37671. /** The longitudinal angle of the camera */
  37672. alpha: number;
  37673. /** The latitudinal angle of the camera */
  37674. beta: number;
  37675. /** The radius of the camera from its target */
  37676. radius: number;
  37677. /** Define the camera target (the messh it should follow) */
  37678. target: Nullable<AbstractMesh>;
  37679. private _cartesianCoordinates;
  37680. /**
  37681. * Instantiates a new ArcFollowCamera
  37682. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37683. * @param name Define the name of the camera
  37684. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37685. * @param beta Define the rotation angle of the camera around the elevation axis
  37686. * @param radius Define the radius of the camera from its target point
  37687. * @param target Define the target of the camera
  37688. * @param scene Define the scene the camera belongs to
  37689. */
  37690. constructor(name: string,
  37691. /** The longitudinal angle of the camera */
  37692. alpha: number,
  37693. /** The latitudinal angle of the camera */
  37694. beta: number,
  37695. /** The radius of the camera from its target */
  37696. radius: number,
  37697. /** Define the camera target (the messh it should follow) */
  37698. target: Nullable<AbstractMesh>, scene: Scene);
  37699. private _follow;
  37700. /** @hidden */
  37701. _checkInputs(): void;
  37702. /**
  37703. * Returns the class name of the object.
  37704. * It is mostly used internally for serialization purposes.
  37705. */
  37706. getClassName(): string;
  37707. }
  37708. }
  37709. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37710. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37711. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37712. import { Nullable } from "babylonjs/types";
  37713. /**
  37714. * Manage the keyboard inputs to control the movement of a follow camera.
  37715. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37716. */
  37717. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37718. /**
  37719. * Defines the camera the input is attached to.
  37720. */
  37721. camera: FollowCamera;
  37722. /**
  37723. * Defines the list of key codes associated with the up action (increase heightOffset)
  37724. */
  37725. keysHeightOffsetIncr: number[];
  37726. /**
  37727. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37728. */
  37729. keysHeightOffsetDecr: number[];
  37730. /**
  37731. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37732. */
  37733. keysHeightOffsetModifierAlt: boolean;
  37734. /**
  37735. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37736. */
  37737. keysHeightOffsetModifierCtrl: boolean;
  37738. /**
  37739. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37740. */
  37741. keysHeightOffsetModifierShift: boolean;
  37742. /**
  37743. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37744. */
  37745. keysRotationOffsetIncr: number[];
  37746. /**
  37747. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37748. */
  37749. keysRotationOffsetDecr: number[];
  37750. /**
  37751. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37752. */
  37753. keysRotationOffsetModifierAlt: boolean;
  37754. /**
  37755. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37756. */
  37757. keysRotationOffsetModifierCtrl: boolean;
  37758. /**
  37759. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37760. */
  37761. keysRotationOffsetModifierShift: boolean;
  37762. /**
  37763. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37764. */
  37765. keysRadiusIncr: number[];
  37766. /**
  37767. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37768. */
  37769. keysRadiusDecr: number[];
  37770. /**
  37771. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37772. */
  37773. keysRadiusModifierAlt: boolean;
  37774. /**
  37775. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37776. */
  37777. keysRadiusModifierCtrl: boolean;
  37778. /**
  37779. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37780. */
  37781. keysRadiusModifierShift: boolean;
  37782. /**
  37783. * Defines the rate of change of heightOffset.
  37784. */
  37785. heightSensibility: number;
  37786. /**
  37787. * Defines the rate of change of rotationOffset.
  37788. */
  37789. rotationSensibility: number;
  37790. /**
  37791. * Defines the rate of change of radius.
  37792. */
  37793. radiusSensibility: number;
  37794. private _keys;
  37795. private _ctrlPressed;
  37796. private _altPressed;
  37797. private _shiftPressed;
  37798. private _onCanvasBlurObserver;
  37799. private _onKeyboardObserver;
  37800. private _engine;
  37801. private _scene;
  37802. /**
  37803. * Attach the input controls to a specific dom element to get the input from.
  37804. * @param element Defines the element the controls should be listened from
  37805. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37806. */
  37807. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37808. /**
  37809. * Detach the current controls from the specified dom element.
  37810. * @param element Defines the element to stop listening the inputs from
  37811. */
  37812. detachControl(element: Nullable<HTMLElement>): void;
  37813. /**
  37814. * Update the current camera state depending on the inputs that have been used this frame.
  37815. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37816. */
  37817. checkInputs(): void;
  37818. /**
  37819. * Gets the class name of the current input.
  37820. * @returns the class name
  37821. */
  37822. getClassName(): string;
  37823. /**
  37824. * Get the friendly name associated with the input class.
  37825. * @returns the input friendly name
  37826. */
  37827. getSimpleName(): string;
  37828. /**
  37829. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37830. * allow modification of the heightOffset value.
  37831. */
  37832. private _modifierHeightOffset;
  37833. /**
  37834. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37835. * allow modification of the rotationOffset value.
  37836. */
  37837. private _modifierRotationOffset;
  37838. /**
  37839. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37840. * allow modification of the radius value.
  37841. */
  37842. private _modifierRadius;
  37843. }
  37844. }
  37845. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37846. import { Nullable } from "babylonjs/types";
  37847. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37848. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37849. import { Observable } from "babylonjs/Misc/observable";
  37850. module "babylonjs/Cameras/freeCameraInputsManager" {
  37851. interface FreeCameraInputsManager {
  37852. /**
  37853. * @hidden
  37854. */
  37855. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37856. /**
  37857. * Add orientation input support to the input manager.
  37858. * @returns the current input manager
  37859. */
  37860. addDeviceOrientation(): FreeCameraInputsManager;
  37861. }
  37862. }
  37863. /**
  37864. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37865. * Screen rotation is taken into account.
  37866. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37867. */
  37868. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37869. private _camera;
  37870. private _screenOrientationAngle;
  37871. private _constantTranform;
  37872. private _screenQuaternion;
  37873. private _alpha;
  37874. private _beta;
  37875. private _gamma;
  37876. /**
  37877. * @hidden
  37878. */
  37879. _onDeviceOrientationChangedObservable: Observable<void>;
  37880. /**
  37881. * Instantiates a new input
  37882. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37883. */
  37884. constructor();
  37885. /**
  37886. * Define the camera controlled by the input.
  37887. */
  37888. camera: FreeCamera;
  37889. /**
  37890. * Attach the input controls to a specific dom element to get the input from.
  37891. * @param element Defines the element the controls should be listened from
  37892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37893. */
  37894. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37895. private _orientationChanged;
  37896. private _deviceOrientation;
  37897. /**
  37898. * Detach the current controls from the specified dom element.
  37899. * @param element Defines the element to stop listening the inputs from
  37900. */
  37901. detachControl(element: Nullable<HTMLElement>): void;
  37902. /**
  37903. * Update the current camera state depending on the inputs that have been used this frame.
  37904. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37905. */
  37906. checkInputs(): void;
  37907. /**
  37908. * Gets the class name of the current intput.
  37909. * @returns the class name
  37910. */
  37911. getClassName(): string;
  37912. /**
  37913. * Get the friendly name associated with the input class.
  37914. * @returns the input friendly name
  37915. */
  37916. getSimpleName(): string;
  37917. }
  37918. }
  37919. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37920. import { Nullable } from "babylonjs/types";
  37921. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37922. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37923. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37924. /**
  37925. * Manage the gamepad inputs to control a free camera.
  37926. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37927. */
  37928. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37929. /**
  37930. * Define the camera the input is attached to.
  37931. */
  37932. camera: FreeCamera;
  37933. /**
  37934. * Define the Gamepad controlling the input
  37935. */
  37936. gamepad: Nullable<Gamepad>;
  37937. /**
  37938. * Defines the gamepad rotation sensiblity.
  37939. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37940. */
  37941. gamepadAngularSensibility: number;
  37942. /**
  37943. * Defines the gamepad move sensiblity.
  37944. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37945. */
  37946. gamepadMoveSensibility: number;
  37947. private _onGamepadConnectedObserver;
  37948. private _onGamepadDisconnectedObserver;
  37949. private _cameraTransform;
  37950. private _deltaTransform;
  37951. private _vector3;
  37952. private _vector2;
  37953. /**
  37954. * Attach the input controls to a specific dom element to get the input from.
  37955. * @param element Defines the element the controls should be listened from
  37956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37957. */
  37958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37959. /**
  37960. * Detach the current controls from the specified dom element.
  37961. * @param element Defines the element to stop listening the inputs from
  37962. */
  37963. detachControl(element: Nullable<HTMLElement>): void;
  37964. /**
  37965. * Update the current camera state depending on the inputs that have been used this frame.
  37966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37967. */
  37968. checkInputs(): void;
  37969. /**
  37970. * Gets the class name of the current intput.
  37971. * @returns the class name
  37972. */
  37973. getClassName(): string;
  37974. /**
  37975. * Get the friendly name associated with the input class.
  37976. * @returns the input friendly name
  37977. */
  37978. getSimpleName(): string;
  37979. }
  37980. }
  37981. declare module "babylonjs/Misc/virtualJoystick" {
  37982. import { Nullable } from "babylonjs/types";
  37983. import { Vector3 } from "babylonjs/Maths/math";
  37984. /**
  37985. * Defines the potential axis of a Joystick
  37986. */
  37987. export enum JoystickAxis {
  37988. /** X axis */
  37989. X = 0,
  37990. /** Y axis */
  37991. Y = 1,
  37992. /** Z axis */
  37993. Z = 2
  37994. }
  37995. /**
  37996. * Class used to define virtual joystick (used in touch mode)
  37997. */
  37998. export class VirtualJoystick {
  37999. /**
  38000. * Gets or sets a boolean indicating that left and right values must be inverted
  38001. */
  38002. reverseLeftRight: boolean;
  38003. /**
  38004. * Gets or sets a boolean indicating that up and down values must be inverted
  38005. */
  38006. reverseUpDown: boolean;
  38007. /**
  38008. * Gets the offset value for the position (ie. the change of the position value)
  38009. */
  38010. deltaPosition: Vector3;
  38011. /**
  38012. * Gets a boolean indicating if the virtual joystick was pressed
  38013. */
  38014. pressed: boolean;
  38015. /**
  38016. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38017. */
  38018. static Canvas: Nullable<HTMLCanvasElement>;
  38019. private static _globalJoystickIndex;
  38020. private static vjCanvasContext;
  38021. private static vjCanvasWidth;
  38022. private static vjCanvasHeight;
  38023. private static halfWidth;
  38024. private _action;
  38025. private _axisTargetedByLeftAndRight;
  38026. private _axisTargetedByUpAndDown;
  38027. private _joystickSensibility;
  38028. private _inversedSensibility;
  38029. private _joystickPointerID;
  38030. private _joystickColor;
  38031. private _joystickPointerPos;
  38032. private _joystickPreviousPointerPos;
  38033. private _joystickPointerStartPos;
  38034. private _deltaJoystickVector;
  38035. private _leftJoystick;
  38036. private _touches;
  38037. private _onPointerDownHandlerRef;
  38038. private _onPointerMoveHandlerRef;
  38039. private _onPointerUpHandlerRef;
  38040. private _onResize;
  38041. /**
  38042. * Creates a new virtual joystick
  38043. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38044. */
  38045. constructor(leftJoystick?: boolean);
  38046. /**
  38047. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38048. * @param newJoystickSensibility defines the new sensibility
  38049. */
  38050. setJoystickSensibility(newJoystickSensibility: number): void;
  38051. private _onPointerDown;
  38052. private _onPointerMove;
  38053. private _onPointerUp;
  38054. /**
  38055. * Change the color of the virtual joystick
  38056. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38057. */
  38058. setJoystickColor(newColor: string): void;
  38059. /**
  38060. * Defines a callback to call when the joystick is touched
  38061. * @param action defines the callback
  38062. */
  38063. setActionOnTouch(action: () => any): void;
  38064. /**
  38065. * Defines which axis you'd like to control for left & right
  38066. * @param axis defines the axis to use
  38067. */
  38068. setAxisForLeftRight(axis: JoystickAxis): void;
  38069. /**
  38070. * Defines which axis you'd like to control for up & down
  38071. * @param axis defines the axis to use
  38072. */
  38073. setAxisForUpDown(axis: JoystickAxis): void;
  38074. private _drawVirtualJoystick;
  38075. /**
  38076. * Release internal HTML canvas
  38077. */
  38078. releaseCanvas(): void;
  38079. }
  38080. }
  38081. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38082. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38083. import { Nullable } from "babylonjs/types";
  38084. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38085. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38086. module "babylonjs/Cameras/freeCameraInputsManager" {
  38087. interface FreeCameraInputsManager {
  38088. /**
  38089. * Add virtual joystick input support to the input manager.
  38090. * @returns the current input manager
  38091. */
  38092. addVirtualJoystick(): FreeCameraInputsManager;
  38093. }
  38094. }
  38095. /**
  38096. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38098. */
  38099. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38100. /**
  38101. * Defines the camera the input is attached to.
  38102. */
  38103. camera: FreeCamera;
  38104. private _leftjoystick;
  38105. private _rightjoystick;
  38106. /**
  38107. * Gets the left stick of the virtual joystick.
  38108. * @returns The virtual Joystick
  38109. */
  38110. getLeftJoystick(): VirtualJoystick;
  38111. /**
  38112. * Gets the right stick of the virtual joystick.
  38113. * @returns The virtual Joystick
  38114. */
  38115. getRightJoystick(): VirtualJoystick;
  38116. /**
  38117. * Update the current camera state depending on the inputs that have been used this frame.
  38118. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38119. */
  38120. checkInputs(): void;
  38121. /**
  38122. * Attach the input controls to a specific dom element to get the input from.
  38123. * @param element Defines the element the controls should be listened from
  38124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38125. */
  38126. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38127. /**
  38128. * Detach the current controls from the specified dom element.
  38129. * @param element Defines the element to stop listening the inputs from
  38130. */
  38131. detachControl(element: Nullable<HTMLElement>): void;
  38132. /**
  38133. * Gets the class name of the current intput.
  38134. * @returns the class name
  38135. */
  38136. getClassName(): string;
  38137. /**
  38138. * Get the friendly name associated with the input class.
  38139. * @returns the input friendly name
  38140. */
  38141. getSimpleName(): string;
  38142. }
  38143. }
  38144. declare module "babylonjs/Cameras/Inputs/index" {
  38145. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38146. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38147. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38148. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38149. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38150. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38151. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38152. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38153. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38154. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38155. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38156. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38157. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38158. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38159. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38160. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38161. }
  38162. declare module "babylonjs/Cameras/touchCamera" {
  38163. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38164. import { Scene } from "babylonjs/scene";
  38165. import { Vector3 } from "babylonjs/Maths/math";
  38166. /**
  38167. * This represents a FPS type of camera controlled by touch.
  38168. * This is like a universal camera minus the Gamepad controls.
  38169. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38170. */
  38171. export class TouchCamera extends FreeCamera {
  38172. /**
  38173. * Defines the touch sensibility for rotation.
  38174. * The higher the faster.
  38175. */
  38176. touchAngularSensibility: number;
  38177. /**
  38178. * Defines the touch sensibility for move.
  38179. * The higher the faster.
  38180. */
  38181. touchMoveSensibility: number;
  38182. /**
  38183. * Instantiates a new touch camera.
  38184. * This represents a FPS type of camera controlled by touch.
  38185. * This is like a universal camera minus the Gamepad controls.
  38186. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38187. * @param name Define the name of the camera in the scene
  38188. * @param position Define the start position of the camera in the scene
  38189. * @param scene Define the scene the camera belongs to
  38190. */
  38191. constructor(name: string, position: Vector3, scene: Scene);
  38192. /**
  38193. * Gets the current object class name.
  38194. * @return the class name
  38195. */
  38196. getClassName(): string;
  38197. /** @hidden */
  38198. _setupInputs(): void;
  38199. }
  38200. }
  38201. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38202. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38203. import { Scene } from "babylonjs/scene";
  38204. import { Vector3, Axis } from "babylonjs/Maths/math";
  38205. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38206. /**
  38207. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38208. * being tilted forward or back and left or right.
  38209. */
  38210. export class DeviceOrientationCamera extends FreeCamera {
  38211. private _initialQuaternion;
  38212. private _quaternionCache;
  38213. private _tmpDragQuaternion;
  38214. /**
  38215. * Creates a new device orientation camera
  38216. * @param name The name of the camera
  38217. * @param position The start position camera
  38218. * @param scene The scene the camera belongs to
  38219. */
  38220. constructor(name: string, position: Vector3, scene: Scene);
  38221. /**
  38222. * Disabled pointer input on first orientation sensor update (Default: true)
  38223. */
  38224. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38225. private _dragFactor;
  38226. /**
  38227. * Enabled turning on the y axis when the orientation sensor is active
  38228. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38229. */
  38230. enableHorizontalDragging(dragFactor?: number): void;
  38231. /**
  38232. * Gets the current instance class name ("DeviceOrientationCamera").
  38233. * This helps avoiding instanceof at run time.
  38234. * @returns the class name
  38235. */
  38236. getClassName(): string;
  38237. /**
  38238. * @hidden
  38239. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38240. */
  38241. _checkInputs(): void;
  38242. /**
  38243. * Reset the camera to its default orientation on the specified axis only.
  38244. * @param axis The axis to reset
  38245. */
  38246. resetToCurrentRotation(axis?: Axis): void;
  38247. }
  38248. }
  38249. declare module "babylonjs/Cameras/universalCamera" {
  38250. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38251. import { Scene } from "babylonjs/scene";
  38252. import { Vector3 } from "babylonjs/Maths/math";
  38253. /**
  38254. * 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,
  38255. * which still works and will still be found in many Playgrounds.
  38256. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38257. */
  38258. export class UniversalCamera extends TouchCamera {
  38259. /**
  38260. * Defines the gamepad rotation sensiblity.
  38261. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38262. */
  38263. gamepadAngularSensibility: number;
  38264. /**
  38265. * Defines the gamepad move sensiblity.
  38266. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38267. */
  38268. gamepadMoveSensibility: number;
  38269. /**
  38270. * 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,
  38271. * which still works and will still be found in many Playgrounds.
  38272. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38273. * @param name Define the name of the camera in the scene
  38274. * @param position Define the start position of the camera in the scene
  38275. * @param scene Define the scene the camera belongs to
  38276. */
  38277. constructor(name: string, position: Vector3, scene: Scene);
  38278. /**
  38279. * Gets the current object class name.
  38280. * @return the class name
  38281. */
  38282. getClassName(): string;
  38283. }
  38284. }
  38285. declare module "babylonjs/Cameras/gamepadCamera" {
  38286. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38287. import { Scene } from "babylonjs/scene";
  38288. import { Vector3 } from "babylonjs/Maths/math";
  38289. /**
  38290. * This represents a FPS type of camera. This is only here for back compat purpose.
  38291. * Please use the UniversalCamera instead as both are identical.
  38292. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38293. */
  38294. export class GamepadCamera extends UniversalCamera {
  38295. /**
  38296. * Instantiates a new Gamepad Camera
  38297. * This represents a FPS type of camera. This is only here for back compat purpose.
  38298. * Please use the UniversalCamera instead as both are identical.
  38299. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38300. * @param name Define the name of the camera in the scene
  38301. * @param position Define the start position of the camera in the scene
  38302. * @param scene Define the scene the camera belongs to
  38303. */
  38304. constructor(name: string, position: Vector3, scene: Scene);
  38305. /**
  38306. * Gets the current object class name.
  38307. * @return the class name
  38308. */
  38309. getClassName(): string;
  38310. }
  38311. }
  38312. declare module "babylonjs/Shaders/pass.fragment" {
  38313. /** @hidden */
  38314. export var passPixelShader: {
  38315. name: string;
  38316. shader: string;
  38317. };
  38318. }
  38319. declare module "babylonjs/Shaders/passCube.fragment" {
  38320. /** @hidden */
  38321. export var passCubePixelShader: {
  38322. name: string;
  38323. shader: string;
  38324. };
  38325. }
  38326. declare module "babylonjs/PostProcesses/passPostProcess" {
  38327. import { Nullable } from "babylonjs/types";
  38328. import { Camera } from "babylonjs/Cameras/camera";
  38329. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38330. import { Engine } from "babylonjs/Engines/engine";
  38331. import "babylonjs/Shaders/pass.fragment";
  38332. import "babylonjs/Shaders/passCube.fragment";
  38333. /**
  38334. * PassPostProcess which produces an output the same as it's input
  38335. */
  38336. export class PassPostProcess extends PostProcess {
  38337. /**
  38338. * Creates the PassPostProcess
  38339. * @param name The name of the effect.
  38340. * @param options The required width/height ratio to downsize to before computing the render pass.
  38341. * @param camera The camera to apply the render pass to.
  38342. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38343. * @param engine The engine which the post process will be applied. (default: current engine)
  38344. * @param reusable If the post process can be reused on the same frame. (default: false)
  38345. * @param textureType The type of texture to be used when performing the post processing.
  38346. * @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)
  38347. */
  38348. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38349. }
  38350. /**
  38351. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38352. */
  38353. export class PassCubePostProcess extends PostProcess {
  38354. private _face;
  38355. /**
  38356. * Gets or sets the cube face to display.
  38357. * * 0 is +X
  38358. * * 1 is -X
  38359. * * 2 is +Y
  38360. * * 3 is -Y
  38361. * * 4 is +Z
  38362. * * 5 is -Z
  38363. */
  38364. face: number;
  38365. /**
  38366. * Creates the PassCubePostProcess
  38367. * @param name The name of the effect.
  38368. * @param options The required width/height ratio to downsize to before computing the render pass.
  38369. * @param camera The camera to apply the render pass to.
  38370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38371. * @param engine The engine which the post process will be applied. (default: current engine)
  38372. * @param reusable If the post process can be reused on the same frame. (default: false)
  38373. * @param textureType The type of texture to be used when performing the post processing.
  38374. * @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)
  38375. */
  38376. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38377. }
  38378. }
  38379. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38380. /** @hidden */
  38381. export var anaglyphPixelShader: {
  38382. name: string;
  38383. shader: string;
  38384. };
  38385. }
  38386. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38387. import { Engine } from "babylonjs/Engines/engine";
  38388. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38389. import { Camera } from "babylonjs/Cameras/camera";
  38390. import "babylonjs/Shaders/anaglyph.fragment";
  38391. /**
  38392. * Postprocess used to generate anaglyphic rendering
  38393. */
  38394. export class AnaglyphPostProcess extends PostProcess {
  38395. private _passedProcess;
  38396. /**
  38397. * Creates a new AnaglyphPostProcess
  38398. * @param name defines postprocess name
  38399. * @param options defines creation options or target ratio scale
  38400. * @param rigCameras defines cameras using this postprocess
  38401. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38402. * @param engine defines hosting engine
  38403. * @param reusable defines if the postprocess will be reused multiple times per frame
  38404. */
  38405. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38406. }
  38407. }
  38408. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38409. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38410. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38411. import { Scene } from "babylonjs/scene";
  38412. import { Vector3 } from "babylonjs/Maths/math";
  38413. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38414. /**
  38415. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38416. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38417. */
  38418. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38419. /**
  38420. * Creates a new AnaglyphArcRotateCamera
  38421. * @param name defines camera name
  38422. * @param alpha defines alpha angle (in radians)
  38423. * @param beta defines beta angle (in radians)
  38424. * @param radius defines radius
  38425. * @param target defines camera target
  38426. * @param interaxialDistance defines distance between each color axis
  38427. * @param scene defines the hosting scene
  38428. */
  38429. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38430. /**
  38431. * Gets camera class name
  38432. * @returns AnaglyphArcRotateCamera
  38433. */
  38434. getClassName(): string;
  38435. }
  38436. }
  38437. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38438. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38439. import { Scene } from "babylonjs/scene";
  38440. import { Vector3 } from "babylonjs/Maths/math";
  38441. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38442. /**
  38443. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38444. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38445. */
  38446. export class AnaglyphFreeCamera extends FreeCamera {
  38447. /**
  38448. * Creates a new AnaglyphFreeCamera
  38449. * @param name defines camera name
  38450. * @param position defines initial position
  38451. * @param interaxialDistance defines distance between each color axis
  38452. * @param scene defines the hosting scene
  38453. */
  38454. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38455. /**
  38456. * Gets camera class name
  38457. * @returns AnaglyphFreeCamera
  38458. */
  38459. getClassName(): string;
  38460. }
  38461. }
  38462. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38463. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38464. import { Scene } from "babylonjs/scene";
  38465. import { Vector3 } from "babylonjs/Maths/math";
  38466. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38467. /**
  38468. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38469. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38470. */
  38471. export class AnaglyphGamepadCamera extends GamepadCamera {
  38472. /**
  38473. * Creates a new AnaglyphGamepadCamera
  38474. * @param name defines camera name
  38475. * @param position defines initial position
  38476. * @param interaxialDistance defines distance between each color axis
  38477. * @param scene defines the hosting scene
  38478. */
  38479. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38480. /**
  38481. * Gets camera class name
  38482. * @returns AnaglyphGamepadCamera
  38483. */
  38484. getClassName(): string;
  38485. }
  38486. }
  38487. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38488. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38489. import { Scene } from "babylonjs/scene";
  38490. import { Vector3 } from "babylonjs/Maths/math";
  38491. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38492. /**
  38493. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38494. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38495. */
  38496. export class AnaglyphUniversalCamera extends UniversalCamera {
  38497. /**
  38498. * Creates a new AnaglyphUniversalCamera
  38499. * @param name defines camera name
  38500. * @param position defines initial position
  38501. * @param interaxialDistance defines distance between each color axis
  38502. * @param scene defines the hosting scene
  38503. */
  38504. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38505. /**
  38506. * Gets camera class name
  38507. * @returns AnaglyphUniversalCamera
  38508. */
  38509. getClassName(): string;
  38510. }
  38511. }
  38512. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38513. /** @hidden */
  38514. export var stereoscopicInterlacePixelShader: {
  38515. name: string;
  38516. shader: string;
  38517. };
  38518. }
  38519. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38520. import { Camera } from "babylonjs/Cameras/camera";
  38521. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38522. import { Engine } from "babylonjs/Engines/engine";
  38523. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38524. /**
  38525. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38526. */
  38527. export class StereoscopicInterlacePostProcess extends PostProcess {
  38528. private _stepSize;
  38529. private _passedProcess;
  38530. /**
  38531. * Initializes a StereoscopicInterlacePostProcess
  38532. * @param name The name of the effect.
  38533. * @param rigCameras The rig cameras to be appled to the post process
  38534. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38536. * @param engine The engine which the post process will be applied. (default: current engine)
  38537. * @param reusable If the post process can be reused on the same frame. (default: false)
  38538. */
  38539. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38540. }
  38541. }
  38542. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38543. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38544. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38545. import { Scene } from "babylonjs/scene";
  38546. import { Vector3 } from "babylonjs/Maths/math";
  38547. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38548. /**
  38549. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38550. * @see http://doc.babylonjs.com/features/cameras
  38551. */
  38552. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38553. /**
  38554. * Creates a new StereoscopicArcRotateCamera
  38555. * @param name defines camera name
  38556. * @param alpha defines alpha angle (in radians)
  38557. * @param beta defines beta angle (in radians)
  38558. * @param radius defines radius
  38559. * @param target defines camera target
  38560. * @param interaxialDistance defines distance between each color axis
  38561. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38562. * @param scene defines the hosting scene
  38563. */
  38564. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38565. /**
  38566. * Gets camera class name
  38567. * @returns StereoscopicArcRotateCamera
  38568. */
  38569. getClassName(): string;
  38570. }
  38571. }
  38572. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38573. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38574. import { Scene } from "babylonjs/scene";
  38575. import { Vector3 } from "babylonjs/Maths/math";
  38576. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38577. /**
  38578. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38579. * @see http://doc.babylonjs.com/features/cameras
  38580. */
  38581. export class StereoscopicFreeCamera extends FreeCamera {
  38582. /**
  38583. * Creates a new StereoscopicFreeCamera
  38584. * @param name defines camera name
  38585. * @param position defines initial position
  38586. * @param interaxialDistance defines distance between each color axis
  38587. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38588. * @param scene defines the hosting scene
  38589. */
  38590. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38591. /**
  38592. * Gets camera class name
  38593. * @returns StereoscopicFreeCamera
  38594. */
  38595. getClassName(): string;
  38596. }
  38597. }
  38598. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38599. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38600. import { Scene } from "babylonjs/scene";
  38601. import { Vector3 } from "babylonjs/Maths/math";
  38602. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38603. /**
  38604. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38605. * @see http://doc.babylonjs.com/features/cameras
  38606. */
  38607. export class StereoscopicGamepadCamera extends GamepadCamera {
  38608. /**
  38609. * Creates a new StereoscopicGamepadCamera
  38610. * @param name defines camera name
  38611. * @param position defines initial position
  38612. * @param interaxialDistance defines distance between each color axis
  38613. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38614. * @param scene defines the hosting scene
  38615. */
  38616. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38617. /**
  38618. * Gets camera class name
  38619. * @returns StereoscopicGamepadCamera
  38620. */
  38621. getClassName(): string;
  38622. }
  38623. }
  38624. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38625. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38626. import { Scene } from "babylonjs/scene";
  38627. import { Vector3 } from "babylonjs/Maths/math";
  38628. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38629. /**
  38630. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38631. * @see http://doc.babylonjs.com/features/cameras
  38632. */
  38633. export class StereoscopicUniversalCamera extends UniversalCamera {
  38634. /**
  38635. * Creates a new StereoscopicUniversalCamera
  38636. * @param name defines camera name
  38637. * @param position defines initial position
  38638. * @param interaxialDistance defines distance between each color axis
  38639. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38640. * @param scene defines the hosting scene
  38641. */
  38642. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38643. /**
  38644. * Gets camera class name
  38645. * @returns StereoscopicUniversalCamera
  38646. */
  38647. getClassName(): string;
  38648. }
  38649. }
  38650. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38651. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38652. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38653. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38654. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38655. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38656. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38657. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38658. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38659. }
  38660. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38661. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38662. import { Scene } from "babylonjs/scene";
  38663. import { Vector3 } from "babylonjs/Maths/math";
  38664. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38665. /**
  38666. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38667. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38668. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38669. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38670. */
  38671. export class VirtualJoysticksCamera extends FreeCamera {
  38672. /**
  38673. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38674. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38675. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38676. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38677. * @param name Define the name of the camera in the scene
  38678. * @param position Define the start position of the camera in the scene
  38679. * @param scene Define the scene the camera belongs to
  38680. */
  38681. constructor(name: string, position: Vector3, scene: Scene);
  38682. /**
  38683. * Gets the current object class name.
  38684. * @return the class name
  38685. */
  38686. getClassName(): string;
  38687. }
  38688. }
  38689. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38690. import { Matrix } from "babylonjs/Maths/math";
  38691. /**
  38692. * This represents all the required metrics to create a VR camera.
  38693. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38694. */
  38695. export class VRCameraMetrics {
  38696. /**
  38697. * Define the horizontal resolution off the screen.
  38698. */
  38699. hResolution: number;
  38700. /**
  38701. * Define the vertical resolution off the screen.
  38702. */
  38703. vResolution: number;
  38704. /**
  38705. * Define the horizontal screen size.
  38706. */
  38707. hScreenSize: number;
  38708. /**
  38709. * Define the vertical screen size.
  38710. */
  38711. vScreenSize: number;
  38712. /**
  38713. * Define the vertical screen center position.
  38714. */
  38715. vScreenCenter: number;
  38716. /**
  38717. * Define the distance of the eyes to the screen.
  38718. */
  38719. eyeToScreenDistance: number;
  38720. /**
  38721. * Define the distance between both lenses
  38722. */
  38723. lensSeparationDistance: number;
  38724. /**
  38725. * Define the distance between both viewer's eyes.
  38726. */
  38727. interpupillaryDistance: number;
  38728. /**
  38729. * Define the distortion factor of the VR postprocess.
  38730. * Please, touch with care.
  38731. */
  38732. distortionK: number[];
  38733. /**
  38734. * Define the chromatic aberration correction factors for the VR post process.
  38735. */
  38736. chromaAbCorrection: number[];
  38737. /**
  38738. * Define the scale factor of the post process.
  38739. * The smaller the better but the slower.
  38740. */
  38741. postProcessScaleFactor: number;
  38742. /**
  38743. * Define an offset for the lens center.
  38744. */
  38745. lensCenterOffset: number;
  38746. /**
  38747. * Define if the current vr camera should compensate the distortion of the lense or not.
  38748. */
  38749. compensateDistortion: boolean;
  38750. /**
  38751. * Defines if multiview should be enabled when rendering (Default: false)
  38752. */
  38753. multiviewEnabled: boolean;
  38754. /**
  38755. * Gets the rendering aspect ratio based on the provided resolutions.
  38756. */
  38757. readonly aspectRatio: number;
  38758. /**
  38759. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38760. */
  38761. readonly aspectRatioFov: number;
  38762. /**
  38763. * @hidden
  38764. */
  38765. readonly leftHMatrix: Matrix;
  38766. /**
  38767. * @hidden
  38768. */
  38769. readonly rightHMatrix: Matrix;
  38770. /**
  38771. * @hidden
  38772. */
  38773. readonly leftPreViewMatrix: Matrix;
  38774. /**
  38775. * @hidden
  38776. */
  38777. readonly rightPreViewMatrix: Matrix;
  38778. /**
  38779. * Get the default VRMetrics based on the most generic setup.
  38780. * @returns the default vr metrics
  38781. */
  38782. static GetDefault(): VRCameraMetrics;
  38783. }
  38784. }
  38785. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38786. /** @hidden */
  38787. export var vrDistortionCorrectionPixelShader: {
  38788. name: string;
  38789. shader: string;
  38790. };
  38791. }
  38792. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38793. import { Camera } from "babylonjs/Cameras/camera";
  38794. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38795. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38796. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38797. /**
  38798. * VRDistortionCorrectionPostProcess used for mobile VR
  38799. */
  38800. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38801. private _isRightEye;
  38802. private _distortionFactors;
  38803. private _postProcessScaleFactor;
  38804. private _lensCenterOffset;
  38805. private _scaleIn;
  38806. private _scaleFactor;
  38807. private _lensCenter;
  38808. /**
  38809. * Initializes the VRDistortionCorrectionPostProcess
  38810. * @param name The name of the effect.
  38811. * @param camera The camera to apply the render pass to.
  38812. * @param isRightEye If this is for the right eye distortion
  38813. * @param vrMetrics All the required metrics for the VR camera
  38814. */
  38815. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38816. }
  38817. }
  38818. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38819. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38820. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38821. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38822. import { Scene } from "babylonjs/scene";
  38823. import { Vector3 } from "babylonjs/Maths/math";
  38824. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38825. import "babylonjs/Cameras/RigModes/vrRigMode";
  38826. /**
  38827. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38828. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38829. */
  38830. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38831. /**
  38832. * Creates a new VRDeviceOrientationArcRotateCamera
  38833. * @param name defines camera name
  38834. * @param alpha defines the camera rotation along the logitudinal axis
  38835. * @param beta defines the camera rotation along the latitudinal axis
  38836. * @param radius defines the camera distance from its target
  38837. * @param target defines the camera target
  38838. * @param scene defines the scene the camera belongs to
  38839. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38840. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38841. */
  38842. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38843. /**
  38844. * Gets camera class name
  38845. * @returns VRDeviceOrientationArcRotateCamera
  38846. */
  38847. getClassName(): string;
  38848. }
  38849. }
  38850. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38851. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38852. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38853. import { Scene } from "babylonjs/scene";
  38854. import { Vector3 } from "babylonjs/Maths/math";
  38855. import "babylonjs/Cameras/RigModes/vrRigMode";
  38856. /**
  38857. * Camera used to simulate VR rendering (based on FreeCamera)
  38858. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38859. */
  38860. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38861. /**
  38862. * Creates a new VRDeviceOrientationFreeCamera
  38863. * @param name defines camera name
  38864. * @param position defines the start position of the camera
  38865. * @param scene defines the scene the camera belongs to
  38866. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38867. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38868. */
  38869. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38870. /**
  38871. * Gets camera class name
  38872. * @returns VRDeviceOrientationFreeCamera
  38873. */
  38874. getClassName(): string;
  38875. }
  38876. }
  38877. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38878. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38879. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38880. import { Scene } from "babylonjs/scene";
  38881. import { Vector3 } from "babylonjs/Maths/math";
  38882. /**
  38883. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38884. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38885. */
  38886. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38887. /**
  38888. * Creates a new VRDeviceOrientationGamepadCamera
  38889. * @param name defines camera name
  38890. * @param position defines the start position of the camera
  38891. * @param scene defines the scene the camera belongs to
  38892. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38893. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38894. */
  38895. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38896. /**
  38897. * Gets camera class name
  38898. * @returns VRDeviceOrientationGamepadCamera
  38899. */
  38900. getClassName(): string;
  38901. }
  38902. }
  38903. declare module "babylonjs/Gamepads/xboxGamepad" {
  38904. import { Observable } from "babylonjs/Misc/observable";
  38905. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38906. /**
  38907. * Defines supported buttons for XBox360 compatible gamepads
  38908. */
  38909. export enum Xbox360Button {
  38910. /** A */
  38911. A = 0,
  38912. /** B */
  38913. B = 1,
  38914. /** X */
  38915. X = 2,
  38916. /** Y */
  38917. Y = 3,
  38918. /** Start */
  38919. Start = 4,
  38920. /** Back */
  38921. Back = 5,
  38922. /** Left button */
  38923. LB = 6,
  38924. /** Right button */
  38925. RB = 7,
  38926. /** Left stick */
  38927. LeftStick = 8,
  38928. /** Right stick */
  38929. RightStick = 9
  38930. }
  38931. /** Defines values for XBox360 DPad */
  38932. export enum Xbox360Dpad {
  38933. /** Up */
  38934. Up = 0,
  38935. /** Down */
  38936. Down = 1,
  38937. /** Left */
  38938. Left = 2,
  38939. /** Right */
  38940. Right = 3
  38941. }
  38942. /**
  38943. * Defines a XBox360 gamepad
  38944. */
  38945. export class Xbox360Pad extends Gamepad {
  38946. private _leftTrigger;
  38947. private _rightTrigger;
  38948. private _onlefttriggerchanged;
  38949. private _onrighttriggerchanged;
  38950. private _onbuttondown;
  38951. private _onbuttonup;
  38952. private _ondpaddown;
  38953. private _ondpadup;
  38954. /** Observable raised when a button is pressed */
  38955. onButtonDownObservable: Observable<Xbox360Button>;
  38956. /** Observable raised when a button is released */
  38957. onButtonUpObservable: Observable<Xbox360Button>;
  38958. /** Observable raised when a pad is pressed */
  38959. onPadDownObservable: Observable<Xbox360Dpad>;
  38960. /** Observable raised when a pad is released */
  38961. onPadUpObservable: Observable<Xbox360Dpad>;
  38962. private _buttonA;
  38963. private _buttonB;
  38964. private _buttonX;
  38965. private _buttonY;
  38966. private _buttonBack;
  38967. private _buttonStart;
  38968. private _buttonLB;
  38969. private _buttonRB;
  38970. private _buttonLeftStick;
  38971. private _buttonRightStick;
  38972. private _dPadUp;
  38973. private _dPadDown;
  38974. private _dPadLeft;
  38975. private _dPadRight;
  38976. private _isXboxOnePad;
  38977. /**
  38978. * Creates a new XBox360 gamepad object
  38979. * @param id defines the id of this gamepad
  38980. * @param index defines its index
  38981. * @param gamepad defines the internal HTML gamepad object
  38982. * @param xboxOne defines if it is a XBox One gamepad
  38983. */
  38984. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38985. /**
  38986. * Defines the callback to call when left trigger is pressed
  38987. * @param callback defines the callback to use
  38988. */
  38989. onlefttriggerchanged(callback: (value: number) => void): void;
  38990. /**
  38991. * Defines the callback to call when right trigger is pressed
  38992. * @param callback defines the callback to use
  38993. */
  38994. onrighttriggerchanged(callback: (value: number) => void): void;
  38995. /**
  38996. * Gets the left trigger value
  38997. */
  38998. /**
  38999. * Sets the left trigger value
  39000. */
  39001. leftTrigger: number;
  39002. /**
  39003. * Gets the right trigger value
  39004. */
  39005. /**
  39006. * Sets the right trigger value
  39007. */
  39008. rightTrigger: number;
  39009. /**
  39010. * Defines the callback to call when a button is pressed
  39011. * @param callback defines the callback to use
  39012. */
  39013. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39014. /**
  39015. * Defines the callback to call when a button is released
  39016. * @param callback defines the callback to use
  39017. */
  39018. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39019. /**
  39020. * Defines the callback to call when a pad is pressed
  39021. * @param callback defines the callback to use
  39022. */
  39023. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39024. /**
  39025. * Defines the callback to call when a pad is released
  39026. * @param callback defines the callback to use
  39027. */
  39028. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39029. private _setButtonValue;
  39030. private _setDPadValue;
  39031. /**
  39032. * Gets the value of the `A` button
  39033. */
  39034. /**
  39035. * Sets the value of the `A` button
  39036. */
  39037. buttonA: number;
  39038. /**
  39039. * Gets the value of the `B` button
  39040. */
  39041. /**
  39042. * Sets the value of the `B` button
  39043. */
  39044. buttonB: number;
  39045. /**
  39046. * Gets the value of the `X` button
  39047. */
  39048. /**
  39049. * Sets the value of the `X` button
  39050. */
  39051. buttonX: number;
  39052. /**
  39053. * Gets the value of the `Y` button
  39054. */
  39055. /**
  39056. * Sets the value of the `Y` button
  39057. */
  39058. buttonY: number;
  39059. /**
  39060. * Gets the value of the `Start` button
  39061. */
  39062. /**
  39063. * Sets the value of the `Start` button
  39064. */
  39065. buttonStart: number;
  39066. /**
  39067. * Gets the value of the `Back` button
  39068. */
  39069. /**
  39070. * Sets the value of the `Back` button
  39071. */
  39072. buttonBack: number;
  39073. /**
  39074. * Gets the value of the `Left` button
  39075. */
  39076. /**
  39077. * Sets the value of the `Left` button
  39078. */
  39079. buttonLB: number;
  39080. /**
  39081. * Gets the value of the `Right` button
  39082. */
  39083. /**
  39084. * Sets the value of the `Right` button
  39085. */
  39086. buttonRB: number;
  39087. /**
  39088. * Gets the value of the Left joystick
  39089. */
  39090. /**
  39091. * Sets the value of the Left joystick
  39092. */
  39093. buttonLeftStick: number;
  39094. /**
  39095. * Gets the value of the Right joystick
  39096. */
  39097. /**
  39098. * Sets the value of the Right joystick
  39099. */
  39100. buttonRightStick: number;
  39101. /**
  39102. * Gets the value of D-pad up
  39103. */
  39104. /**
  39105. * Sets the value of D-pad up
  39106. */
  39107. dPadUp: number;
  39108. /**
  39109. * Gets the value of D-pad down
  39110. */
  39111. /**
  39112. * Sets the value of D-pad down
  39113. */
  39114. dPadDown: number;
  39115. /**
  39116. * Gets the value of D-pad left
  39117. */
  39118. /**
  39119. * Sets the value of D-pad left
  39120. */
  39121. dPadLeft: number;
  39122. /**
  39123. * Gets the value of D-pad right
  39124. */
  39125. /**
  39126. * Sets the value of D-pad right
  39127. */
  39128. dPadRight: number;
  39129. /**
  39130. * Force the gamepad to synchronize with device values
  39131. */
  39132. update(): void;
  39133. /**
  39134. * Disposes the gamepad
  39135. */
  39136. dispose(): void;
  39137. }
  39138. }
  39139. declare module "babylonjs/Materials/pushMaterial" {
  39140. import { Nullable } from "babylonjs/types";
  39141. import { Scene } from "babylonjs/scene";
  39142. import { Matrix } from "babylonjs/Maths/math";
  39143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39144. import { Mesh } from "babylonjs/Meshes/mesh";
  39145. import { Material } from "babylonjs/Materials/material";
  39146. import { Effect } from "babylonjs/Materials/effect";
  39147. /**
  39148. * Base class of materials working in push mode in babylon JS
  39149. * @hidden
  39150. */
  39151. export class PushMaterial extends Material {
  39152. protected _activeEffect: Effect;
  39153. protected _normalMatrix: Matrix;
  39154. /**
  39155. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39156. * This means that the material can keep using a previous shader while a new one is being compiled.
  39157. * This is mostly used when shader parallel compilation is supported (true by default)
  39158. */
  39159. allowShaderHotSwapping: boolean;
  39160. constructor(name: string, scene: Scene);
  39161. getEffect(): Effect;
  39162. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39163. /**
  39164. * Binds the given world matrix to the active effect
  39165. *
  39166. * @param world the matrix to bind
  39167. */
  39168. bindOnlyWorldMatrix(world: Matrix): void;
  39169. /**
  39170. * Binds the given normal matrix to the active effect
  39171. *
  39172. * @param normalMatrix the matrix to bind
  39173. */
  39174. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39175. bind(world: Matrix, mesh?: Mesh): void;
  39176. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39177. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39178. }
  39179. }
  39180. declare module "babylonjs/Materials/materialFlags" {
  39181. /**
  39182. * This groups all the flags used to control the materials channel.
  39183. */
  39184. export class MaterialFlags {
  39185. private static _DiffuseTextureEnabled;
  39186. /**
  39187. * Are diffuse textures enabled in the application.
  39188. */
  39189. static DiffuseTextureEnabled: boolean;
  39190. private static _AmbientTextureEnabled;
  39191. /**
  39192. * Are ambient textures enabled in the application.
  39193. */
  39194. static AmbientTextureEnabled: boolean;
  39195. private static _OpacityTextureEnabled;
  39196. /**
  39197. * Are opacity textures enabled in the application.
  39198. */
  39199. static OpacityTextureEnabled: boolean;
  39200. private static _ReflectionTextureEnabled;
  39201. /**
  39202. * Are reflection textures enabled in the application.
  39203. */
  39204. static ReflectionTextureEnabled: boolean;
  39205. private static _EmissiveTextureEnabled;
  39206. /**
  39207. * Are emissive textures enabled in the application.
  39208. */
  39209. static EmissiveTextureEnabled: boolean;
  39210. private static _SpecularTextureEnabled;
  39211. /**
  39212. * Are specular textures enabled in the application.
  39213. */
  39214. static SpecularTextureEnabled: boolean;
  39215. private static _BumpTextureEnabled;
  39216. /**
  39217. * Are bump textures enabled in the application.
  39218. */
  39219. static BumpTextureEnabled: boolean;
  39220. private static _LightmapTextureEnabled;
  39221. /**
  39222. * Are lightmap textures enabled in the application.
  39223. */
  39224. static LightmapTextureEnabled: boolean;
  39225. private static _RefractionTextureEnabled;
  39226. /**
  39227. * Are refraction textures enabled in the application.
  39228. */
  39229. static RefractionTextureEnabled: boolean;
  39230. private static _ColorGradingTextureEnabled;
  39231. /**
  39232. * Are color grading textures enabled in the application.
  39233. */
  39234. static ColorGradingTextureEnabled: boolean;
  39235. private static _FresnelEnabled;
  39236. /**
  39237. * Are fresnels enabled in the application.
  39238. */
  39239. static FresnelEnabled: boolean;
  39240. private static _ClearCoatTextureEnabled;
  39241. /**
  39242. * Are clear coat textures enabled in the application.
  39243. */
  39244. static ClearCoatTextureEnabled: boolean;
  39245. private static _ClearCoatBumpTextureEnabled;
  39246. /**
  39247. * Are clear coat bump textures enabled in the application.
  39248. */
  39249. static ClearCoatBumpTextureEnabled: boolean;
  39250. private static _ClearCoatTintTextureEnabled;
  39251. /**
  39252. * Are clear coat tint textures enabled in the application.
  39253. */
  39254. static ClearCoatTintTextureEnabled: boolean;
  39255. private static _SheenTextureEnabled;
  39256. /**
  39257. * Are sheen textures enabled in the application.
  39258. */
  39259. static SheenTextureEnabled: boolean;
  39260. private static _AnisotropicTextureEnabled;
  39261. /**
  39262. * Are anisotropic textures enabled in the application.
  39263. */
  39264. static AnisotropicTextureEnabled: boolean;
  39265. private static _ThicknessTextureEnabled;
  39266. /**
  39267. * Are thickness textures enabled in the application.
  39268. */
  39269. static ThicknessTextureEnabled: boolean;
  39270. }
  39271. }
  39272. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39273. /** @hidden */
  39274. export var defaultFragmentDeclaration: {
  39275. name: string;
  39276. shader: string;
  39277. };
  39278. }
  39279. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39280. /** @hidden */
  39281. export var defaultUboDeclaration: {
  39282. name: string;
  39283. shader: string;
  39284. };
  39285. }
  39286. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39287. /** @hidden */
  39288. export var lightFragmentDeclaration: {
  39289. name: string;
  39290. shader: string;
  39291. };
  39292. }
  39293. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39294. /** @hidden */
  39295. export var lightUboDeclaration: {
  39296. name: string;
  39297. shader: string;
  39298. };
  39299. }
  39300. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39301. /** @hidden */
  39302. export var lightsFragmentFunctions: {
  39303. name: string;
  39304. shader: string;
  39305. };
  39306. }
  39307. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39308. /** @hidden */
  39309. export var shadowsFragmentFunctions: {
  39310. name: string;
  39311. shader: string;
  39312. };
  39313. }
  39314. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39315. /** @hidden */
  39316. export var fresnelFunction: {
  39317. name: string;
  39318. shader: string;
  39319. };
  39320. }
  39321. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39322. /** @hidden */
  39323. export var reflectionFunction: {
  39324. name: string;
  39325. shader: string;
  39326. };
  39327. }
  39328. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39329. /** @hidden */
  39330. export var bumpFragmentFunctions: {
  39331. name: string;
  39332. shader: string;
  39333. };
  39334. }
  39335. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39336. /** @hidden */
  39337. export var logDepthDeclaration: {
  39338. name: string;
  39339. shader: string;
  39340. };
  39341. }
  39342. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39343. /** @hidden */
  39344. export var bumpFragment: {
  39345. name: string;
  39346. shader: string;
  39347. };
  39348. }
  39349. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39350. /** @hidden */
  39351. export var depthPrePass: {
  39352. name: string;
  39353. shader: string;
  39354. };
  39355. }
  39356. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39357. /** @hidden */
  39358. export var lightFragment: {
  39359. name: string;
  39360. shader: string;
  39361. };
  39362. }
  39363. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39364. /** @hidden */
  39365. export var logDepthFragment: {
  39366. name: string;
  39367. shader: string;
  39368. };
  39369. }
  39370. declare module "babylonjs/Shaders/default.fragment" {
  39371. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39372. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39373. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39374. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39375. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39376. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39377. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39378. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39379. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39380. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39381. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39382. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39383. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39384. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39385. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39386. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39387. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39388. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39389. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39390. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39391. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39392. /** @hidden */
  39393. export var defaultPixelShader: {
  39394. name: string;
  39395. shader: string;
  39396. };
  39397. }
  39398. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39399. /** @hidden */
  39400. export var defaultVertexDeclaration: {
  39401. name: string;
  39402. shader: string;
  39403. };
  39404. }
  39405. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39406. /** @hidden */
  39407. export var bumpVertexDeclaration: {
  39408. name: string;
  39409. shader: string;
  39410. };
  39411. }
  39412. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39413. /** @hidden */
  39414. export var bumpVertex: {
  39415. name: string;
  39416. shader: string;
  39417. };
  39418. }
  39419. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39420. /** @hidden */
  39421. export var fogVertex: {
  39422. name: string;
  39423. shader: string;
  39424. };
  39425. }
  39426. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39427. /** @hidden */
  39428. export var shadowsVertex: {
  39429. name: string;
  39430. shader: string;
  39431. };
  39432. }
  39433. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39434. /** @hidden */
  39435. export var pointCloudVertex: {
  39436. name: string;
  39437. shader: string;
  39438. };
  39439. }
  39440. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39441. /** @hidden */
  39442. export var logDepthVertex: {
  39443. name: string;
  39444. shader: string;
  39445. };
  39446. }
  39447. declare module "babylonjs/Shaders/default.vertex" {
  39448. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39449. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39450. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39451. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39452. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39453. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39454. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39455. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39456. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39457. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39458. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39459. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39460. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39461. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39462. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39463. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39464. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39465. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39466. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39467. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39468. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39469. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39470. /** @hidden */
  39471. export var defaultVertexShader: {
  39472. name: string;
  39473. shader: string;
  39474. };
  39475. }
  39476. declare module "babylonjs/Materials/standardMaterial" {
  39477. import { SmartArray } from "babylonjs/Misc/smartArray";
  39478. import { IAnimatable } from "babylonjs/Misc/tools";
  39479. import { Nullable } from "babylonjs/types";
  39480. import { Scene } from "babylonjs/scene";
  39481. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39482. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39484. import { Mesh } from "babylonjs/Meshes/mesh";
  39485. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39486. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39487. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39488. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39489. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39490. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39491. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39492. import "babylonjs/Shaders/default.fragment";
  39493. import "babylonjs/Shaders/default.vertex";
  39494. /** @hidden */
  39495. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39496. MAINUV1: boolean;
  39497. MAINUV2: boolean;
  39498. DIFFUSE: boolean;
  39499. DIFFUSEDIRECTUV: number;
  39500. AMBIENT: boolean;
  39501. AMBIENTDIRECTUV: number;
  39502. OPACITY: boolean;
  39503. OPACITYDIRECTUV: number;
  39504. OPACITYRGB: boolean;
  39505. REFLECTION: boolean;
  39506. EMISSIVE: boolean;
  39507. EMISSIVEDIRECTUV: number;
  39508. SPECULAR: boolean;
  39509. SPECULARDIRECTUV: number;
  39510. BUMP: boolean;
  39511. BUMPDIRECTUV: number;
  39512. PARALLAX: boolean;
  39513. PARALLAXOCCLUSION: boolean;
  39514. SPECULAROVERALPHA: boolean;
  39515. CLIPPLANE: boolean;
  39516. CLIPPLANE2: boolean;
  39517. CLIPPLANE3: boolean;
  39518. CLIPPLANE4: boolean;
  39519. ALPHATEST: boolean;
  39520. DEPTHPREPASS: boolean;
  39521. ALPHAFROMDIFFUSE: boolean;
  39522. POINTSIZE: boolean;
  39523. FOG: boolean;
  39524. SPECULARTERM: boolean;
  39525. DIFFUSEFRESNEL: boolean;
  39526. OPACITYFRESNEL: boolean;
  39527. REFLECTIONFRESNEL: boolean;
  39528. REFRACTIONFRESNEL: boolean;
  39529. EMISSIVEFRESNEL: boolean;
  39530. FRESNEL: boolean;
  39531. NORMAL: boolean;
  39532. UV1: boolean;
  39533. UV2: boolean;
  39534. VERTEXCOLOR: boolean;
  39535. VERTEXALPHA: boolean;
  39536. NUM_BONE_INFLUENCERS: number;
  39537. BonesPerMesh: number;
  39538. BONETEXTURE: boolean;
  39539. INSTANCES: boolean;
  39540. GLOSSINESS: boolean;
  39541. ROUGHNESS: boolean;
  39542. EMISSIVEASILLUMINATION: boolean;
  39543. LINKEMISSIVEWITHDIFFUSE: boolean;
  39544. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39545. LIGHTMAP: boolean;
  39546. LIGHTMAPDIRECTUV: number;
  39547. OBJECTSPACE_NORMALMAP: boolean;
  39548. USELIGHTMAPASSHADOWMAP: boolean;
  39549. REFLECTIONMAP_3D: boolean;
  39550. REFLECTIONMAP_SPHERICAL: boolean;
  39551. REFLECTIONMAP_PLANAR: boolean;
  39552. REFLECTIONMAP_CUBIC: boolean;
  39553. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39554. REFLECTIONMAP_PROJECTION: boolean;
  39555. REFLECTIONMAP_SKYBOX: boolean;
  39556. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39557. REFLECTIONMAP_EXPLICIT: boolean;
  39558. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39559. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39560. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39561. INVERTCUBICMAP: boolean;
  39562. LOGARITHMICDEPTH: boolean;
  39563. REFRACTION: boolean;
  39564. REFRACTIONMAP_3D: boolean;
  39565. REFLECTIONOVERALPHA: boolean;
  39566. TWOSIDEDLIGHTING: boolean;
  39567. SHADOWFLOAT: boolean;
  39568. MORPHTARGETS: boolean;
  39569. MORPHTARGETS_NORMAL: boolean;
  39570. MORPHTARGETS_TANGENT: boolean;
  39571. NUM_MORPH_INFLUENCERS: number;
  39572. NONUNIFORMSCALING: boolean;
  39573. PREMULTIPLYALPHA: boolean;
  39574. IMAGEPROCESSING: boolean;
  39575. VIGNETTE: boolean;
  39576. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39577. VIGNETTEBLENDMODEOPAQUE: boolean;
  39578. TONEMAPPING: boolean;
  39579. TONEMAPPING_ACES: boolean;
  39580. CONTRAST: boolean;
  39581. COLORCURVES: boolean;
  39582. COLORGRADING: boolean;
  39583. COLORGRADING3D: boolean;
  39584. SAMPLER3DGREENDEPTH: boolean;
  39585. SAMPLER3DBGRMAP: boolean;
  39586. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39587. MULTIVIEW: boolean;
  39588. /**
  39589. * If the reflection texture on this material is in linear color space
  39590. * @hidden
  39591. */
  39592. IS_REFLECTION_LINEAR: boolean;
  39593. /**
  39594. * If the refraction texture on this material is in linear color space
  39595. * @hidden
  39596. */
  39597. IS_REFRACTION_LINEAR: boolean;
  39598. EXPOSURE: boolean;
  39599. constructor();
  39600. setReflectionMode(modeToEnable: string): void;
  39601. }
  39602. /**
  39603. * This is the default material used in Babylon. It is the best trade off between quality
  39604. * and performances.
  39605. * @see http://doc.babylonjs.com/babylon101/materials
  39606. */
  39607. export class StandardMaterial extends PushMaterial {
  39608. private _diffuseTexture;
  39609. /**
  39610. * The basic texture of the material as viewed under a light.
  39611. */
  39612. diffuseTexture: Nullable<BaseTexture>;
  39613. private _ambientTexture;
  39614. /**
  39615. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39616. */
  39617. ambientTexture: Nullable<BaseTexture>;
  39618. private _opacityTexture;
  39619. /**
  39620. * Define the transparency of the material from a texture.
  39621. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39622. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39623. */
  39624. opacityTexture: Nullable<BaseTexture>;
  39625. private _reflectionTexture;
  39626. /**
  39627. * Define the texture used to display the reflection.
  39628. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39629. */
  39630. reflectionTexture: Nullable<BaseTexture>;
  39631. private _emissiveTexture;
  39632. /**
  39633. * Define texture of the material as if self lit.
  39634. * This will be mixed in the final result even in the absence of light.
  39635. */
  39636. emissiveTexture: Nullable<BaseTexture>;
  39637. private _specularTexture;
  39638. /**
  39639. * Define how the color and intensity of the highlight given by the light in the material.
  39640. */
  39641. specularTexture: Nullable<BaseTexture>;
  39642. private _bumpTexture;
  39643. /**
  39644. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39645. * 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.
  39646. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39647. */
  39648. bumpTexture: Nullable<BaseTexture>;
  39649. private _lightmapTexture;
  39650. /**
  39651. * Complex lighting can be computationally expensive to compute at runtime.
  39652. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39653. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39654. */
  39655. lightmapTexture: Nullable<BaseTexture>;
  39656. private _refractionTexture;
  39657. /**
  39658. * Define the texture used to display the refraction.
  39659. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39660. */
  39661. refractionTexture: Nullable<BaseTexture>;
  39662. /**
  39663. * The color of the material lit by the environmental background lighting.
  39664. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39665. */
  39666. ambientColor: Color3;
  39667. /**
  39668. * The basic color of the material as viewed under a light.
  39669. */
  39670. diffuseColor: Color3;
  39671. /**
  39672. * Define how the color and intensity of the highlight given by the light in the material.
  39673. */
  39674. specularColor: Color3;
  39675. /**
  39676. * Define the color of the material as if self lit.
  39677. * This will be mixed in the final result even in the absence of light.
  39678. */
  39679. emissiveColor: Color3;
  39680. /**
  39681. * Defines how sharp are the highlights in the material.
  39682. * The bigger the value the sharper giving a more glossy feeling to the result.
  39683. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39684. */
  39685. specularPower: number;
  39686. private _useAlphaFromDiffuseTexture;
  39687. /**
  39688. * Does the transparency come from the diffuse texture alpha channel.
  39689. */
  39690. useAlphaFromDiffuseTexture: boolean;
  39691. private _useEmissiveAsIllumination;
  39692. /**
  39693. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39694. */
  39695. useEmissiveAsIllumination: boolean;
  39696. private _linkEmissiveWithDiffuse;
  39697. /**
  39698. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39699. * the emissive level when the final color is close to one.
  39700. */
  39701. linkEmissiveWithDiffuse: boolean;
  39702. private _useSpecularOverAlpha;
  39703. /**
  39704. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39705. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39706. */
  39707. useSpecularOverAlpha: boolean;
  39708. private _useReflectionOverAlpha;
  39709. /**
  39710. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39711. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39712. */
  39713. useReflectionOverAlpha: boolean;
  39714. private _disableLighting;
  39715. /**
  39716. * Does lights from the scene impacts this material.
  39717. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39718. */
  39719. disableLighting: boolean;
  39720. private _useObjectSpaceNormalMap;
  39721. /**
  39722. * Allows using an object space normal map (instead of tangent space).
  39723. */
  39724. useObjectSpaceNormalMap: boolean;
  39725. private _useParallax;
  39726. /**
  39727. * Is parallax enabled or not.
  39728. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39729. */
  39730. useParallax: boolean;
  39731. private _useParallaxOcclusion;
  39732. /**
  39733. * Is parallax occlusion enabled or not.
  39734. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39735. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39736. */
  39737. useParallaxOcclusion: boolean;
  39738. /**
  39739. * 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.
  39740. */
  39741. parallaxScaleBias: number;
  39742. private _roughness;
  39743. /**
  39744. * Helps to define how blurry the reflections should appears in the material.
  39745. */
  39746. roughness: number;
  39747. /**
  39748. * In case of refraction, define the value of the indice of refraction.
  39749. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39750. */
  39751. indexOfRefraction: number;
  39752. /**
  39753. * Invert the refraction texture alongside the y axis.
  39754. * It can be useful with procedural textures or probe for instance.
  39755. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39756. */
  39757. invertRefractionY: boolean;
  39758. /**
  39759. * Defines the alpha limits in alpha test mode.
  39760. */
  39761. alphaCutOff: number;
  39762. private _useLightmapAsShadowmap;
  39763. /**
  39764. * In case of light mapping, define whether the map contains light or shadow informations.
  39765. */
  39766. useLightmapAsShadowmap: boolean;
  39767. private _diffuseFresnelParameters;
  39768. /**
  39769. * Define the diffuse fresnel parameters of the material.
  39770. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39771. */
  39772. diffuseFresnelParameters: FresnelParameters;
  39773. private _opacityFresnelParameters;
  39774. /**
  39775. * Define the opacity fresnel parameters of the material.
  39776. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39777. */
  39778. opacityFresnelParameters: FresnelParameters;
  39779. private _reflectionFresnelParameters;
  39780. /**
  39781. * Define the reflection fresnel parameters of the material.
  39782. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39783. */
  39784. reflectionFresnelParameters: FresnelParameters;
  39785. private _refractionFresnelParameters;
  39786. /**
  39787. * Define the refraction fresnel parameters of the material.
  39788. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39789. */
  39790. refractionFresnelParameters: FresnelParameters;
  39791. private _emissiveFresnelParameters;
  39792. /**
  39793. * Define the emissive fresnel parameters of the material.
  39794. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39795. */
  39796. emissiveFresnelParameters: FresnelParameters;
  39797. private _useReflectionFresnelFromSpecular;
  39798. /**
  39799. * If true automatically deducts the fresnels values from the material specularity.
  39800. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39801. */
  39802. useReflectionFresnelFromSpecular: boolean;
  39803. private _useGlossinessFromSpecularMapAlpha;
  39804. /**
  39805. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39806. */
  39807. useGlossinessFromSpecularMapAlpha: boolean;
  39808. private _maxSimultaneousLights;
  39809. /**
  39810. * Defines the maximum number of lights that can be used in the material
  39811. */
  39812. maxSimultaneousLights: number;
  39813. private _invertNormalMapX;
  39814. /**
  39815. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39816. */
  39817. invertNormalMapX: boolean;
  39818. private _invertNormalMapY;
  39819. /**
  39820. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39821. */
  39822. invertNormalMapY: boolean;
  39823. private _twoSidedLighting;
  39824. /**
  39825. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39826. */
  39827. twoSidedLighting: boolean;
  39828. /**
  39829. * Default configuration related to image processing available in the standard Material.
  39830. */
  39831. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39832. /**
  39833. * Gets the image processing configuration used either in this material.
  39834. */
  39835. /**
  39836. * Sets the Default image processing configuration used either in the this material.
  39837. *
  39838. * If sets to null, the scene one is in use.
  39839. */
  39840. imageProcessingConfiguration: ImageProcessingConfiguration;
  39841. /**
  39842. * Keep track of the image processing observer to allow dispose and replace.
  39843. */
  39844. private _imageProcessingObserver;
  39845. /**
  39846. * Attaches a new image processing configuration to the Standard Material.
  39847. * @param configuration
  39848. */
  39849. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39850. /**
  39851. * Gets wether the color curves effect is enabled.
  39852. */
  39853. /**
  39854. * Sets wether the color curves effect is enabled.
  39855. */
  39856. cameraColorCurvesEnabled: boolean;
  39857. /**
  39858. * Gets wether the color grading effect is enabled.
  39859. */
  39860. /**
  39861. * Gets wether the color grading effect is enabled.
  39862. */
  39863. cameraColorGradingEnabled: boolean;
  39864. /**
  39865. * Gets wether tonemapping is enabled or not.
  39866. */
  39867. /**
  39868. * Sets wether tonemapping is enabled or not
  39869. */
  39870. cameraToneMappingEnabled: boolean;
  39871. /**
  39872. * The camera exposure used on this material.
  39873. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39874. * This corresponds to a photographic exposure.
  39875. */
  39876. /**
  39877. * The camera exposure used on this material.
  39878. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39879. * This corresponds to a photographic exposure.
  39880. */
  39881. cameraExposure: number;
  39882. /**
  39883. * Gets The camera contrast used on this material.
  39884. */
  39885. /**
  39886. * Sets The camera contrast used on this material.
  39887. */
  39888. cameraContrast: number;
  39889. /**
  39890. * Gets the Color Grading 2D Lookup Texture.
  39891. */
  39892. /**
  39893. * Sets the Color Grading 2D Lookup Texture.
  39894. */
  39895. cameraColorGradingTexture: Nullable<BaseTexture>;
  39896. /**
  39897. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39898. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39899. * 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;
  39900. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39901. */
  39902. /**
  39903. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39904. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39905. * 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;
  39906. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39907. */
  39908. cameraColorCurves: Nullable<ColorCurves>;
  39909. /**
  39910. * Custom callback helping to override the default shader used in the material.
  39911. */
  39912. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39913. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39914. protected _worldViewProjectionMatrix: Matrix;
  39915. protected _globalAmbientColor: Color3;
  39916. protected _useLogarithmicDepth: boolean;
  39917. /**
  39918. * Instantiates a new standard material.
  39919. * This is the default material used in Babylon. It is the best trade off between quality
  39920. * and performances.
  39921. * @see http://doc.babylonjs.com/babylon101/materials
  39922. * @param name Define the name of the material in the scene
  39923. * @param scene Define the scene the material belong to
  39924. */
  39925. constructor(name: string, scene: Scene);
  39926. /**
  39927. * Gets a boolean indicating that current material needs to register RTT
  39928. */
  39929. readonly hasRenderTargetTextures: boolean;
  39930. /**
  39931. * Gets the current class name of the material e.g. "StandardMaterial"
  39932. * Mainly use in serialization.
  39933. * @returns the class name
  39934. */
  39935. getClassName(): string;
  39936. /**
  39937. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39938. * You can try switching to logarithmic depth.
  39939. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39940. */
  39941. useLogarithmicDepth: boolean;
  39942. /**
  39943. * Specifies if the material will require alpha blending
  39944. * @returns a boolean specifying if alpha blending is needed
  39945. */
  39946. needAlphaBlending(): boolean;
  39947. /**
  39948. * Specifies if this material should be rendered in alpha test mode
  39949. * @returns a boolean specifying if an alpha test is needed.
  39950. */
  39951. needAlphaTesting(): boolean;
  39952. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39953. /**
  39954. * Get the texture used for alpha test purpose.
  39955. * @returns the diffuse texture in case of the standard material.
  39956. */
  39957. getAlphaTestTexture(): Nullable<BaseTexture>;
  39958. /**
  39959. * Get if the submesh is ready to be used and all its information available.
  39960. * Child classes can use it to update shaders
  39961. * @param mesh defines the mesh to check
  39962. * @param subMesh defines which submesh to check
  39963. * @param useInstances specifies that instances should be used
  39964. * @returns a boolean indicating that the submesh is ready or not
  39965. */
  39966. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39967. /**
  39968. * Builds the material UBO layouts.
  39969. * Used internally during the effect preparation.
  39970. */
  39971. buildUniformLayout(): void;
  39972. /**
  39973. * Unbinds the material from the mesh
  39974. */
  39975. unbind(): void;
  39976. /**
  39977. * Binds the submesh to this material by preparing the effect and shader to draw
  39978. * @param world defines the world transformation matrix
  39979. * @param mesh defines the mesh containing the submesh
  39980. * @param subMesh defines the submesh to bind the material to
  39981. */
  39982. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39983. /**
  39984. * Get the list of animatables in the material.
  39985. * @returns the list of animatables object used in the material
  39986. */
  39987. getAnimatables(): IAnimatable[];
  39988. /**
  39989. * Gets the active textures from the material
  39990. * @returns an array of textures
  39991. */
  39992. getActiveTextures(): BaseTexture[];
  39993. /**
  39994. * Specifies if the material uses a texture
  39995. * @param texture defines the texture to check against the material
  39996. * @returns a boolean specifying if the material uses the texture
  39997. */
  39998. hasTexture(texture: BaseTexture): boolean;
  39999. /**
  40000. * Disposes the material
  40001. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40002. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40003. */
  40004. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40005. /**
  40006. * Makes a duplicate of the material, and gives it a new name
  40007. * @param name defines the new name for the duplicated material
  40008. * @returns the cloned material
  40009. */
  40010. clone(name: string): StandardMaterial;
  40011. /**
  40012. * Serializes this material in a JSON representation
  40013. * @returns the serialized material object
  40014. */
  40015. serialize(): any;
  40016. /**
  40017. * Creates a standard material from parsed material data
  40018. * @param source defines the JSON representation of the material
  40019. * @param scene defines the hosting scene
  40020. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40021. * @returns a new standard material
  40022. */
  40023. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40024. /**
  40025. * Are diffuse textures enabled in the application.
  40026. */
  40027. static DiffuseTextureEnabled: boolean;
  40028. /**
  40029. * Are ambient textures enabled in the application.
  40030. */
  40031. static AmbientTextureEnabled: boolean;
  40032. /**
  40033. * Are opacity textures enabled in the application.
  40034. */
  40035. static OpacityTextureEnabled: boolean;
  40036. /**
  40037. * Are reflection textures enabled in the application.
  40038. */
  40039. static ReflectionTextureEnabled: boolean;
  40040. /**
  40041. * Are emissive textures enabled in the application.
  40042. */
  40043. static EmissiveTextureEnabled: boolean;
  40044. /**
  40045. * Are specular textures enabled in the application.
  40046. */
  40047. static SpecularTextureEnabled: boolean;
  40048. /**
  40049. * Are bump textures enabled in the application.
  40050. */
  40051. static BumpTextureEnabled: boolean;
  40052. /**
  40053. * Are lightmap textures enabled in the application.
  40054. */
  40055. static LightmapTextureEnabled: boolean;
  40056. /**
  40057. * Are refraction textures enabled in the application.
  40058. */
  40059. static RefractionTextureEnabled: boolean;
  40060. /**
  40061. * Are color grading textures enabled in the application.
  40062. */
  40063. static ColorGradingTextureEnabled: boolean;
  40064. /**
  40065. * Are fresnels enabled in the application.
  40066. */
  40067. static FresnelEnabled: boolean;
  40068. }
  40069. }
  40070. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40071. import { Scene } from "babylonjs/scene";
  40072. import { Texture } from "babylonjs/Materials/Textures/texture";
  40073. /**
  40074. * A class extending Texture allowing drawing on a texture
  40075. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40076. */
  40077. export class DynamicTexture extends Texture {
  40078. private _generateMipMaps;
  40079. private _canvas;
  40080. private _context;
  40081. private _engine;
  40082. /**
  40083. * Creates a DynamicTexture
  40084. * @param name defines the name of the texture
  40085. * @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
  40086. * @param scene defines the scene where you want the texture
  40087. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40088. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40089. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40090. */
  40091. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40092. /**
  40093. * Get the current class name of the texture useful for serialization or dynamic coding.
  40094. * @returns "DynamicTexture"
  40095. */
  40096. getClassName(): string;
  40097. /**
  40098. * Gets the current state of canRescale
  40099. */
  40100. readonly canRescale: boolean;
  40101. private _recreate;
  40102. /**
  40103. * Scales the texture
  40104. * @param ratio the scale factor to apply to both width and height
  40105. */
  40106. scale(ratio: number): void;
  40107. /**
  40108. * Resizes the texture
  40109. * @param width the new width
  40110. * @param height the new height
  40111. */
  40112. scaleTo(width: number, height: number): void;
  40113. /**
  40114. * Gets the context of the canvas used by the texture
  40115. * @returns the canvas context of the dynamic texture
  40116. */
  40117. getContext(): CanvasRenderingContext2D;
  40118. /**
  40119. * Clears the texture
  40120. */
  40121. clear(): void;
  40122. /**
  40123. * Updates the texture
  40124. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40125. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40126. */
  40127. update(invertY?: boolean, premulAlpha?: boolean): void;
  40128. /**
  40129. * Draws text onto the texture
  40130. * @param text defines the text to be drawn
  40131. * @param x defines the placement of the text from the left
  40132. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40133. * @param font defines the font to be used with font-style, font-size, font-name
  40134. * @param color defines the color used for the text
  40135. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40136. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40137. * @param update defines whether texture is immediately update (default is true)
  40138. */
  40139. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40140. /**
  40141. * Clones the texture
  40142. * @returns the clone of the texture.
  40143. */
  40144. clone(): DynamicTexture;
  40145. /**
  40146. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40147. * @returns a serialized dynamic texture object
  40148. */
  40149. serialize(): any;
  40150. /** @hidden */
  40151. _rebuild(): void;
  40152. }
  40153. }
  40154. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40155. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40156. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40157. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40158. /** @hidden */
  40159. export var imageProcessingPixelShader: {
  40160. name: string;
  40161. shader: string;
  40162. };
  40163. }
  40164. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40165. import { Nullable } from "babylonjs/types";
  40166. import { Color4 } from "babylonjs/Maths/math";
  40167. import { Camera } from "babylonjs/Cameras/camera";
  40168. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40169. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40170. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40171. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40172. import { Engine } from "babylonjs/Engines/engine";
  40173. import "babylonjs/Shaders/imageProcessing.fragment";
  40174. import "babylonjs/Shaders/postprocess.vertex";
  40175. /**
  40176. * ImageProcessingPostProcess
  40177. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40178. */
  40179. export class ImageProcessingPostProcess extends PostProcess {
  40180. /**
  40181. * Default configuration related to image processing available in the PBR Material.
  40182. */
  40183. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40184. /**
  40185. * Gets the image processing configuration used either in this material.
  40186. */
  40187. /**
  40188. * Sets the Default image processing configuration used either in the this material.
  40189. *
  40190. * If sets to null, the scene one is in use.
  40191. */
  40192. imageProcessingConfiguration: ImageProcessingConfiguration;
  40193. /**
  40194. * Keep track of the image processing observer to allow dispose and replace.
  40195. */
  40196. private _imageProcessingObserver;
  40197. /**
  40198. * Attaches a new image processing configuration to the PBR Material.
  40199. * @param configuration
  40200. */
  40201. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40202. /**
  40203. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40204. */
  40205. /**
  40206. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40207. */
  40208. colorCurves: Nullable<ColorCurves>;
  40209. /**
  40210. * Gets wether the color curves effect is enabled.
  40211. */
  40212. /**
  40213. * Sets wether the color curves effect is enabled.
  40214. */
  40215. colorCurvesEnabled: boolean;
  40216. /**
  40217. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40218. */
  40219. /**
  40220. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40221. */
  40222. colorGradingTexture: Nullable<BaseTexture>;
  40223. /**
  40224. * Gets wether the color grading effect is enabled.
  40225. */
  40226. /**
  40227. * Gets wether the color grading effect is enabled.
  40228. */
  40229. colorGradingEnabled: boolean;
  40230. /**
  40231. * Gets exposure used in the effect.
  40232. */
  40233. /**
  40234. * Sets exposure used in the effect.
  40235. */
  40236. exposure: number;
  40237. /**
  40238. * Gets wether tonemapping is enabled or not.
  40239. */
  40240. /**
  40241. * Sets wether tonemapping is enabled or not
  40242. */
  40243. toneMappingEnabled: boolean;
  40244. /**
  40245. * Gets the type of tone mapping effect.
  40246. */
  40247. /**
  40248. * Sets the type of tone mapping effect.
  40249. */
  40250. toneMappingType: number;
  40251. /**
  40252. * Gets contrast used in the effect.
  40253. */
  40254. /**
  40255. * Sets contrast used in the effect.
  40256. */
  40257. contrast: number;
  40258. /**
  40259. * Gets Vignette stretch size.
  40260. */
  40261. /**
  40262. * Sets Vignette stretch size.
  40263. */
  40264. vignetteStretch: number;
  40265. /**
  40266. * Gets Vignette centre X Offset.
  40267. */
  40268. /**
  40269. * Sets Vignette centre X Offset.
  40270. */
  40271. vignetteCentreX: number;
  40272. /**
  40273. * Gets Vignette centre Y Offset.
  40274. */
  40275. /**
  40276. * Sets Vignette centre Y Offset.
  40277. */
  40278. vignetteCentreY: number;
  40279. /**
  40280. * Gets Vignette weight or intensity of the vignette effect.
  40281. */
  40282. /**
  40283. * Sets Vignette weight or intensity of the vignette effect.
  40284. */
  40285. vignetteWeight: number;
  40286. /**
  40287. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40288. * if vignetteEnabled is set to true.
  40289. */
  40290. /**
  40291. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40292. * if vignetteEnabled is set to true.
  40293. */
  40294. vignetteColor: Color4;
  40295. /**
  40296. * Gets Camera field of view used by the Vignette effect.
  40297. */
  40298. /**
  40299. * Sets Camera field of view used by the Vignette effect.
  40300. */
  40301. vignetteCameraFov: number;
  40302. /**
  40303. * Gets the vignette blend mode allowing different kind of effect.
  40304. */
  40305. /**
  40306. * Sets the vignette blend mode allowing different kind of effect.
  40307. */
  40308. vignetteBlendMode: number;
  40309. /**
  40310. * Gets wether the vignette effect is enabled.
  40311. */
  40312. /**
  40313. * Sets wether the vignette effect is enabled.
  40314. */
  40315. vignetteEnabled: boolean;
  40316. private _fromLinearSpace;
  40317. /**
  40318. * Gets wether the input of the processing is in Gamma or Linear Space.
  40319. */
  40320. /**
  40321. * Sets wether the input of the processing is in Gamma or Linear Space.
  40322. */
  40323. fromLinearSpace: boolean;
  40324. /**
  40325. * Defines cache preventing GC.
  40326. */
  40327. private _defines;
  40328. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40329. /**
  40330. * "ImageProcessingPostProcess"
  40331. * @returns "ImageProcessingPostProcess"
  40332. */
  40333. getClassName(): string;
  40334. protected _updateParameters(): void;
  40335. dispose(camera?: Camera): void;
  40336. }
  40337. }
  40338. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40339. import { Scene } from "babylonjs/scene";
  40340. import { Color3 } from "babylonjs/Maths/math";
  40341. import { Mesh } from "babylonjs/Meshes/mesh";
  40342. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40343. import { Nullable } from "babylonjs/types";
  40344. /**
  40345. * Class containing static functions to help procedurally build meshes
  40346. */
  40347. export class GroundBuilder {
  40348. /**
  40349. * Creates a ground mesh
  40350. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40351. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40353. * @param name defines the name of the mesh
  40354. * @param options defines the options used to create the mesh
  40355. * @param scene defines the hosting scene
  40356. * @returns the ground mesh
  40357. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40358. */
  40359. static CreateGround(name: string, options: {
  40360. width?: number;
  40361. height?: number;
  40362. subdivisions?: number;
  40363. subdivisionsX?: number;
  40364. subdivisionsY?: number;
  40365. updatable?: boolean;
  40366. }, scene: any): Mesh;
  40367. /**
  40368. * Creates a tiled ground mesh
  40369. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40370. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40371. * * 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
  40372. * * 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
  40373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40374. * @param name defines the name of the mesh
  40375. * @param options defines the options used to create the mesh
  40376. * @param scene defines the hosting scene
  40377. * @returns the tiled ground mesh
  40378. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40379. */
  40380. static CreateTiledGround(name: string, options: {
  40381. xmin: number;
  40382. zmin: number;
  40383. xmax: number;
  40384. zmax: number;
  40385. subdivisions?: {
  40386. w: number;
  40387. h: number;
  40388. };
  40389. precision?: {
  40390. w: number;
  40391. h: number;
  40392. };
  40393. updatable?: boolean;
  40394. }, scene?: Nullable<Scene>): Mesh;
  40395. /**
  40396. * Creates a ground mesh from a height map
  40397. * * The parameter `url` sets the URL of the height map image resource.
  40398. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40399. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40400. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40401. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40402. * * 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.
  40403. * * 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).
  40404. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40406. * @param name defines the name of the mesh
  40407. * @param url defines the url to the height map
  40408. * @param options defines the options used to create the mesh
  40409. * @param scene defines the hosting scene
  40410. * @returns the ground mesh
  40411. * @see https://doc.babylonjs.com/babylon101/height_map
  40412. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40413. */
  40414. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40415. width?: number;
  40416. height?: number;
  40417. subdivisions?: number;
  40418. minHeight?: number;
  40419. maxHeight?: number;
  40420. colorFilter?: Color3;
  40421. alphaFilter?: number;
  40422. updatable?: boolean;
  40423. onReady?: (mesh: GroundMesh) => void;
  40424. }, scene?: Nullable<Scene>): GroundMesh;
  40425. }
  40426. }
  40427. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40428. import { Vector4 } from "babylonjs/Maths/math";
  40429. import { Mesh } from "babylonjs/Meshes/mesh";
  40430. /**
  40431. * Class containing static functions to help procedurally build meshes
  40432. */
  40433. export class TorusBuilder {
  40434. /**
  40435. * Creates a torus mesh
  40436. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40437. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40438. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40442. * @param name defines the name of the mesh
  40443. * @param options defines the options used to create the mesh
  40444. * @param scene defines the hosting scene
  40445. * @returns the torus mesh
  40446. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40447. */
  40448. static CreateTorus(name: string, options: {
  40449. diameter?: number;
  40450. thickness?: number;
  40451. tessellation?: number;
  40452. updatable?: boolean;
  40453. sideOrientation?: number;
  40454. frontUVs?: Vector4;
  40455. backUVs?: Vector4;
  40456. }, scene: any): Mesh;
  40457. }
  40458. }
  40459. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40460. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40461. import { Mesh } from "babylonjs/Meshes/mesh";
  40462. /**
  40463. * Class containing static functions to help procedurally build meshes
  40464. */
  40465. export class CylinderBuilder {
  40466. /**
  40467. * Creates a cylinder or a cone mesh
  40468. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40469. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40470. * * 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.
  40471. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40472. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40473. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40474. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40475. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40476. * * 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).
  40477. * * 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
  40478. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40479. * * 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
  40480. * * 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.
  40481. * * If `enclose` is false, a ring surface is one element.
  40482. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40483. * * 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
  40484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40485. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40487. * @param name defines the name of the mesh
  40488. * @param options defines the options used to create the mesh
  40489. * @param scene defines the hosting scene
  40490. * @returns the cylinder mesh
  40491. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40492. */
  40493. static CreateCylinder(name: string, options: {
  40494. height?: number;
  40495. diameterTop?: number;
  40496. diameterBottom?: number;
  40497. diameter?: number;
  40498. tessellation?: number;
  40499. subdivisions?: number;
  40500. arc?: number;
  40501. faceColors?: Color4[];
  40502. faceUV?: Vector4[];
  40503. updatable?: boolean;
  40504. hasRings?: boolean;
  40505. enclose?: boolean;
  40506. sideOrientation?: number;
  40507. frontUVs?: Vector4;
  40508. backUVs?: Vector4;
  40509. }, scene: any): Mesh;
  40510. }
  40511. }
  40512. declare module "babylonjs/Gamepads/gamepadManager" {
  40513. import { Observable } from "babylonjs/Misc/observable";
  40514. import { Nullable } from "babylonjs/types";
  40515. import { Scene } from "babylonjs/scene";
  40516. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40517. /**
  40518. * Manager for handling gamepads
  40519. */
  40520. export class GamepadManager {
  40521. private _scene?;
  40522. private _babylonGamepads;
  40523. private _oneGamepadConnected;
  40524. /** @hidden */
  40525. _isMonitoring: boolean;
  40526. private _gamepadEventSupported;
  40527. private _gamepadSupport;
  40528. /**
  40529. * observable to be triggered when the gamepad controller has been connected
  40530. */
  40531. onGamepadConnectedObservable: Observable<Gamepad>;
  40532. /**
  40533. * observable to be triggered when the gamepad controller has been disconnected
  40534. */
  40535. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40536. private _onGamepadConnectedEvent;
  40537. private _onGamepadDisconnectedEvent;
  40538. /**
  40539. * Initializes the gamepad manager
  40540. * @param _scene BabylonJS scene
  40541. */
  40542. constructor(_scene?: Scene | undefined);
  40543. /**
  40544. * The gamepads in the game pad manager
  40545. */
  40546. readonly gamepads: Gamepad[];
  40547. /**
  40548. * Get the gamepad controllers based on type
  40549. * @param type The type of gamepad controller
  40550. * @returns Nullable gamepad
  40551. */
  40552. getGamepadByType(type?: number): Nullable<Gamepad>;
  40553. /**
  40554. * Disposes the gamepad manager
  40555. */
  40556. dispose(): void;
  40557. private _addNewGamepad;
  40558. private _startMonitoringGamepads;
  40559. private _stopMonitoringGamepads;
  40560. /** @hidden */
  40561. _checkGamepadsStatus(): void;
  40562. private _updateGamepadObjects;
  40563. }
  40564. }
  40565. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40566. import { Nullable } from "babylonjs/types";
  40567. import { Scene } from "babylonjs/scene";
  40568. import { ISceneComponent } from "babylonjs/sceneComponent";
  40569. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40570. module "babylonjs/scene" {
  40571. interface Scene {
  40572. /** @hidden */
  40573. _gamepadManager: Nullable<GamepadManager>;
  40574. /**
  40575. * Gets the gamepad manager associated with the scene
  40576. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40577. */
  40578. gamepadManager: GamepadManager;
  40579. }
  40580. }
  40581. module "babylonjs/Cameras/freeCameraInputsManager" {
  40582. /**
  40583. * Interface representing a free camera inputs manager
  40584. */
  40585. interface FreeCameraInputsManager {
  40586. /**
  40587. * Adds gamepad input support to the FreeCameraInputsManager.
  40588. * @returns the FreeCameraInputsManager
  40589. */
  40590. addGamepad(): FreeCameraInputsManager;
  40591. }
  40592. }
  40593. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40594. /**
  40595. * Interface representing an arc rotate camera inputs manager
  40596. */
  40597. interface ArcRotateCameraInputsManager {
  40598. /**
  40599. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40600. * @returns the camera inputs manager
  40601. */
  40602. addGamepad(): ArcRotateCameraInputsManager;
  40603. }
  40604. }
  40605. /**
  40606. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40607. */
  40608. export class GamepadSystemSceneComponent implements ISceneComponent {
  40609. /**
  40610. * The component name helpfull to identify the component in the list of scene components.
  40611. */
  40612. readonly name: string;
  40613. /**
  40614. * The scene the component belongs to.
  40615. */
  40616. scene: Scene;
  40617. /**
  40618. * Creates a new instance of the component for the given scene
  40619. * @param scene Defines the scene to register the component in
  40620. */
  40621. constructor(scene: Scene);
  40622. /**
  40623. * Registers the component in a given scene
  40624. */
  40625. register(): void;
  40626. /**
  40627. * Rebuilds the elements related to this component in case of
  40628. * context lost for instance.
  40629. */
  40630. rebuild(): void;
  40631. /**
  40632. * Disposes the component and the associated ressources
  40633. */
  40634. dispose(): void;
  40635. private _beforeCameraUpdate;
  40636. }
  40637. }
  40638. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40639. import { Observable } from "babylonjs/Misc/observable";
  40640. import { Nullable } from "babylonjs/types";
  40641. import { Camera } from "babylonjs/Cameras/camera";
  40642. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40643. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40644. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40645. import { Scene } from "babylonjs/scene";
  40646. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40647. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40649. import { Mesh } from "babylonjs/Meshes/mesh";
  40650. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40651. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40652. import "babylonjs/Meshes/Builders/groundBuilder";
  40653. import "babylonjs/Meshes/Builders/torusBuilder";
  40654. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40655. import "babylonjs/Gamepads/gamepadSceneComponent";
  40656. import "babylonjs/Animations/animatable";
  40657. /**
  40658. * Options to modify the vr teleportation behavior.
  40659. */
  40660. export interface VRTeleportationOptions {
  40661. /**
  40662. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40663. */
  40664. floorMeshName?: string;
  40665. /**
  40666. * A list of meshes to be used as the teleportation floor. (default: empty)
  40667. */
  40668. floorMeshes?: Mesh[];
  40669. }
  40670. /**
  40671. * Options to modify the vr experience helper's behavior.
  40672. */
  40673. export interface VRExperienceHelperOptions extends WebVROptions {
  40674. /**
  40675. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40676. */
  40677. createDeviceOrientationCamera?: boolean;
  40678. /**
  40679. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40680. */
  40681. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40682. /**
  40683. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40684. */
  40685. laserToggle?: boolean;
  40686. /**
  40687. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40688. */
  40689. floorMeshes?: Mesh[];
  40690. /**
  40691. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40692. */
  40693. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40694. }
  40695. /**
  40696. * Event containing information after VR has been entered
  40697. */
  40698. export class OnAfterEnteringVRObservableEvent {
  40699. /**
  40700. * If entering vr was successful
  40701. */
  40702. success: boolean;
  40703. }
  40704. /**
  40705. * Helps to quickly add VR support to an existing scene.
  40706. * See http://doc.babylonjs.com/how_to/webvr_helper
  40707. */
  40708. export class VRExperienceHelper {
  40709. /** Options to modify the vr experience helper's behavior. */
  40710. webVROptions: VRExperienceHelperOptions;
  40711. private _scene;
  40712. private _position;
  40713. private _btnVR;
  40714. private _btnVRDisplayed;
  40715. private _webVRsupported;
  40716. private _webVRready;
  40717. private _webVRrequesting;
  40718. private _webVRpresenting;
  40719. private _hasEnteredVR;
  40720. private _fullscreenVRpresenting;
  40721. private _canvas;
  40722. private _webVRCamera;
  40723. private _vrDeviceOrientationCamera;
  40724. private _deviceOrientationCamera;
  40725. private _existingCamera;
  40726. private _onKeyDown;
  40727. private _onVrDisplayPresentChange;
  40728. private _onVRDisplayChanged;
  40729. private _onVRRequestPresentStart;
  40730. private _onVRRequestPresentComplete;
  40731. /**
  40732. * Observable raised right before entering VR.
  40733. */
  40734. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40735. /**
  40736. * Observable raised when entering VR has completed.
  40737. */
  40738. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40739. /**
  40740. * Observable raised when exiting VR.
  40741. */
  40742. onExitingVRObservable: Observable<VRExperienceHelper>;
  40743. /**
  40744. * Observable raised when controller mesh is loaded.
  40745. */
  40746. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40747. /** Return this.onEnteringVRObservable
  40748. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40749. */
  40750. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40751. /** Return this.onExitingVRObservable
  40752. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40753. */
  40754. readonly onExitingVR: Observable<VRExperienceHelper>;
  40755. /** Return this.onControllerMeshLoadedObservable
  40756. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40757. */
  40758. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40759. private _rayLength;
  40760. private _useCustomVRButton;
  40761. private _teleportationRequested;
  40762. private _teleportActive;
  40763. private _floorMeshName;
  40764. private _floorMeshesCollection;
  40765. private _rotationAllowed;
  40766. private _teleportBackwardsVector;
  40767. private _teleportationTarget;
  40768. private _isDefaultTeleportationTarget;
  40769. private _postProcessMove;
  40770. private _teleportationFillColor;
  40771. private _teleportationBorderColor;
  40772. private _rotationAngle;
  40773. private _haloCenter;
  40774. private _cameraGazer;
  40775. private _padSensibilityUp;
  40776. private _padSensibilityDown;
  40777. private _leftController;
  40778. private _rightController;
  40779. /**
  40780. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40781. */
  40782. onNewMeshSelected: Observable<AbstractMesh>;
  40783. /**
  40784. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40785. */
  40786. onNewMeshPicked: Observable<PickingInfo>;
  40787. private _circleEase;
  40788. /**
  40789. * Observable raised before camera teleportation
  40790. */
  40791. onBeforeCameraTeleport: Observable<Vector3>;
  40792. /**
  40793. * Observable raised after camera teleportation
  40794. */
  40795. onAfterCameraTeleport: Observable<Vector3>;
  40796. /**
  40797. * Observable raised when current selected mesh gets unselected
  40798. */
  40799. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40800. private _raySelectionPredicate;
  40801. /**
  40802. * To be optionaly changed by user to define custom ray selection
  40803. */
  40804. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40805. /**
  40806. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40807. */
  40808. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40809. /**
  40810. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40811. */
  40812. teleportationEnabled: boolean;
  40813. private _defaultHeight;
  40814. private _teleportationInitialized;
  40815. private _interactionsEnabled;
  40816. private _interactionsRequested;
  40817. private _displayGaze;
  40818. private _displayLaserPointer;
  40819. /**
  40820. * The mesh used to display where the user is going to teleport.
  40821. */
  40822. /**
  40823. * Sets the mesh to be used to display where the user is going to teleport.
  40824. */
  40825. teleportationTarget: Mesh;
  40826. /**
  40827. * 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
  40828. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40829. * See http://doc.babylonjs.com/resources/baking_transformations
  40830. */
  40831. gazeTrackerMesh: Mesh;
  40832. /**
  40833. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40834. */
  40835. updateGazeTrackerScale: boolean;
  40836. /**
  40837. * If the gaze trackers color should be updated when selecting meshes
  40838. */
  40839. updateGazeTrackerColor: boolean;
  40840. /**
  40841. * The gaze tracking mesh corresponding to the left controller
  40842. */
  40843. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40844. /**
  40845. * The gaze tracking mesh corresponding to the right controller
  40846. */
  40847. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40848. /**
  40849. * If the ray of the gaze should be displayed.
  40850. */
  40851. /**
  40852. * Sets if the ray of the gaze should be displayed.
  40853. */
  40854. displayGaze: boolean;
  40855. /**
  40856. * If the ray of the LaserPointer should be displayed.
  40857. */
  40858. /**
  40859. * Sets if the ray of the LaserPointer should be displayed.
  40860. */
  40861. displayLaserPointer: boolean;
  40862. /**
  40863. * The deviceOrientationCamera used as the camera when not in VR.
  40864. */
  40865. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40866. /**
  40867. * Based on the current WebVR support, returns the current VR camera used.
  40868. */
  40869. readonly currentVRCamera: Nullable<Camera>;
  40870. /**
  40871. * The webVRCamera which is used when in VR.
  40872. */
  40873. readonly webVRCamera: WebVRFreeCamera;
  40874. /**
  40875. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40876. */
  40877. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40878. private readonly _teleportationRequestInitiated;
  40879. /**
  40880. * Defines wether or not Pointer lock should be requested when switching to
  40881. * full screen.
  40882. */
  40883. requestPointerLockOnFullScreen: boolean;
  40884. /**
  40885. * Instantiates a VRExperienceHelper.
  40886. * Helps to quickly add VR support to an existing scene.
  40887. * @param scene The scene the VRExperienceHelper belongs to.
  40888. * @param webVROptions Options to modify the vr experience helper's behavior.
  40889. */
  40890. constructor(scene: Scene,
  40891. /** Options to modify the vr experience helper's behavior. */
  40892. webVROptions?: VRExperienceHelperOptions);
  40893. private _onDefaultMeshLoaded;
  40894. private _onResize;
  40895. private _onFullscreenChange;
  40896. /**
  40897. * Gets a value indicating if we are currently in VR mode.
  40898. */
  40899. readonly isInVRMode: boolean;
  40900. private onVrDisplayPresentChange;
  40901. private onVRDisplayChanged;
  40902. private moveButtonToBottomRight;
  40903. private displayVRButton;
  40904. private updateButtonVisibility;
  40905. private _cachedAngularSensibility;
  40906. /**
  40907. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40908. * Otherwise, will use the fullscreen API.
  40909. */
  40910. enterVR(): void;
  40911. /**
  40912. * Attempt to exit VR, or fullscreen.
  40913. */
  40914. exitVR(): void;
  40915. /**
  40916. * The position of the vr experience helper.
  40917. */
  40918. /**
  40919. * Sets the position of the vr experience helper.
  40920. */
  40921. position: Vector3;
  40922. /**
  40923. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40924. */
  40925. enableInteractions(): void;
  40926. private readonly _noControllerIsActive;
  40927. private beforeRender;
  40928. private _isTeleportationFloor;
  40929. /**
  40930. * Adds a floor mesh to be used for teleportation.
  40931. * @param floorMesh the mesh to be used for teleportation.
  40932. */
  40933. addFloorMesh(floorMesh: Mesh): void;
  40934. /**
  40935. * Removes a floor mesh from being used for teleportation.
  40936. * @param floorMesh the mesh to be removed.
  40937. */
  40938. removeFloorMesh(floorMesh: Mesh): void;
  40939. /**
  40940. * Enables interactions and teleportation using the VR controllers and gaze.
  40941. * @param vrTeleportationOptions options to modify teleportation behavior.
  40942. */
  40943. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40944. private _onNewGamepadConnected;
  40945. private _tryEnableInteractionOnController;
  40946. private _onNewGamepadDisconnected;
  40947. private _enableInteractionOnController;
  40948. private _checkTeleportWithRay;
  40949. private _checkRotate;
  40950. private _checkTeleportBackwards;
  40951. private _enableTeleportationOnController;
  40952. private _createTeleportationCircles;
  40953. private _displayTeleportationTarget;
  40954. private _hideTeleportationTarget;
  40955. private _rotateCamera;
  40956. private _moveTeleportationSelectorTo;
  40957. private _workingVector;
  40958. private _workingQuaternion;
  40959. private _workingMatrix;
  40960. /**
  40961. * Teleports the users feet to the desired location
  40962. * @param location The location where the user's feet should be placed
  40963. */
  40964. teleportCamera(location: Vector3): void;
  40965. private _convertNormalToDirectionOfRay;
  40966. private _castRayAndSelectObject;
  40967. private _notifySelectedMeshUnselected;
  40968. /**
  40969. * Sets the color of the laser ray from the vr controllers.
  40970. * @param color new color for the ray.
  40971. */
  40972. changeLaserColor(color: Color3): void;
  40973. /**
  40974. * Sets the color of the ray from the vr headsets gaze.
  40975. * @param color new color for the ray.
  40976. */
  40977. changeGazeColor(color: Color3): void;
  40978. /**
  40979. * Exits VR and disposes of the vr experience helper
  40980. */
  40981. dispose(): void;
  40982. /**
  40983. * Gets the name of the VRExperienceHelper class
  40984. * @returns "VRExperienceHelper"
  40985. */
  40986. getClassName(): string;
  40987. }
  40988. }
  40989. declare module "babylonjs/Cameras/VR/index" {
  40990. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40991. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40992. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40993. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40994. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40995. export * from "babylonjs/Cameras/VR/webVRCamera";
  40996. }
  40997. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40998. import { Observable } from "babylonjs/Misc/observable";
  40999. import { Nullable } from "babylonjs/types";
  41000. import { IDisposable, Scene } from "babylonjs/scene";
  41001. import { Vector3 } from "babylonjs/Maths/math";
  41002. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41003. import { Ray } from "babylonjs/Culling/ray";
  41004. /**
  41005. * Manages an XRSession
  41006. * @see https://doc.babylonjs.com/how_to/webxr
  41007. */
  41008. export class WebXRSessionManager implements IDisposable {
  41009. private scene;
  41010. /**
  41011. * Fires every time a new xrFrame arrives which can be used to update the camera
  41012. */
  41013. onXRFrameObservable: Observable<any>;
  41014. /**
  41015. * Fires when the xr session is ended either by the device or manually done
  41016. */
  41017. onXRSessionEnded: Observable<any>;
  41018. /** @hidden */
  41019. _xrSession: XRSession;
  41020. /** @hidden */
  41021. _frameOfReference: XRFrameOfReference;
  41022. /** @hidden */
  41023. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41024. /** @hidden */
  41025. _currentXRFrame: Nullable<XRFrame>;
  41026. private _xrNavigator;
  41027. private _xrDevice;
  41028. private _tmpMatrix;
  41029. /**
  41030. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41031. * @param scene The scene which the session should be created for
  41032. */
  41033. constructor(scene: Scene);
  41034. /**
  41035. * Initializes the manager
  41036. * After initialization enterXR can be called to start an XR session
  41037. * @returns Promise which resolves after it is initialized
  41038. */
  41039. initializeAsync(): Promise<void>;
  41040. /**
  41041. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41042. * @param sessionCreationOptions xr options to create the session with
  41043. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41044. * @returns Promise which resolves after it enters XR
  41045. */
  41046. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41047. /**
  41048. * Stops the xrSession and restores the renderloop
  41049. * @returns Promise which resolves after it exits XR
  41050. */
  41051. exitXRAsync(): Promise<void>;
  41052. /**
  41053. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41054. * @param ray ray to cast into the environment
  41055. * @returns Promise which resolves with a collision point in the environment if it exists
  41056. */
  41057. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41058. /**
  41059. * Checks if a session would be supported for the creation options specified
  41060. * @param options creation options to check if they are supported
  41061. * @returns true if supported
  41062. */
  41063. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41064. /**
  41065. * @hidden
  41066. * Converts the render layer of xrSession to a render target
  41067. * @param session session to create render target for
  41068. * @param scene scene the new render target should be created for
  41069. */
  41070. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41071. /**
  41072. * Disposes of the session manager
  41073. */
  41074. dispose(): void;
  41075. }
  41076. }
  41077. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41078. import { Scene } from "babylonjs/scene";
  41079. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41080. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41081. /**
  41082. * WebXR Camera which holds the views for the xrSession
  41083. * @see https://doc.babylonjs.com/how_to/webxr
  41084. */
  41085. export class WebXRCamera extends FreeCamera {
  41086. private static _TmpMatrix;
  41087. /**
  41088. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41089. * @param name the name of the camera
  41090. * @param scene the scene to add the camera to
  41091. */
  41092. constructor(name: string, scene: Scene);
  41093. private _updateNumberOfRigCameras;
  41094. /** @hidden */
  41095. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41096. /**
  41097. * Updates the cameras position from the current pose information of the XR session
  41098. * @param xrSessionManager the session containing pose information
  41099. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41100. */
  41101. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41102. }
  41103. }
  41104. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41105. import { Nullable } from "babylonjs/types";
  41106. import { Observable } from "babylonjs/Misc/observable";
  41107. import { IDisposable, Scene } from "babylonjs/scene";
  41108. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41110. import { Ray } from "babylonjs/Culling/ray";
  41111. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41112. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41113. /**
  41114. * States of the webXR experience
  41115. */
  41116. export enum WebXRState {
  41117. /**
  41118. * Transitioning to being in XR mode
  41119. */
  41120. ENTERING_XR = 0,
  41121. /**
  41122. * Transitioning to non XR mode
  41123. */
  41124. EXITING_XR = 1,
  41125. /**
  41126. * In XR mode and presenting
  41127. */
  41128. IN_XR = 2,
  41129. /**
  41130. * Not entered XR mode
  41131. */
  41132. NOT_IN_XR = 3
  41133. }
  41134. /**
  41135. * Helper class used to enable XR
  41136. * @see https://doc.babylonjs.com/how_to/webxr
  41137. */
  41138. export class WebXRExperienceHelper implements IDisposable {
  41139. private scene;
  41140. /**
  41141. * 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
  41142. */
  41143. container: AbstractMesh;
  41144. /**
  41145. * Camera used to render xr content
  41146. */
  41147. camera: WebXRCamera;
  41148. /**
  41149. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41150. */
  41151. state: WebXRState;
  41152. private _setState;
  41153. private static _TmpVector;
  41154. /**
  41155. * Fires when the state of the experience helper has changed
  41156. */
  41157. onStateChangedObservable: Observable<WebXRState>;
  41158. /** @hidden */
  41159. _sessionManager: WebXRSessionManager;
  41160. private _nonVRCamera;
  41161. private _originalSceneAutoClear;
  41162. private _supported;
  41163. /**
  41164. * Creates the experience helper
  41165. * @param scene the scene to attach the experience helper to
  41166. * @returns a promise for the experience helper
  41167. */
  41168. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41169. /**
  41170. * Creates a WebXRExperienceHelper
  41171. * @param scene The scene the helper should be created in
  41172. */
  41173. private constructor();
  41174. /**
  41175. * Exits XR mode and returns the scene to its original state
  41176. * @returns promise that resolves after xr mode has exited
  41177. */
  41178. exitXRAsync(): Promise<void>;
  41179. /**
  41180. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41181. * @param sessionCreationOptions options for the XR session
  41182. * @param frameOfReference frame of reference of the XR session
  41183. * @returns promise that resolves after xr mode has entered
  41184. */
  41185. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41186. /**
  41187. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41188. * @param ray ray to cast into the environment
  41189. * @returns Promise which resolves with a collision point in the environment if it exists
  41190. */
  41191. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41192. /**
  41193. * Updates the global position of the camera by moving the camera's container
  41194. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41195. * @param position The desired global position of the camera
  41196. */
  41197. setPositionOfCameraUsingContainer(position: Vector3): void;
  41198. /**
  41199. * Rotates the xr camera by rotating the camera's container around the camera's position
  41200. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41201. * @param rotation the desired quaternion rotation to apply to the camera
  41202. */
  41203. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41204. /**
  41205. * Checks if the creation options are supported by the xr session
  41206. * @param options creation options
  41207. * @returns true if supported
  41208. */
  41209. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41210. /**
  41211. * Disposes of the experience helper
  41212. */
  41213. dispose(): void;
  41214. }
  41215. }
  41216. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41217. import { Nullable } from "babylonjs/types";
  41218. import { Observable } from "babylonjs/Misc/observable";
  41219. import { IDisposable, Scene } from "babylonjs/scene";
  41220. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41221. /**
  41222. * Button which can be used to enter a different mode of XR
  41223. */
  41224. export class WebXREnterExitUIButton {
  41225. /** button element */
  41226. element: HTMLElement;
  41227. /** XR initialization options for the button */
  41228. initializationOptions: XRSessionCreationOptions;
  41229. /**
  41230. * Creates a WebXREnterExitUIButton
  41231. * @param element button element
  41232. * @param initializationOptions XR initialization options for the button
  41233. */
  41234. constructor(
  41235. /** button element */
  41236. element: HTMLElement,
  41237. /** XR initialization options for the button */
  41238. initializationOptions: XRSessionCreationOptions);
  41239. /**
  41240. * Overwritable function which can be used to update the button's visuals when the state changes
  41241. * @param activeButton the current active button in the UI
  41242. */
  41243. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41244. }
  41245. /**
  41246. * Options to create the webXR UI
  41247. */
  41248. export class WebXREnterExitUIOptions {
  41249. /**
  41250. * Context to enter xr with
  41251. */
  41252. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41253. /**
  41254. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41255. */
  41256. customButtons?: Array<WebXREnterExitUIButton>;
  41257. }
  41258. /**
  41259. * UI to allow the user to enter/exit XR mode
  41260. */
  41261. export class WebXREnterExitUI implements IDisposable {
  41262. private scene;
  41263. private _overlay;
  41264. private _buttons;
  41265. private _activeButton;
  41266. /**
  41267. * Fired every time the active button is changed.
  41268. *
  41269. * When xr is entered via a button that launches xr that button will be the callback parameter
  41270. *
  41271. * When exiting xr the callback parameter will be null)
  41272. */
  41273. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41274. /**
  41275. * Creates UI to allow the user to enter/exit XR mode
  41276. * @param scene the scene to add the ui to
  41277. * @param helper the xr experience helper to enter/exit xr with
  41278. * @param options options to configure the UI
  41279. * @returns the created ui
  41280. */
  41281. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41282. private constructor();
  41283. private _updateButtons;
  41284. /**
  41285. * Disposes of the object
  41286. */
  41287. dispose(): void;
  41288. }
  41289. }
  41290. declare module "babylonjs/Cameras/XR/webXRInput" {
  41291. import { IDisposable, Scene } from "babylonjs/scene";
  41292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41293. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41294. /**
  41295. * Represents an XR input
  41296. */
  41297. export class WebXRController {
  41298. /**
  41299. * 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
  41300. */
  41301. grip?: AbstractMesh;
  41302. /**
  41303. * Pointer which can be used to select objects or attach a visible laser to
  41304. */
  41305. pointer: AbstractMesh;
  41306. /**
  41307. * Creates the controller
  41308. * @see https://doc.babylonjs.com/how_to/webxr
  41309. * @param scene the scene which the controller should be associated to
  41310. */
  41311. constructor(scene: Scene);
  41312. /**
  41313. * Disposes of the object
  41314. */
  41315. dispose(): void;
  41316. }
  41317. /**
  41318. * XR input used to track XR inputs such as controllers/rays
  41319. */
  41320. export class WebXRInput implements IDisposable {
  41321. private helper;
  41322. /**
  41323. * XR controllers being tracked
  41324. */
  41325. controllers: Array<WebXRController>;
  41326. private _tmpMatrix;
  41327. private _frameObserver;
  41328. /**
  41329. * Initializes the WebXRInput
  41330. * @param helper experience helper which the input should be created for
  41331. */
  41332. constructor(helper: WebXRExperienceHelper);
  41333. /**
  41334. * Disposes of the object
  41335. */
  41336. dispose(): void;
  41337. }
  41338. }
  41339. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41340. import { Nullable } from "babylonjs/types";
  41341. import { IDisposable } from "babylonjs/scene";
  41342. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41343. /**
  41344. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41345. */
  41346. export class WebXRManagedOutputCanvas implements IDisposable {
  41347. private _canvas;
  41348. /**
  41349. * xrpresent context of the canvas which can be used to display/mirror xr content
  41350. */
  41351. canvasContext: Nullable<WebGLRenderingContext>;
  41352. /**
  41353. * Initializes the canvas to be added/removed upon entering/exiting xr
  41354. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41355. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41356. */
  41357. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41358. /**
  41359. * Disposes of the object
  41360. */
  41361. dispose(): void;
  41362. private _setManagedOutputCanvas;
  41363. private _addCanvas;
  41364. private _removeCanvas;
  41365. }
  41366. }
  41367. declare module "babylonjs/Cameras/XR/index" {
  41368. export * from "babylonjs/Cameras/XR/webXRCamera";
  41369. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41370. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41371. export * from "babylonjs/Cameras/XR/webXRInput";
  41372. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41373. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41374. }
  41375. declare module "babylonjs/Cameras/RigModes/index" {
  41376. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41377. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41378. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41379. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41380. }
  41381. declare module "babylonjs/Cameras/index" {
  41382. export * from "babylonjs/Cameras/Inputs/index";
  41383. export * from "babylonjs/Cameras/cameraInputsManager";
  41384. export * from "babylonjs/Cameras/camera";
  41385. export * from "babylonjs/Cameras/targetCamera";
  41386. export * from "babylonjs/Cameras/freeCamera";
  41387. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41388. export * from "babylonjs/Cameras/touchCamera";
  41389. export * from "babylonjs/Cameras/arcRotateCamera";
  41390. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41391. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41392. export * from "babylonjs/Cameras/flyCamera";
  41393. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41394. export * from "babylonjs/Cameras/followCamera";
  41395. export * from "babylonjs/Cameras/gamepadCamera";
  41396. export * from "babylonjs/Cameras/Stereoscopic/index";
  41397. export * from "babylonjs/Cameras/universalCamera";
  41398. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41399. export * from "babylonjs/Cameras/VR/index";
  41400. export * from "babylonjs/Cameras/XR/index";
  41401. export * from "babylonjs/Cameras/RigModes/index";
  41402. }
  41403. declare module "babylonjs/Collisions/index" {
  41404. export * from "babylonjs/Collisions/collider";
  41405. export * from "babylonjs/Collisions/collisionCoordinator";
  41406. export * from "babylonjs/Collisions/pickingInfo";
  41407. export * from "babylonjs/Collisions/intersectionInfo";
  41408. }
  41409. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41410. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41411. import { Vector3, Plane } from "babylonjs/Maths/math";
  41412. import { Ray } from "babylonjs/Culling/ray";
  41413. /**
  41414. * Contains an array of blocks representing the octree
  41415. */
  41416. export interface IOctreeContainer<T> {
  41417. /**
  41418. * Blocks within the octree
  41419. */
  41420. blocks: Array<OctreeBlock<T>>;
  41421. }
  41422. /**
  41423. * Class used to store a cell in an octree
  41424. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41425. */
  41426. export class OctreeBlock<T> {
  41427. /**
  41428. * Gets the content of the current block
  41429. */
  41430. entries: T[];
  41431. /**
  41432. * Gets the list of block children
  41433. */
  41434. blocks: Array<OctreeBlock<T>>;
  41435. private _depth;
  41436. private _maxDepth;
  41437. private _capacity;
  41438. private _minPoint;
  41439. private _maxPoint;
  41440. private _boundingVectors;
  41441. private _creationFunc;
  41442. /**
  41443. * Creates a new block
  41444. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41445. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41446. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41447. * @param depth defines the current depth of this block in the octree
  41448. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41449. * @param creationFunc defines a callback to call when an element is added to the block
  41450. */
  41451. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41452. /**
  41453. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41454. */
  41455. readonly capacity: number;
  41456. /**
  41457. * Gets the minimum vector (in world space) of the block's bounding box
  41458. */
  41459. readonly minPoint: Vector3;
  41460. /**
  41461. * Gets the maximum vector (in world space) of the block's bounding box
  41462. */
  41463. readonly maxPoint: Vector3;
  41464. /**
  41465. * Add a new element to this block
  41466. * @param entry defines the element to add
  41467. */
  41468. addEntry(entry: T): void;
  41469. /**
  41470. * Remove an element from this block
  41471. * @param entry defines the element to remove
  41472. */
  41473. removeEntry(entry: T): void;
  41474. /**
  41475. * Add an array of elements to this block
  41476. * @param entries defines the array of elements to add
  41477. */
  41478. addEntries(entries: T[]): void;
  41479. /**
  41480. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41481. * @param frustumPlanes defines the frustum planes to test
  41482. * @param selection defines the array to store current content if selection is positive
  41483. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41484. */
  41485. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41486. /**
  41487. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41488. * @param sphereCenter defines the bounding sphere center
  41489. * @param sphereRadius defines the bounding sphere radius
  41490. * @param selection defines the array to store current content if selection is positive
  41491. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41492. */
  41493. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41494. /**
  41495. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41496. * @param ray defines the ray to test with
  41497. * @param selection defines the array to store current content if selection is positive
  41498. */
  41499. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41500. /**
  41501. * Subdivide the content into child blocks (this block will then be empty)
  41502. */
  41503. createInnerBlocks(): void;
  41504. /**
  41505. * @hidden
  41506. */
  41507. 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;
  41508. }
  41509. }
  41510. declare module "babylonjs/Culling/Octrees/octree" {
  41511. import { SmartArray } from "babylonjs/Misc/smartArray";
  41512. import { Vector3, Plane } from "babylonjs/Maths/math";
  41513. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41515. import { Ray } from "babylonjs/Culling/ray";
  41516. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41517. /**
  41518. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41519. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41520. */
  41521. export class Octree<T> {
  41522. /** 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.) */
  41523. maxDepth: number;
  41524. /**
  41525. * Blocks within the octree containing objects
  41526. */
  41527. blocks: Array<OctreeBlock<T>>;
  41528. /**
  41529. * Content stored in the octree
  41530. */
  41531. dynamicContent: T[];
  41532. private _maxBlockCapacity;
  41533. private _selectionContent;
  41534. private _creationFunc;
  41535. /**
  41536. * Creates a octree
  41537. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41538. * @param creationFunc function to be used to instatiate the octree
  41539. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41540. * @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.)
  41541. */
  41542. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41543. /** 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.) */
  41544. maxDepth?: number);
  41545. /**
  41546. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41547. * @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);
  41548. * @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);
  41549. * @param entries meshes to be added to the octree blocks
  41550. */
  41551. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41552. /**
  41553. * Adds a mesh to the octree
  41554. * @param entry Mesh to add to the octree
  41555. */
  41556. addMesh(entry: T): void;
  41557. /**
  41558. * Remove an element from the octree
  41559. * @param entry defines the element to remove
  41560. */
  41561. removeMesh(entry: T): void;
  41562. /**
  41563. * Selects an array of meshes within the frustum
  41564. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41565. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41566. * @returns array of meshes within the frustum
  41567. */
  41568. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41569. /**
  41570. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41571. * @param sphereCenter defines the bounding sphere center
  41572. * @param sphereRadius defines the bounding sphere radius
  41573. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41574. * @returns an array of objects that intersect the sphere
  41575. */
  41576. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41577. /**
  41578. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41579. * @param ray defines the ray to test with
  41580. * @returns array of intersected objects
  41581. */
  41582. intersectsRay(ray: Ray): SmartArray<T>;
  41583. /**
  41584. * Adds a mesh into the octree block if it intersects the block
  41585. */
  41586. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41587. /**
  41588. * Adds a submesh into the octree block if it intersects the block
  41589. */
  41590. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41591. }
  41592. }
  41593. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41594. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41595. import { Scene } from "babylonjs/scene";
  41596. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41598. import { Ray } from "babylonjs/Culling/ray";
  41599. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41600. import { Collider } from "babylonjs/Collisions/collider";
  41601. module "babylonjs/scene" {
  41602. interface Scene {
  41603. /**
  41604. * @hidden
  41605. * Backing Filed
  41606. */
  41607. _selectionOctree: Octree<AbstractMesh>;
  41608. /**
  41609. * Gets the octree used to boost mesh selection (picking)
  41610. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41611. */
  41612. selectionOctree: Octree<AbstractMesh>;
  41613. /**
  41614. * Creates or updates the octree used to boost selection (picking)
  41615. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41616. * @param maxCapacity defines the maximum capacity per leaf
  41617. * @param maxDepth defines the maximum depth of the octree
  41618. * @returns an octree of AbstractMesh
  41619. */
  41620. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41621. }
  41622. }
  41623. module "babylonjs/Meshes/abstractMesh" {
  41624. interface AbstractMesh {
  41625. /**
  41626. * @hidden
  41627. * Backing Field
  41628. */
  41629. _submeshesOctree: Octree<SubMesh>;
  41630. /**
  41631. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41632. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41633. * @param maxCapacity defines the maximum size of each block (64 by default)
  41634. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41635. * @returns the new octree
  41636. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41638. */
  41639. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41640. }
  41641. }
  41642. /**
  41643. * Defines the octree scene component responsible to manage any octrees
  41644. * in a given scene.
  41645. */
  41646. export class OctreeSceneComponent {
  41647. /**
  41648. * The component name helpfull to identify the component in the list of scene components.
  41649. */
  41650. readonly name: string;
  41651. /**
  41652. * The scene the component belongs to.
  41653. */
  41654. scene: Scene;
  41655. /**
  41656. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41657. */
  41658. readonly checksIsEnabled: boolean;
  41659. /**
  41660. * Creates a new instance of the component for the given scene
  41661. * @param scene Defines the scene to register the component in
  41662. */
  41663. constructor(scene: Scene);
  41664. /**
  41665. * Registers the component in a given scene
  41666. */
  41667. register(): void;
  41668. /**
  41669. * Return the list of active meshes
  41670. * @returns the list of active meshes
  41671. */
  41672. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41673. /**
  41674. * Return the list of active sub meshes
  41675. * @param mesh The mesh to get the candidates sub meshes from
  41676. * @returns the list of active sub meshes
  41677. */
  41678. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41679. private _tempRay;
  41680. /**
  41681. * Return the list of sub meshes intersecting with a given local ray
  41682. * @param mesh defines the mesh to find the submesh for
  41683. * @param localRay defines the ray in local space
  41684. * @returns the list of intersecting sub meshes
  41685. */
  41686. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41687. /**
  41688. * Return the list of sub meshes colliding with a collider
  41689. * @param mesh defines the mesh to find the submesh for
  41690. * @param collider defines the collider to evaluate the collision against
  41691. * @returns the list of colliding sub meshes
  41692. */
  41693. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41694. /**
  41695. * Rebuilds the elements related to this component in case of
  41696. * context lost for instance.
  41697. */
  41698. rebuild(): void;
  41699. /**
  41700. * Disposes the component and the associated ressources.
  41701. */
  41702. dispose(): void;
  41703. }
  41704. }
  41705. declare module "babylonjs/Culling/Octrees/index" {
  41706. export * from "babylonjs/Culling/Octrees/octree";
  41707. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41708. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41709. }
  41710. declare module "babylonjs/Culling/index" {
  41711. export * from "babylonjs/Culling/boundingBox";
  41712. export * from "babylonjs/Culling/boundingInfo";
  41713. export * from "babylonjs/Culling/boundingSphere";
  41714. export * from "babylonjs/Culling/Octrees/index";
  41715. export * from "babylonjs/Culling/ray";
  41716. }
  41717. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41718. import { IDisposable, Scene } from "babylonjs/scene";
  41719. import { Nullable } from "babylonjs/types";
  41720. import { Observable } from "babylonjs/Misc/observable";
  41721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41722. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  41723. /**
  41724. * Renders a layer on top of an existing scene
  41725. */
  41726. export class UtilityLayerRenderer implements IDisposable {
  41727. /** the original scene that will be rendered on top of */
  41728. originalScene: Scene;
  41729. private _pointerCaptures;
  41730. private _lastPointerEvents;
  41731. private static _DefaultUtilityLayer;
  41732. private static _DefaultKeepDepthUtilityLayer;
  41733. private _sharedGizmoLight;
  41734. /**
  41735. * @hidden
  41736. * Light which used by gizmos to get light shading
  41737. */
  41738. _getSharedGizmoLight(): HemisphericLight;
  41739. /**
  41740. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41741. */
  41742. pickUtilitySceneFirst: boolean;
  41743. /**
  41744. * 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)
  41745. */
  41746. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41747. /**
  41748. * 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)
  41749. */
  41750. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41751. /**
  41752. * The scene that is rendered on top of the original scene
  41753. */
  41754. utilityLayerScene: Scene;
  41755. /**
  41756. * If the utility layer should automatically be rendered on top of existing scene
  41757. */
  41758. shouldRender: boolean;
  41759. /**
  41760. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41761. */
  41762. onlyCheckPointerDownEvents: boolean;
  41763. /**
  41764. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41765. */
  41766. processAllEvents: boolean;
  41767. /**
  41768. * Observable raised when the pointer move from the utility layer scene to the main scene
  41769. */
  41770. onPointerOutObservable: Observable<number>;
  41771. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41772. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41773. private _afterRenderObserver;
  41774. private _sceneDisposeObserver;
  41775. private _originalPointerObserver;
  41776. /**
  41777. * Instantiates a UtilityLayerRenderer
  41778. * @param originalScene the original scene that will be rendered on top of
  41779. * @param handleEvents boolean indicating if the utility layer should handle events
  41780. */
  41781. constructor(
  41782. /** the original scene that will be rendered on top of */
  41783. originalScene: Scene, handleEvents?: boolean);
  41784. private _notifyObservers;
  41785. /**
  41786. * Renders the utility layers scene on top of the original scene
  41787. */
  41788. render(): void;
  41789. /**
  41790. * Disposes of the renderer
  41791. */
  41792. dispose(): void;
  41793. private _updateCamera;
  41794. }
  41795. }
  41796. declare module "babylonjs/Gizmos/gizmo" {
  41797. import { Nullable } from "babylonjs/types";
  41798. import { IDisposable } from "babylonjs/scene";
  41799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41800. import { Mesh } from "babylonjs/Meshes/mesh";
  41801. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41802. /**
  41803. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41804. */
  41805. export class Gizmo implements IDisposable {
  41806. /** The utility layer the gizmo will be added to */
  41807. gizmoLayer: UtilityLayerRenderer;
  41808. /**
  41809. * The root mesh of the gizmo
  41810. */
  41811. _rootMesh: Mesh;
  41812. private _attachedMesh;
  41813. /**
  41814. * Ratio for the scale of the gizmo (Default: 1)
  41815. */
  41816. scaleRatio: number;
  41817. private _tmpMatrix;
  41818. /**
  41819. * If a custom mesh has been set (Default: false)
  41820. */
  41821. protected _customMeshSet: boolean;
  41822. /**
  41823. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41824. * * When set, interactions will be enabled
  41825. */
  41826. attachedMesh: Nullable<AbstractMesh>;
  41827. /**
  41828. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41829. * @param mesh The mesh to replace the default mesh of the gizmo
  41830. */
  41831. setCustomMesh(mesh: Mesh): void;
  41832. /**
  41833. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41834. */
  41835. updateGizmoRotationToMatchAttachedMesh: boolean;
  41836. /**
  41837. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41838. */
  41839. updateGizmoPositionToMatchAttachedMesh: boolean;
  41840. /**
  41841. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41842. */
  41843. protected _updateScale: boolean;
  41844. protected _interactionsEnabled: boolean;
  41845. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41846. private _beforeRenderObserver;
  41847. /**
  41848. * Creates a gizmo
  41849. * @param gizmoLayer The utility layer the gizmo will be added to
  41850. */
  41851. constructor(
  41852. /** The utility layer the gizmo will be added to */
  41853. gizmoLayer?: UtilityLayerRenderer);
  41854. private _tempVector;
  41855. /**
  41856. * @hidden
  41857. * Updates the gizmo to match the attached mesh's position/rotation
  41858. */
  41859. protected _update(): void;
  41860. /**
  41861. * Disposes of the gizmo
  41862. */
  41863. dispose(): void;
  41864. }
  41865. }
  41866. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41867. import { Observable } from "babylonjs/Misc/observable";
  41868. import { Nullable } from "babylonjs/types";
  41869. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41870. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41872. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41873. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41874. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41875. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41876. import { Scene } from "babylonjs/scene";
  41877. /**
  41878. * Single axis drag gizmo
  41879. */
  41880. export class AxisDragGizmo extends Gizmo {
  41881. /**
  41882. * Drag behavior responsible for the gizmos dragging interactions
  41883. */
  41884. dragBehavior: PointerDragBehavior;
  41885. private _pointerObserver;
  41886. /**
  41887. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41888. */
  41889. snapDistance: number;
  41890. /**
  41891. * Event that fires each time the gizmo snaps to a new location.
  41892. * * snapDistance is the the change in distance
  41893. */
  41894. onSnapObservable: Observable<{
  41895. snapDistance: number;
  41896. }>;
  41897. /** @hidden */
  41898. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41899. /** @hidden */
  41900. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41901. /**
  41902. * Creates an AxisDragGizmo
  41903. * @param gizmoLayer The utility layer the gizmo will be added to
  41904. * @param dragAxis The axis which the gizmo will be able to drag on
  41905. * @param color The color of the gizmo
  41906. */
  41907. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41908. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41909. /**
  41910. * Disposes of the gizmo
  41911. */
  41912. dispose(): void;
  41913. }
  41914. }
  41915. declare module "babylonjs/Debug/axesViewer" {
  41916. import { Vector3 } from "babylonjs/Maths/math";
  41917. import { Nullable } from "babylonjs/types";
  41918. import { Scene } from "babylonjs/scene";
  41919. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41920. /**
  41921. * The Axes viewer will show 3 axes in a specific point in space
  41922. */
  41923. export class AxesViewer {
  41924. private _xAxis;
  41925. private _yAxis;
  41926. private _zAxis;
  41927. private _scaleLinesFactor;
  41928. private _instanced;
  41929. /**
  41930. * Gets the hosting scene
  41931. */
  41932. scene: Scene;
  41933. /**
  41934. * Gets or sets a number used to scale line length
  41935. */
  41936. scaleLines: number;
  41937. /** Gets the node hierarchy used to render x-axis */
  41938. readonly xAxis: TransformNode;
  41939. /** Gets the node hierarchy used to render y-axis */
  41940. readonly yAxis: TransformNode;
  41941. /** Gets the node hierarchy used to render z-axis */
  41942. readonly zAxis: TransformNode;
  41943. /**
  41944. * Creates a new AxesViewer
  41945. * @param scene defines the hosting scene
  41946. * @param scaleLines defines a number used to scale line length (1 by default)
  41947. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41948. * @param xAxis defines the node hierarchy used to render the x-axis
  41949. * @param yAxis defines the node hierarchy used to render the y-axis
  41950. * @param zAxis defines the node hierarchy used to render the z-axis
  41951. */
  41952. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41953. /**
  41954. * Force the viewer to update
  41955. * @param position defines the position of the viewer
  41956. * @param xaxis defines the x axis of the viewer
  41957. * @param yaxis defines the y axis of the viewer
  41958. * @param zaxis defines the z axis of the viewer
  41959. */
  41960. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41961. /**
  41962. * Creates an instance of this axes viewer.
  41963. * @returns a new axes viewer with instanced meshes
  41964. */
  41965. createInstance(): AxesViewer;
  41966. /** Releases resources */
  41967. dispose(): void;
  41968. private static _SetRenderingGroupId;
  41969. }
  41970. }
  41971. declare module "babylonjs/Debug/boneAxesViewer" {
  41972. import { Nullable } from "babylonjs/types";
  41973. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41974. import { Vector3 } from "babylonjs/Maths/math";
  41975. import { Mesh } from "babylonjs/Meshes/mesh";
  41976. import { Bone } from "babylonjs/Bones/bone";
  41977. import { Scene } from "babylonjs/scene";
  41978. /**
  41979. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41980. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41981. */
  41982. export class BoneAxesViewer extends AxesViewer {
  41983. /**
  41984. * Gets or sets the target mesh where to display the axes viewer
  41985. */
  41986. mesh: Nullable<Mesh>;
  41987. /**
  41988. * Gets or sets the target bone where to display the axes viewer
  41989. */
  41990. bone: Nullable<Bone>;
  41991. /** Gets current position */
  41992. pos: Vector3;
  41993. /** Gets direction of X axis */
  41994. xaxis: Vector3;
  41995. /** Gets direction of Y axis */
  41996. yaxis: Vector3;
  41997. /** Gets direction of Z axis */
  41998. zaxis: Vector3;
  41999. /**
  42000. * Creates a new BoneAxesViewer
  42001. * @param scene defines the hosting scene
  42002. * @param bone defines the target bone
  42003. * @param mesh defines the target mesh
  42004. * @param scaleLines defines a scaling factor for line length (1 by default)
  42005. */
  42006. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42007. /**
  42008. * Force the viewer to update
  42009. */
  42010. update(): void;
  42011. /** Releases resources */
  42012. dispose(): void;
  42013. }
  42014. }
  42015. declare module "babylonjs/Debug/debugLayer" {
  42016. import { Observable } from "babylonjs/Misc/observable";
  42017. import { Scene } from "babylonjs/scene";
  42018. /**
  42019. * Interface used to define scene explorer extensibility option
  42020. */
  42021. export interface IExplorerExtensibilityOption {
  42022. /**
  42023. * Define the option label
  42024. */
  42025. label: string;
  42026. /**
  42027. * Defines the action to execute on click
  42028. */
  42029. action: (entity: any) => void;
  42030. }
  42031. /**
  42032. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42033. */
  42034. export interface IExplorerExtensibilityGroup {
  42035. /**
  42036. * Defines a predicate to test if a given type mut be extended
  42037. */
  42038. predicate: (entity: any) => boolean;
  42039. /**
  42040. * Gets the list of options added to a type
  42041. */
  42042. entries: IExplorerExtensibilityOption[];
  42043. }
  42044. /**
  42045. * Interface used to define the options to use to create the Inspector
  42046. */
  42047. export interface IInspectorOptions {
  42048. /**
  42049. * Display in overlay mode (default: false)
  42050. */
  42051. overlay?: boolean;
  42052. /**
  42053. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42054. */
  42055. globalRoot?: HTMLElement;
  42056. /**
  42057. * Display the Scene explorer
  42058. */
  42059. showExplorer?: boolean;
  42060. /**
  42061. * Display the property inspector
  42062. */
  42063. showInspector?: boolean;
  42064. /**
  42065. * Display in embed mode (both panes on the right)
  42066. */
  42067. embedMode?: boolean;
  42068. /**
  42069. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42070. */
  42071. handleResize?: boolean;
  42072. /**
  42073. * Allow the panes to popup (default: true)
  42074. */
  42075. enablePopup?: boolean;
  42076. /**
  42077. * Allow the panes to be closed by users (default: true)
  42078. */
  42079. enableClose?: boolean;
  42080. /**
  42081. * Optional list of extensibility entries
  42082. */
  42083. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42084. /**
  42085. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42086. */
  42087. inspectorURL?: string;
  42088. }
  42089. module "babylonjs/scene" {
  42090. interface Scene {
  42091. /**
  42092. * @hidden
  42093. * Backing field
  42094. */
  42095. _debugLayer: DebugLayer;
  42096. /**
  42097. * Gets the debug layer (aka Inspector) associated with the scene
  42098. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42099. */
  42100. debugLayer: DebugLayer;
  42101. }
  42102. }
  42103. /**
  42104. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42105. * what is happening in your scene
  42106. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42107. */
  42108. export class DebugLayer {
  42109. /**
  42110. * Define the url to get the inspector script from.
  42111. * By default it uses the babylonjs CDN.
  42112. * @ignoreNaming
  42113. */
  42114. static InspectorURL: string;
  42115. private _scene;
  42116. private BJSINSPECTOR;
  42117. /**
  42118. * Observable triggered when a property is changed through the inspector.
  42119. */
  42120. onPropertyChangedObservable: Observable<{
  42121. object: any;
  42122. property: string;
  42123. value: any;
  42124. initialValue: any;
  42125. }>;
  42126. /**
  42127. * Instantiates a new debug layer.
  42128. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42129. * what is happening in your scene
  42130. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42131. * @param scene Defines the scene to inspect
  42132. */
  42133. constructor(scene: Scene);
  42134. /** Creates the inspector window. */
  42135. private _createInspector;
  42136. /**
  42137. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42138. * @param entity defines the entity to select
  42139. * @param lineContainerTitle defines the specific block to highlight
  42140. */
  42141. select(entity: any, lineContainerTitle?: string): void;
  42142. /** Get the inspector from bundle or global */
  42143. private _getGlobalInspector;
  42144. /**
  42145. * Get if the inspector is visible or not.
  42146. * @returns true if visible otherwise, false
  42147. */
  42148. isVisible(): boolean;
  42149. /**
  42150. * Hide the inspector and close its window.
  42151. */
  42152. hide(): void;
  42153. /**
  42154. * Launch the debugLayer.
  42155. * @param config Define the configuration of the inspector
  42156. * @return a promise fulfilled when the debug layer is visible
  42157. */
  42158. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42159. }
  42160. }
  42161. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42162. import { Nullable } from "babylonjs/types";
  42163. import { Scene } from "babylonjs/scene";
  42164. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42165. import { Mesh } from "babylonjs/Meshes/mesh";
  42166. /**
  42167. * Class containing static functions to help procedurally build meshes
  42168. */
  42169. export class BoxBuilder {
  42170. /**
  42171. * Creates a box mesh
  42172. * * The parameter `size` sets the size (float) of each box side (default 1)
  42173. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42174. * * 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)
  42175. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42179. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42180. * @param name defines the name of the mesh
  42181. * @param options defines the options used to create the mesh
  42182. * @param scene defines the hosting scene
  42183. * @returns the box mesh
  42184. */
  42185. static CreateBox(name: string, options: {
  42186. size?: number;
  42187. width?: number;
  42188. height?: number;
  42189. depth?: number;
  42190. faceUV?: Vector4[];
  42191. faceColors?: Color4[];
  42192. sideOrientation?: number;
  42193. frontUVs?: Vector4;
  42194. backUVs?: Vector4;
  42195. updatable?: boolean;
  42196. }, scene?: Nullable<Scene>): Mesh;
  42197. }
  42198. }
  42199. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42200. import { Vector4 } from "babylonjs/Maths/math";
  42201. import { Mesh } from "babylonjs/Meshes/mesh";
  42202. /**
  42203. * Class containing static functions to help procedurally build meshes
  42204. */
  42205. export class SphereBuilder {
  42206. /**
  42207. * Creates a sphere mesh
  42208. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42209. * * 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`)
  42210. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42211. * * 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
  42212. * * 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)
  42213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42216. * @param name defines the name of the mesh
  42217. * @param options defines the options used to create the mesh
  42218. * @param scene defines the hosting scene
  42219. * @returns the sphere mesh
  42220. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42221. */
  42222. static CreateSphere(name: string, options: {
  42223. segments?: number;
  42224. diameter?: number;
  42225. diameterX?: number;
  42226. diameterY?: number;
  42227. diameterZ?: number;
  42228. arc?: number;
  42229. slice?: number;
  42230. sideOrientation?: number;
  42231. frontUVs?: Vector4;
  42232. backUVs?: Vector4;
  42233. updatable?: boolean;
  42234. }, scene: any): Mesh;
  42235. }
  42236. }
  42237. declare module "babylonjs/Debug/physicsViewer" {
  42238. import { Nullable } from "babylonjs/types";
  42239. import { Scene } from "babylonjs/scene";
  42240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42241. import { Mesh } from "babylonjs/Meshes/mesh";
  42242. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42243. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42244. /**
  42245. * Used to show the physics impostor around the specific mesh
  42246. */
  42247. export class PhysicsViewer {
  42248. /** @hidden */
  42249. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42250. /** @hidden */
  42251. protected _meshes: Array<Nullable<AbstractMesh>>;
  42252. /** @hidden */
  42253. protected _scene: Nullable<Scene>;
  42254. /** @hidden */
  42255. protected _numMeshes: number;
  42256. /** @hidden */
  42257. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42258. private _renderFunction;
  42259. private _utilityLayer;
  42260. private _debugBoxMesh;
  42261. private _debugSphereMesh;
  42262. private _debugCylinderMesh;
  42263. private _debugMaterial;
  42264. private _debugMeshMeshes;
  42265. /**
  42266. * Creates a new PhysicsViewer
  42267. * @param scene defines the hosting scene
  42268. */
  42269. constructor(scene: Scene);
  42270. /** @hidden */
  42271. protected _updateDebugMeshes(): void;
  42272. /**
  42273. * Renders a specified physic impostor
  42274. * @param impostor defines the impostor to render
  42275. * @param targetMesh defines the mesh represented by the impostor
  42276. * @returns the new debug mesh used to render the impostor
  42277. */
  42278. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42279. /**
  42280. * Hides a specified physic impostor
  42281. * @param impostor defines the impostor to hide
  42282. */
  42283. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42284. private _getDebugMaterial;
  42285. private _getDebugBoxMesh;
  42286. private _getDebugSphereMesh;
  42287. private _getDebugCylinderMesh;
  42288. private _getDebugMeshMesh;
  42289. private _getDebugMesh;
  42290. /** Releases all resources */
  42291. dispose(): void;
  42292. }
  42293. }
  42294. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42295. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42296. import { Nullable } from "babylonjs/types";
  42297. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42298. import { Scene } from "babylonjs/scene";
  42299. /**
  42300. * Class containing static functions to help procedurally build meshes
  42301. */
  42302. export class LinesBuilder {
  42303. /**
  42304. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42305. * * 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
  42306. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42307. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42308. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42309. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42310. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42311. * * 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
  42312. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42314. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42315. * @param name defines the name of the new line system
  42316. * @param options defines the options used to create the line system
  42317. * @param scene defines the hosting scene
  42318. * @returns a new line system mesh
  42319. */
  42320. static CreateLineSystem(name: string, options: {
  42321. lines: Vector3[][];
  42322. updatable?: boolean;
  42323. instance?: Nullable<LinesMesh>;
  42324. colors?: Nullable<Color4[][]>;
  42325. useVertexAlpha?: boolean;
  42326. }, scene: Nullable<Scene>): LinesMesh;
  42327. /**
  42328. * Creates a line mesh
  42329. * 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
  42330. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42331. * * The parameter `points` is an array successive Vector3
  42332. * * 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
  42333. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42334. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42335. * * When updating an instance, remember that only point positions can change, not the number of points
  42336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42338. * @param name defines the name of the new line system
  42339. * @param options defines the options used to create the line system
  42340. * @param scene defines the hosting scene
  42341. * @returns a new line mesh
  42342. */
  42343. static CreateLines(name: string, options: {
  42344. points: Vector3[];
  42345. updatable?: boolean;
  42346. instance?: Nullable<LinesMesh>;
  42347. colors?: Color4[];
  42348. useVertexAlpha?: boolean;
  42349. }, scene?: Nullable<Scene>): LinesMesh;
  42350. /**
  42351. * Creates a dashed line mesh
  42352. * * 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
  42353. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42354. * * The parameter `points` is an array successive Vector3
  42355. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42356. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42357. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42358. * * 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
  42359. * * When updating an instance, remember that only point positions can change, not the number of points
  42360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42361. * @param name defines the name of the mesh
  42362. * @param options defines the options used to create the mesh
  42363. * @param scene defines the hosting scene
  42364. * @returns the dashed line mesh
  42365. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42366. */
  42367. static CreateDashedLines(name: string, options: {
  42368. points: Vector3[];
  42369. dashSize?: number;
  42370. gapSize?: number;
  42371. dashNb?: number;
  42372. updatable?: boolean;
  42373. instance?: LinesMesh;
  42374. }, scene?: Nullable<Scene>): LinesMesh;
  42375. }
  42376. }
  42377. declare module "babylonjs/Debug/rayHelper" {
  42378. import { Nullable } from "babylonjs/types";
  42379. import { Ray } from "babylonjs/Culling/ray";
  42380. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42381. import { Scene } from "babylonjs/scene";
  42382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42383. import "babylonjs/Meshes/Builders/linesBuilder";
  42384. /**
  42385. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42386. * in order to better appreciate the issue one might have.
  42387. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42388. */
  42389. export class RayHelper {
  42390. /**
  42391. * Defines the ray we are currently tryin to visualize.
  42392. */
  42393. ray: Nullable<Ray>;
  42394. private _renderPoints;
  42395. private _renderLine;
  42396. private _renderFunction;
  42397. private _scene;
  42398. private _updateToMeshFunction;
  42399. private _attachedToMesh;
  42400. private _meshSpaceDirection;
  42401. private _meshSpaceOrigin;
  42402. /**
  42403. * Helper function to create a colored helper in a scene in one line.
  42404. * @param ray Defines the ray we are currently tryin to visualize
  42405. * @param scene Defines the scene the ray is used in
  42406. * @param color Defines the color we want to see the ray in
  42407. * @returns The newly created ray helper.
  42408. */
  42409. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42410. /**
  42411. * Instantiate a new ray helper.
  42412. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42413. * in order to better appreciate the issue one might have.
  42414. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42415. * @param ray Defines the ray we are currently tryin to visualize
  42416. */
  42417. constructor(ray: Ray);
  42418. /**
  42419. * Shows the ray we are willing to debug.
  42420. * @param scene Defines the scene the ray needs to be rendered in
  42421. * @param color Defines the color the ray needs to be rendered in
  42422. */
  42423. show(scene: Scene, color?: Color3): void;
  42424. /**
  42425. * Hides the ray we are debugging.
  42426. */
  42427. hide(): void;
  42428. private _render;
  42429. /**
  42430. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42431. * @param mesh Defines the mesh we want the helper attached to
  42432. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42433. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42434. * @param length Defines the length of the ray
  42435. */
  42436. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42437. /**
  42438. * Detach the ray helper from the mesh it has previously been attached to.
  42439. */
  42440. detachFromMesh(): void;
  42441. private _updateToMesh;
  42442. /**
  42443. * Dispose the helper and release its associated resources.
  42444. */
  42445. dispose(): void;
  42446. }
  42447. }
  42448. declare module "babylonjs/Debug/skeletonViewer" {
  42449. import { Color3 } from "babylonjs/Maths/math";
  42450. import { Scene } from "babylonjs/scene";
  42451. import { Nullable } from "babylonjs/types";
  42452. import { Skeleton } from "babylonjs/Bones/skeleton";
  42453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42454. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42455. /**
  42456. * Class used to render a debug view of a given skeleton
  42457. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42458. */
  42459. export class SkeletonViewer {
  42460. /** defines the skeleton to render */
  42461. skeleton: Skeleton;
  42462. /** defines the mesh attached to the skeleton */
  42463. mesh: AbstractMesh;
  42464. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42465. autoUpdateBonesMatrices: boolean;
  42466. /** defines the rendering group id to use with the viewer */
  42467. renderingGroupId: number;
  42468. /** Gets or sets the color used to render the skeleton */
  42469. color: Color3;
  42470. private _scene;
  42471. private _debugLines;
  42472. private _debugMesh;
  42473. private _isEnabled;
  42474. private _renderFunction;
  42475. private _utilityLayer;
  42476. /**
  42477. * Returns the mesh used to render the bones
  42478. */
  42479. readonly debugMesh: Nullable<LinesMesh>;
  42480. /**
  42481. * Creates a new SkeletonViewer
  42482. * @param skeleton defines the skeleton to render
  42483. * @param mesh defines the mesh attached to the skeleton
  42484. * @param scene defines the hosting scene
  42485. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42486. * @param renderingGroupId defines the rendering group id to use with the viewer
  42487. */
  42488. constructor(
  42489. /** defines the skeleton to render */
  42490. skeleton: Skeleton,
  42491. /** defines the mesh attached to the skeleton */
  42492. mesh: AbstractMesh, scene: Scene,
  42493. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42494. autoUpdateBonesMatrices?: boolean,
  42495. /** defines the rendering group id to use with the viewer */
  42496. renderingGroupId?: number);
  42497. /** Gets or sets a boolean indicating if the viewer is enabled */
  42498. isEnabled: boolean;
  42499. private _getBonePosition;
  42500. private _getLinesForBonesWithLength;
  42501. private _getLinesForBonesNoLength;
  42502. /** Update the viewer to sync with current skeleton state */
  42503. update(): void;
  42504. /** Release associated resources */
  42505. dispose(): void;
  42506. }
  42507. }
  42508. declare module "babylonjs/Debug/index" {
  42509. export * from "babylonjs/Debug/axesViewer";
  42510. export * from "babylonjs/Debug/boneAxesViewer";
  42511. export * from "babylonjs/Debug/debugLayer";
  42512. export * from "babylonjs/Debug/physicsViewer";
  42513. export * from "babylonjs/Debug/rayHelper";
  42514. export * from "babylonjs/Debug/skeletonViewer";
  42515. }
  42516. declare module "babylonjs/Engines/nullEngine" {
  42517. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42518. import { Scene } from "babylonjs/scene";
  42519. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42520. import { Engine } from "babylonjs/Engines/engine";
  42521. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42522. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42523. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42524. import { Effect } from "babylonjs/Materials/effect";
  42525. /**
  42526. * Options to create the null engine
  42527. */
  42528. export class NullEngineOptions {
  42529. /**
  42530. * Render width (Default: 512)
  42531. */
  42532. renderWidth: number;
  42533. /**
  42534. * Render height (Default: 256)
  42535. */
  42536. renderHeight: number;
  42537. /**
  42538. * Texture size (Default: 512)
  42539. */
  42540. textureSize: number;
  42541. /**
  42542. * If delta time between frames should be constant
  42543. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42544. */
  42545. deterministicLockstep: boolean;
  42546. /**
  42547. * Maximum about of steps between frames (Default: 4)
  42548. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42549. */
  42550. lockstepMaxSteps: number;
  42551. }
  42552. /**
  42553. * The null engine class provides support for headless version of babylon.js.
  42554. * This can be used in server side scenario or for testing purposes
  42555. */
  42556. export class NullEngine extends Engine {
  42557. private _options;
  42558. /**
  42559. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42560. */
  42561. isDeterministicLockStep(): boolean;
  42562. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42563. getLockstepMaxSteps(): number;
  42564. /**
  42565. * Sets hardware scaling, used to save performance if needed
  42566. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42567. */
  42568. getHardwareScalingLevel(): number;
  42569. constructor(options?: NullEngineOptions);
  42570. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42571. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42572. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42573. getRenderWidth(useScreen?: boolean): number;
  42574. getRenderHeight(useScreen?: boolean): number;
  42575. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42576. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42577. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42578. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42579. bindSamplers(effect: Effect): void;
  42580. enableEffect(effect: Effect): void;
  42581. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42582. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42583. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42584. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42585. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42586. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42587. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42588. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42589. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42590. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42591. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42592. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42593. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42594. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42595. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42596. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42597. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42598. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42599. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42600. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42601. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42602. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42603. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42604. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42605. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42606. bindBuffers(vertexBuffers: {
  42607. [key: string]: VertexBuffer;
  42608. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42609. wipeCaches(bruteForce?: boolean): void;
  42610. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42611. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42612. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42613. /** @hidden */
  42614. _createTexture(): WebGLTexture;
  42615. /** @hidden */
  42616. _releaseTexture(texture: InternalTexture): void;
  42617. 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;
  42618. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42619. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42620. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42621. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42622. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42623. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42624. areAllEffectsReady(): boolean;
  42625. /**
  42626. * @hidden
  42627. * Get the current error code of the webGL context
  42628. * @returns the error code
  42629. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42630. */
  42631. getError(): number;
  42632. /** @hidden */
  42633. _getUnpackAlignement(): number;
  42634. /** @hidden */
  42635. _unpackFlipY(value: boolean): void;
  42636. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42637. /**
  42638. * Updates a dynamic vertex buffer.
  42639. * @param vertexBuffer the vertex buffer to update
  42640. * @param data the data used to update the vertex buffer
  42641. * @param byteOffset the byte offset of the data (optional)
  42642. * @param byteLength the byte length of the data (optional)
  42643. */
  42644. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42645. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42646. /** @hidden */
  42647. _bindTexture(channel: number, texture: InternalTexture): void;
  42648. /** @hidden */
  42649. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42650. releaseEffects(): void;
  42651. displayLoadingUI(): void;
  42652. hideLoadingUI(): void;
  42653. /** @hidden */
  42654. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42655. /** @hidden */
  42656. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42657. /** @hidden */
  42658. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42659. /** @hidden */
  42660. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42661. }
  42662. }
  42663. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42664. import { Nullable, int } from "babylonjs/types";
  42665. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42666. /** @hidden */
  42667. export class _OcclusionDataStorage {
  42668. /** @hidden */
  42669. occlusionInternalRetryCounter: number;
  42670. /** @hidden */
  42671. isOcclusionQueryInProgress: boolean;
  42672. /** @hidden */
  42673. isOccluded: boolean;
  42674. /** @hidden */
  42675. occlusionRetryCount: number;
  42676. /** @hidden */
  42677. occlusionType: number;
  42678. /** @hidden */
  42679. occlusionQueryAlgorithmType: number;
  42680. }
  42681. module "babylonjs/Engines/engine" {
  42682. interface Engine {
  42683. /**
  42684. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42685. * @return the new query
  42686. */
  42687. createQuery(): WebGLQuery;
  42688. /**
  42689. * Delete and release a webGL query
  42690. * @param query defines the query to delete
  42691. * @return the current engine
  42692. */
  42693. deleteQuery(query: WebGLQuery): Engine;
  42694. /**
  42695. * Check if a given query has resolved and got its value
  42696. * @param query defines the query to check
  42697. * @returns true if the query got its value
  42698. */
  42699. isQueryResultAvailable(query: WebGLQuery): boolean;
  42700. /**
  42701. * Gets the value of a given query
  42702. * @param query defines the query to check
  42703. * @returns the value of the query
  42704. */
  42705. getQueryResult(query: WebGLQuery): number;
  42706. /**
  42707. * Initiates an occlusion query
  42708. * @param algorithmType defines the algorithm to use
  42709. * @param query defines the query to use
  42710. * @returns the current engine
  42711. * @see http://doc.babylonjs.com/features/occlusionquery
  42712. */
  42713. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42714. /**
  42715. * Ends an occlusion query
  42716. * @see http://doc.babylonjs.com/features/occlusionquery
  42717. * @param algorithmType defines the algorithm to use
  42718. * @returns the current engine
  42719. */
  42720. endOcclusionQuery(algorithmType: number): Engine;
  42721. /**
  42722. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42723. * Please note that only one query can be issued at a time
  42724. * @returns a time token used to track the time span
  42725. */
  42726. startTimeQuery(): Nullable<_TimeToken>;
  42727. /**
  42728. * Ends a time query
  42729. * @param token defines the token used to measure the time span
  42730. * @returns the time spent (in ns)
  42731. */
  42732. endTimeQuery(token: _TimeToken): int;
  42733. /** @hidden */
  42734. _currentNonTimestampToken: Nullable<_TimeToken>;
  42735. /** @hidden */
  42736. _createTimeQuery(): WebGLQuery;
  42737. /** @hidden */
  42738. _deleteTimeQuery(query: WebGLQuery): void;
  42739. /** @hidden */
  42740. _getGlAlgorithmType(algorithmType: number): number;
  42741. /** @hidden */
  42742. _getTimeQueryResult(query: WebGLQuery): any;
  42743. /** @hidden */
  42744. _getTimeQueryAvailability(query: WebGLQuery): any;
  42745. }
  42746. }
  42747. module "babylonjs/Meshes/abstractMesh" {
  42748. interface AbstractMesh {
  42749. /**
  42750. * Backing filed
  42751. * @hidden
  42752. */
  42753. __occlusionDataStorage: _OcclusionDataStorage;
  42754. /**
  42755. * Access property
  42756. * @hidden
  42757. */
  42758. _occlusionDataStorage: _OcclusionDataStorage;
  42759. /**
  42760. * 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.
  42761. * The default value is -1 which means don't break the query and wait till the result
  42762. * @see http://doc.babylonjs.com/features/occlusionquery
  42763. */
  42764. occlusionRetryCount: number;
  42765. /**
  42766. * 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:
  42767. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42768. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42769. * * 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.
  42770. * @see http://doc.babylonjs.com/features/occlusionquery
  42771. */
  42772. occlusionType: number;
  42773. /**
  42774. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42775. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42776. * * 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.
  42777. * @see http://doc.babylonjs.com/features/occlusionquery
  42778. */
  42779. occlusionQueryAlgorithmType: number;
  42780. /**
  42781. * 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
  42782. * @see http://doc.babylonjs.com/features/occlusionquery
  42783. */
  42784. isOccluded: boolean;
  42785. /**
  42786. * Flag to check the progress status of the query
  42787. * @see http://doc.babylonjs.com/features/occlusionquery
  42788. */
  42789. isOcclusionQueryInProgress: boolean;
  42790. }
  42791. }
  42792. }
  42793. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42794. import { Nullable } from "babylonjs/types";
  42795. /** @hidden */
  42796. export var _forceTransformFeedbackToBundle: boolean;
  42797. module "babylonjs/Engines/engine" {
  42798. interface Engine {
  42799. /**
  42800. * Creates a webGL transform feedback object
  42801. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42802. * @returns the webGL transform feedback object
  42803. */
  42804. createTransformFeedback(): WebGLTransformFeedback;
  42805. /**
  42806. * Delete a webGL transform feedback object
  42807. * @param value defines the webGL transform feedback object to delete
  42808. */
  42809. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42810. /**
  42811. * Bind a webGL transform feedback object to the webgl context
  42812. * @param value defines the webGL transform feedback object to bind
  42813. */
  42814. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42815. /**
  42816. * Begins a transform feedback operation
  42817. * @param usePoints defines if points or triangles must be used
  42818. */
  42819. beginTransformFeedback(usePoints: boolean): void;
  42820. /**
  42821. * Ends a transform feedback operation
  42822. */
  42823. endTransformFeedback(): void;
  42824. /**
  42825. * Specify the varyings to use with transform feedback
  42826. * @param program defines the associated webGL program
  42827. * @param value defines the list of strings representing the varying names
  42828. */
  42829. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42830. /**
  42831. * Bind a webGL buffer for a transform feedback operation
  42832. * @param value defines the webGL buffer to bind
  42833. */
  42834. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42835. }
  42836. }
  42837. }
  42838. declare module "babylonjs/Engines/Extensions/index" {
  42839. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42840. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42841. export * from "babylonjs/Engines/Extensions/engine.multiview";
  42842. }
  42843. declare module "babylonjs/Engines/index" {
  42844. export * from "babylonjs/Engines/constants";
  42845. export * from "babylonjs/Engines/engine";
  42846. export * from "babylonjs/Engines/engineStore";
  42847. export * from "babylonjs/Engines/nullEngine";
  42848. export * from "babylonjs/Engines/Extensions/index";
  42849. }
  42850. declare module "babylonjs/Events/clipboardEvents" {
  42851. /**
  42852. * Gather the list of clipboard event types as constants.
  42853. */
  42854. export class ClipboardEventTypes {
  42855. /**
  42856. * The clipboard event is fired when a copy command is active (pressed).
  42857. */
  42858. static readonly COPY: number;
  42859. /**
  42860. * The clipboard event is fired when a cut command is active (pressed).
  42861. */
  42862. static readonly CUT: number;
  42863. /**
  42864. * The clipboard event is fired when a paste command is active (pressed).
  42865. */
  42866. static readonly PASTE: number;
  42867. }
  42868. /**
  42869. * This class is used to store clipboard related info for the onClipboardObservable event.
  42870. */
  42871. export class ClipboardInfo {
  42872. /**
  42873. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42874. */
  42875. type: number;
  42876. /**
  42877. * Defines the related dom event
  42878. */
  42879. event: ClipboardEvent;
  42880. /**
  42881. *Creates an instance of ClipboardInfo.
  42882. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42883. * @param event Defines the related dom event
  42884. */
  42885. constructor(
  42886. /**
  42887. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42888. */
  42889. type: number,
  42890. /**
  42891. * Defines the related dom event
  42892. */
  42893. event: ClipboardEvent);
  42894. /**
  42895. * Get the clipboard event's type from the keycode.
  42896. * @param keyCode Defines the keyCode for the current keyboard event.
  42897. * @return {number}
  42898. */
  42899. static GetTypeFromCharacter(keyCode: number): number;
  42900. }
  42901. }
  42902. declare module "babylonjs/Events/index" {
  42903. export * from "babylonjs/Events/keyboardEvents";
  42904. export * from "babylonjs/Events/pointerEvents";
  42905. export * from "babylonjs/Events/clipboardEvents";
  42906. }
  42907. declare module "babylonjs/Loading/sceneLoader" {
  42908. import { Observable } from "babylonjs/Misc/observable";
  42909. import { Nullable } from "babylonjs/types";
  42910. import { Scene } from "babylonjs/scene";
  42911. import { Engine } from "babylonjs/Engines/engine";
  42912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42913. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42914. import { AssetContainer } from "babylonjs/assetContainer";
  42915. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42916. import { Skeleton } from "babylonjs/Bones/skeleton";
  42917. /**
  42918. * Class used to represent data loading progression
  42919. */
  42920. export class SceneLoaderProgressEvent {
  42921. /** defines if data length to load can be evaluated */
  42922. readonly lengthComputable: boolean;
  42923. /** defines the loaded data length */
  42924. readonly loaded: number;
  42925. /** defines the data length to load */
  42926. readonly total: number;
  42927. /**
  42928. * Create a new progress event
  42929. * @param lengthComputable defines if data length to load can be evaluated
  42930. * @param loaded defines the loaded data length
  42931. * @param total defines the data length to load
  42932. */
  42933. constructor(
  42934. /** defines if data length to load can be evaluated */
  42935. lengthComputable: boolean,
  42936. /** defines the loaded data length */
  42937. loaded: number,
  42938. /** defines the data length to load */
  42939. total: number);
  42940. /**
  42941. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42942. * @param event defines the source event
  42943. * @returns a new SceneLoaderProgressEvent
  42944. */
  42945. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42946. }
  42947. /**
  42948. * Interface used by SceneLoader plugins to define supported file extensions
  42949. */
  42950. export interface ISceneLoaderPluginExtensions {
  42951. /**
  42952. * Defines the list of supported extensions
  42953. */
  42954. [extension: string]: {
  42955. isBinary: boolean;
  42956. };
  42957. }
  42958. /**
  42959. * Interface used by SceneLoader plugin factory
  42960. */
  42961. export interface ISceneLoaderPluginFactory {
  42962. /**
  42963. * Defines the name of the factory
  42964. */
  42965. name: string;
  42966. /**
  42967. * Function called to create a new plugin
  42968. * @return the new plugin
  42969. */
  42970. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42971. /**
  42972. * Boolean indicating if the plugin can direct load specific data
  42973. */
  42974. canDirectLoad?: (data: string) => boolean;
  42975. }
  42976. /**
  42977. * Interface used to define a SceneLoader plugin
  42978. */
  42979. export interface ISceneLoaderPlugin {
  42980. /**
  42981. * The friendly name of this plugin.
  42982. */
  42983. name: string;
  42984. /**
  42985. * The file extensions supported by this plugin.
  42986. */
  42987. extensions: string | ISceneLoaderPluginExtensions;
  42988. /**
  42989. * Import meshes into a scene.
  42990. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42991. * @param scene The scene to import into
  42992. * @param data The data to import
  42993. * @param rootUrl The root url for scene and resources
  42994. * @param meshes The meshes array to import into
  42995. * @param particleSystems The particle systems array to import into
  42996. * @param skeletons The skeletons array to import into
  42997. * @param onError The callback when import fails
  42998. * @returns True if successful or false otherwise
  42999. */
  43000. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43001. /**
  43002. * Load into a scene.
  43003. * @param scene The scene to load into
  43004. * @param data The data to import
  43005. * @param rootUrl The root url for scene and resources
  43006. * @param onError The callback when import fails
  43007. * @returns true if successful or false otherwise
  43008. */
  43009. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43010. /**
  43011. * The callback that returns true if the data can be directly loaded.
  43012. */
  43013. canDirectLoad?: (data: string) => boolean;
  43014. /**
  43015. * The callback that allows custom handling of the root url based on the response url.
  43016. */
  43017. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43018. /**
  43019. * Load into an asset container.
  43020. * @param scene The scene to load into
  43021. * @param data The data to import
  43022. * @param rootUrl The root url for scene and resources
  43023. * @param onError The callback when import fails
  43024. * @returns The loaded asset container
  43025. */
  43026. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43027. }
  43028. /**
  43029. * Interface used to define an async SceneLoader plugin
  43030. */
  43031. export interface ISceneLoaderPluginAsync {
  43032. /**
  43033. * The friendly name of this plugin.
  43034. */
  43035. name: string;
  43036. /**
  43037. * The file extensions supported by this plugin.
  43038. */
  43039. extensions: string | ISceneLoaderPluginExtensions;
  43040. /**
  43041. * Import meshes into a scene.
  43042. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43043. * @param scene The scene to import into
  43044. * @param data The data to import
  43045. * @param rootUrl The root url for scene and resources
  43046. * @param onProgress The callback when the load progresses
  43047. * @param fileName Defines the name of the file to load
  43048. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43049. */
  43050. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43051. meshes: AbstractMesh[];
  43052. particleSystems: IParticleSystem[];
  43053. skeletons: Skeleton[];
  43054. animationGroups: AnimationGroup[];
  43055. }>;
  43056. /**
  43057. * Load into a scene.
  43058. * @param scene The scene to load into
  43059. * @param data The data to import
  43060. * @param rootUrl The root url for scene and resources
  43061. * @param onProgress The callback when the load progresses
  43062. * @param fileName Defines the name of the file to load
  43063. * @returns Nothing
  43064. */
  43065. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43066. /**
  43067. * The callback that returns true if the data can be directly loaded.
  43068. */
  43069. canDirectLoad?: (data: string) => boolean;
  43070. /**
  43071. * The callback that allows custom handling of the root url based on the response url.
  43072. */
  43073. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43074. /**
  43075. * Load into an asset container.
  43076. * @param scene The scene to load into
  43077. * @param data The data to import
  43078. * @param rootUrl The root url for scene and resources
  43079. * @param onProgress The callback when the load progresses
  43080. * @param fileName Defines the name of the file to load
  43081. * @returns The loaded asset container
  43082. */
  43083. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43084. }
  43085. /**
  43086. * Class used to load scene from various file formats using registered plugins
  43087. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43088. */
  43089. export class SceneLoader {
  43090. /**
  43091. * No logging while loading
  43092. */
  43093. static readonly NO_LOGGING: number;
  43094. /**
  43095. * Minimal logging while loading
  43096. */
  43097. static readonly MINIMAL_LOGGING: number;
  43098. /**
  43099. * Summary logging while loading
  43100. */
  43101. static readonly SUMMARY_LOGGING: number;
  43102. /**
  43103. * Detailled logging while loading
  43104. */
  43105. static readonly DETAILED_LOGGING: number;
  43106. /**
  43107. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43108. */
  43109. static ForceFullSceneLoadingForIncremental: boolean;
  43110. /**
  43111. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43112. */
  43113. static ShowLoadingScreen: boolean;
  43114. /**
  43115. * Defines the current logging level (while loading the scene)
  43116. * @ignorenaming
  43117. */
  43118. static loggingLevel: number;
  43119. /**
  43120. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43121. */
  43122. static CleanBoneMatrixWeights: boolean;
  43123. /**
  43124. * Event raised when a plugin is used to load a scene
  43125. */
  43126. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43127. private static _registeredPlugins;
  43128. private static _getDefaultPlugin;
  43129. private static _getPluginForExtension;
  43130. private static _getPluginForDirectLoad;
  43131. private static _getPluginForFilename;
  43132. private static _getDirectLoad;
  43133. private static _loadData;
  43134. private static _getFileInfo;
  43135. /**
  43136. * Gets a plugin that can load the given extension
  43137. * @param extension defines the extension to load
  43138. * @returns a plugin or null if none works
  43139. */
  43140. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43141. /**
  43142. * Gets a boolean indicating that the given extension can be loaded
  43143. * @param extension defines the extension to load
  43144. * @returns true if the extension is supported
  43145. */
  43146. static IsPluginForExtensionAvailable(extension: string): boolean;
  43147. /**
  43148. * Adds a new plugin to the list of registered plugins
  43149. * @param plugin defines the plugin to add
  43150. */
  43151. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43152. /**
  43153. * Import meshes into a scene
  43154. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43155. * @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)
  43156. * @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)
  43157. * @param scene the instance of BABYLON.Scene to append to
  43158. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43159. * @param onProgress a callback with a progress event for each file being loaded
  43160. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43161. * @param pluginExtension the extension used to determine the plugin
  43162. * @returns The loaded plugin
  43163. */
  43164. 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>;
  43165. /**
  43166. * Import meshes into a scene
  43167. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43168. * @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)
  43169. * @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)
  43170. * @param scene the instance of BABYLON.Scene to append to
  43171. * @param onProgress a callback with a progress event for each file being loaded
  43172. * @param pluginExtension the extension used to determine the plugin
  43173. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43174. */
  43175. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43176. meshes: AbstractMesh[];
  43177. particleSystems: IParticleSystem[];
  43178. skeletons: Skeleton[];
  43179. animationGroups: AnimationGroup[];
  43180. }>;
  43181. /**
  43182. * Load a scene
  43183. * @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)
  43184. * @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)
  43185. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43186. * @param onSuccess a callback with the scene when import succeeds
  43187. * @param onProgress a callback with a progress event for each file being loaded
  43188. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43189. * @param pluginExtension the extension used to determine the plugin
  43190. * @returns The loaded plugin
  43191. */
  43192. 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>;
  43193. /**
  43194. * Load a scene
  43195. * @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)
  43196. * @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)
  43197. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43198. * @param onProgress a callback with a progress event for each file being loaded
  43199. * @param pluginExtension the extension used to determine the plugin
  43200. * @returns The loaded scene
  43201. */
  43202. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43203. /**
  43204. * Append a scene
  43205. * @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)
  43206. * @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)
  43207. * @param scene is the instance of BABYLON.Scene to append to
  43208. * @param onSuccess a callback with the scene when import succeeds
  43209. * @param onProgress a callback with a progress event for each file being loaded
  43210. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43211. * @param pluginExtension the extension used to determine the plugin
  43212. * @returns The loaded plugin
  43213. */
  43214. 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>;
  43215. /**
  43216. * Append a scene
  43217. * @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)
  43218. * @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)
  43219. * @param scene is the instance of BABYLON.Scene to append to
  43220. * @param onProgress a callback with a progress event for each file being loaded
  43221. * @param pluginExtension the extension used to determine the plugin
  43222. * @returns The given scene
  43223. */
  43224. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43225. /**
  43226. * Load a scene into an asset container
  43227. * @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)
  43228. * @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)
  43229. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43230. * @param onSuccess a callback with the scene when import succeeds
  43231. * @param onProgress a callback with a progress event for each file being loaded
  43232. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43233. * @param pluginExtension the extension used to determine the plugin
  43234. * @returns The loaded plugin
  43235. */
  43236. 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>;
  43237. /**
  43238. * Load a scene into an asset container
  43239. * @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)
  43240. * @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)
  43241. * @param scene is the instance of Scene to append to
  43242. * @param onProgress a callback with a progress event for each file being loaded
  43243. * @param pluginExtension the extension used to determine the plugin
  43244. * @returns The loaded asset container
  43245. */
  43246. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43247. }
  43248. }
  43249. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43250. import { Scene } from "babylonjs/scene";
  43251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43252. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43253. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43254. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43255. /**
  43256. * Google Daydream controller
  43257. */
  43258. export class DaydreamController extends WebVRController {
  43259. /**
  43260. * Base Url for the controller model.
  43261. */
  43262. static MODEL_BASE_URL: string;
  43263. /**
  43264. * File name for the controller model.
  43265. */
  43266. static MODEL_FILENAME: string;
  43267. /**
  43268. * Gamepad Id prefix used to identify Daydream Controller.
  43269. */
  43270. static readonly GAMEPAD_ID_PREFIX: string;
  43271. /**
  43272. * Creates a new DaydreamController from a gamepad
  43273. * @param vrGamepad the gamepad that the controller should be created from
  43274. */
  43275. constructor(vrGamepad: any);
  43276. /**
  43277. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43278. * @param scene scene in which to add meshes
  43279. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43280. */
  43281. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43282. /**
  43283. * Called once for each button that changed state since the last frame
  43284. * @param buttonIdx Which button index changed
  43285. * @param state New state of the button
  43286. * @param changes Which properties on the state changed since last frame
  43287. */
  43288. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43289. }
  43290. }
  43291. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43292. import { Scene } from "babylonjs/scene";
  43293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43294. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43295. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43296. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43297. /**
  43298. * Gear VR Controller
  43299. */
  43300. export class GearVRController extends WebVRController {
  43301. /**
  43302. * Base Url for the controller model.
  43303. */
  43304. static MODEL_BASE_URL: string;
  43305. /**
  43306. * File name for the controller model.
  43307. */
  43308. static MODEL_FILENAME: string;
  43309. /**
  43310. * Gamepad Id prefix used to identify this controller.
  43311. */
  43312. static readonly GAMEPAD_ID_PREFIX: string;
  43313. private readonly _buttonIndexToObservableNameMap;
  43314. /**
  43315. * Creates a new GearVRController from a gamepad
  43316. * @param vrGamepad the gamepad that the controller should be created from
  43317. */
  43318. constructor(vrGamepad: any);
  43319. /**
  43320. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43321. * @param scene scene in which to add meshes
  43322. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43323. */
  43324. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43325. /**
  43326. * Called once for each button that changed state since the last frame
  43327. * @param buttonIdx Which button index changed
  43328. * @param state New state of the button
  43329. * @param changes Which properties on the state changed since last frame
  43330. */
  43331. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43332. }
  43333. }
  43334. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43335. import { Scene } from "babylonjs/scene";
  43336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43337. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43338. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43339. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43340. /**
  43341. * Generic Controller
  43342. */
  43343. export class GenericController extends WebVRController {
  43344. /**
  43345. * Base Url for the controller model.
  43346. */
  43347. static readonly MODEL_BASE_URL: string;
  43348. /**
  43349. * File name for the controller model.
  43350. */
  43351. static readonly MODEL_FILENAME: string;
  43352. /**
  43353. * Creates a new GenericController from a gamepad
  43354. * @param vrGamepad the gamepad that the controller should be created from
  43355. */
  43356. constructor(vrGamepad: any);
  43357. /**
  43358. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43359. * @param scene scene in which to add meshes
  43360. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43361. */
  43362. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43363. /**
  43364. * Called once for each button that changed state since the last frame
  43365. * @param buttonIdx Which button index changed
  43366. * @param state New state of the button
  43367. * @param changes Which properties on the state changed since last frame
  43368. */
  43369. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43370. }
  43371. }
  43372. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43373. import { Observable } from "babylonjs/Misc/observable";
  43374. import { Scene } from "babylonjs/scene";
  43375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43376. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43377. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43378. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43379. /**
  43380. * Oculus Touch Controller
  43381. */
  43382. export class OculusTouchController extends WebVRController {
  43383. /**
  43384. * Base Url for the controller model.
  43385. */
  43386. static MODEL_BASE_URL: string;
  43387. /**
  43388. * File name for the left controller model.
  43389. */
  43390. static MODEL_LEFT_FILENAME: string;
  43391. /**
  43392. * File name for the right controller model.
  43393. */
  43394. static MODEL_RIGHT_FILENAME: string;
  43395. /**
  43396. * Fired when the secondary trigger on this controller is modified
  43397. */
  43398. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43399. /**
  43400. * Fired when the thumb rest on this controller is modified
  43401. */
  43402. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43403. /**
  43404. * Creates a new OculusTouchController from a gamepad
  43405. * @param vrGamepad the gamepad that the controller should be created from
  43406. */
  43407. constructor(vrGamepad: any);
  43408. /**
  43409. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43410. * @param scene scene in which to add meshes
  43411. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43412. */
  43413. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43414. /**
  43415. * Fired when the A button on this controller is modified
  43416. */
  43417. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43418. /**
  43419. * Fired when the B button on this controller is modified
  43420. */
  43421. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43422. /**
  43423. * Fired when the X button on this controller is modified
  43424. */
  43425. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43426. /**
  43427. * Fired when the Y button on this controller is modified
  43428. */
  43429. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43430. /**
  43431. * Called once for each button that changed state since the last frame
  43432. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43433. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43434. * 2) secondary trigger (same)
  43435. * 3) A (right) X (left), touch, pressed = value
  43436. * 4) B / Y
  43437. * 5) thumb rest
  43438. * @param buttonIdx Which button index changed
  43439. * @param state New state of the button
  43440. * @param changes Which properties on the state changed since last frame
  43441. */
  43442. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43443. }
  43444. }
  43445. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43446. import { Scene } from "babylonjs/scene";
  43447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43448. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43449. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43450. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43451. import { Observable } from "babylonjs/Misc/observable";
  43452. /**
  43453. * Vive Controller
  43454. */
  43455. export class ViveController extends WebVRController {
  43456. /**
  43457. * Base Url for the controller model.
  43458. */
  43459. static MODEL_BASE_URL: string;
  43460. /**
  43461. * File name for the controller model.
  43462. */
  43463. static MODEL_FILENAME: string;
  43464. /**
  43465. * Creates a new ViveController from a gamepad
  43466. * @param vrGamepad the gamepad that the controller should be created from
  43467. */
  43468. constructor(vrGamepad: any);
  43469. /**
  43470. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43471. * @param scene scene in which to add meshes
  43472. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43473. */
  43474. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43475. /**
  43476. * Fired when the left button on this controller is modified
  43477. */
  43478. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43479. /**
  43480. * Fired when the right button on this controller is modified
  43481. */
  43482. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43483. /**
  43484. * Fired when the menu button on this controller is modified
  43485. */
  43486. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43487. /**
  43488. * Called once for each button that changed state since the last frame
  43489. * Vive mapping:
  43490. * 0: touchpad
  43491. * 1: trigger
  43492. * 2: left AND right buttons
  43493. * 3: menu button
  43494. * @param buttonIdx Which button index changed
  43495. * @param state New state of the button
  43496. * @param changes Which properties on the state changed since last frame
  43497. */
  43498. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43499. }
  43500. }
  43501. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43502. import { Observable } from "babylonjs/Misc/observable";
  43503. import { Scene } from "babylonjs/scene";
  43504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43505. import { Ray } from "babylonjs/Culling/ray";
  43506. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43507. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43508. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43509. /**
  43510. * Defines the WindowsMotionController object that the state of the windows motion controller
  43511. */
  43512. export class WindowsMotionController extends WebVRController {
  43513. /**
  43514. * The base url used to load the left and right controller models
  43515. */
  43516. static MODEL_BASE_URL: string;
  43517. /**
  43518. * The name of the left controller model file
  43519. */
  43520. static MODEL_LEFT_FILENAME: string;
  43521. /**
  43522. * The name of the right controller model file
  43523. */
  43524. static MODEL_RIGHT_FILENAME: string;
  43525. /**
  43526. * The controller name prefix for this controller type
  43527. */
  43528. static readonly GAMEPAD_ID_PREFIX: string;
  43529. /**
  43530. * The controller id pattern for this controller type
  43531. */
  43532. private static readonly GAMEPAD_ID_PATTERN;
  43533. private _loadedMeshInfo;
  43534. private readonly _mapping;
  43535. /**
  43536. * Fired when the trackpad on this controller is clicked
  43537. */
  43538. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43539. /**
  43540. * Fired when the trackpad on this controller is modified
  43541. */
  43542. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43543. /**
  43544. * The current x and y values of this controller's trackpad
  43545. */
  43546. trackpad: StickValues;
  43547. /**
  43548. * Creates a new WindowsMotionController from a gamepad
  43549. * @param vrGamepad the gamepad that the controller should be created from
  43550. */
  43551. constructor(vrGamepad: any);
  43552. /**
  43553. * Fired when the trigger on this controller is modified
  43554. */
  43555. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43556. /**
  43557. * Fired when the menu button on this controller is modified
  43558. */
  43559. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43560. /**
  43561. * Fired when the grip button on this controller is modified
  43562. */
  43563. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43564. /**
  43565. * Fired when the thumbstick button on this controller is modified
  43566. */
  43567. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43568. /**
  43569. * Fired when the touchpad button on this controller is modified
  43570. */
  43571. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43572. /**
  43573. * Fired when the touchpad values on this controller are modified
  43574. */
  43575. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43576. private _updateTrackpad;
  43577. /**
  43578. * Called once per frame by the engine.
  43579. */
  43580. update(): void;
  43581. /**
  43582. * Called once for each button that changed state since the last frame
  43583. * @param buttonIdx Which button index changed
  43584. * @param state New state of the button
  43585. * @param changes Which properties on the state changed since last frame
  43586. */
  43587. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43588. /**
  43589. * Moves the buttons on the controller mesh based on their current state
  43590. * @param buttonName the name of the button to move
  43591. * @param buttonValue the value of the button which determines the buttons new position
  43592. */
  43593. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43594. /**
  43595. * Moves the axis on the controller mesh based on its current state
  43596. * @param axis the index of the axis
  43597. * @param axisValue the value of the axis which determines the meshes new position
  43598. * @hidden
  43599. */
  43600. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43601. /**
  43602. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43603. * @param scene scene in which to add meshes
  43604. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43605. */
  43606. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43607. /**
  43608. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43609. * can be transformed by button presses and axes values, based on this._mapping.
  43610. *
  43611. * @param scene scene in which the meshes exist
  43612. * @param meshes list of meshes that make up the controller model to process
  43613. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43614. */
  43615. private processModel;
  43616. private createMeshInfo;
  43617. /**
  43618. * Gets the ray of the controller in the direction the controller is pointing
  43619. * @param length the length the resulting ray should be
  43620. * @returns a ray in the direction the controller is pointing
  43621. */
  43622. getForwardRay(length?: number): Ray;
  43623. /**
  43624. * Disposes of the controller
  43625. */
  43626. dispose(): void;
  43627. }
  43628. }
  43629. declare module "babylonjs/Gamepads/Controllers/index" {
  43630. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43631. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43632. export * from "babylonjs/Gamepads/Controllers/genericController";
  43633. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43634. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43635. export * from "babylonjs/Gamepads/Controllers/viveController";
  43636. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43637. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43638. }
  43639. declare module "babylonjs/Gamepads/index" {
  43640. export * from "babylonjs/Gamepads/Controllers/index";
  43641. export * from "babylonjs/Gamepads/gamepad";
  43642. export * from "babylonjs/Gamepads/gamepadManager";
  43643. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43644. export * from "babylonjs/Gamepads/xboxGamepad";
  43645. }
  43646. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43647. import { Observable } from "babylonjs/Misc/observable";
  43648. import { Nullable } from "babylonjs/types";
  43649. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43651. import { Mesh } from "babylonjs/Meshes/mesh";
  43652. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43653. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43654. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43655. /**
  43656. * Single axis scale gizmo
  43657. */
  43658. export class AxisScaleGizmo extends Gizmo {
  43659. private _coloredMaterial;
  43660. /**
  43661. * Drag behavior responsible for the gizmos dragging interactions
  43662. */
  43663. dragBehavior: PointerDragBehavior;
  43664. private _pointerObserver;
  43665. /**
  43666. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43667. */
  43668. snapDistance: number;
  43669. /**
  43670. * Event that fires each time the gizmo snaps to a new location.
  43671. * * snapDistance is the the change in distance
  43672. */
  43673. onSnapObservable: Observable<{
  43674. snapDistance: number;
  43675. }>;
  43676. /**
  43677. * If the scaling operation should be done on all axis (default: false)
  43678. */
  43679. uniformScaling: boolean;
  43680. /**
  43681. * Creates an AxisScaleGizmo
  43682. * @param gizmoLayer The utility layer the gizmo will be added to
  43683. * @param dragAxis The axis which the gizmo will be able to scale on
  43684. * @param color The color of the gizmo
  43685. */
  43686. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43687. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43688. /**
  43689. * Disposes of the gizmo
  43690. */
  43691. dispose(): void;
  43692. /**
  43693. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43694. * @param mesh The mesh to replace the default mesh of the gizmo
  43695. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43696. */
  43697. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43698. }
  43699. }
  43700. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43701. import { Observable } from "babylonjs/Misc/observable";
  43702. import { Nullable } from "babylonjs/types";
  43703. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43705. import { Mesh } from "babylonjs/Meshes/mesh";
  43706. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43707. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43708. import "babylonjs/Meshes/Builders/boxBuilder";
  43709. /**
  43710. * Bounding box gizmo
  43711. */
  43712. export class BoundingBoxGizmo extends Gizmo {
  43713. private _lineBoundingBox;
  43714. private _rotateSpheresParent;
  43715. private _scaleBoxesParent;
  43716. private _boundingDimensions;
  43717. private _renderObserver;
  43718. private _pointerObserver;
  43719. private _scaleDragSpeed;
  43720. private _tmpQuaternion;
  43721. private _tmpVector;
  43722. private _tmpRotationMatrix;
  43723. /**
  43724. * 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)
  43725. */
  43726. ignoreChildren: boolean;
  43727. /**
  43728. * 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)
  43729. */
  43730. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43731. /**
  43732. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43733. */
  43734. rotationSphereSize: number;
  43735. /**
  43736. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43737. */
  43738. scaleBoxSize: number;
  43739. /**
  43740. * 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)
  43741. */
  43742. fixedDragMeshScreenSize: boolean;
  43743. /**
  43744. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43745. */
  43746. fixedDragMeshScreenSizeDistanceFactor: number;
  43747. /**
  43748. * Fired when a rotation sphere or scale box is dragged
  43749. */
  43750. onDragStartObservable: Observable<{}>;
  43751. /**
  43752. * Fired when a scale box is dragged
  43753. */
  43754. onScaleBoxDragObservable: Observable<{}>;
  43755. /**
  43756. * Fired when a scale box drag is ended
  43757. */
  43758. onScaleBoxDragEndObservable: Observable<{}>;
  43759. /**
  43760. * Fired when a rotation sphere is dragged
  43761. */
  43762. onRotationSphereDragObservable: Observable<{}>;
  43763. /**
  43764. * Fired when a rotation sphere drag is ended
  43765. */
  43766. onRotationSphereDragEndObservable: Observable<{}>;
  43767. /**
  43768. * 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)
  43769. */
  43770. scalePivot: Nullable<Vector3>;
  43771. private _anchorMesh;
  43772. private _existingMeshScale;
  43773. private _dragMesh;
  43774. private pointerDragBehavior;
  43775. private coloredMaterial;
  43776. private hoverColoredMaterial;
  43777. /**
  43778. * Sets the color of the bounding box gizmo
  43779. * @param color the color to set
  43780. */
  43781. setColor(color: Color3): void;
  43782. /**
  43783. * Creates an BoundingBoxGizmo
  43784. * @param gizmoLayer The utility layer the gizmo will be added to
  43785. * @param color The color of the gizmo
  43786. */
  43787. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43788. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43789. private _selectNode;
  43790. /**
  43791. * Updates the bounding box information for the Gizmo
  43792. */
  43793. updateBoundingBox(): void;
  43794. private _updateRotationSpheres;
  43795. private _updateScaleBoxes;
  43796. /**
  43797. * Enables rotation on the specified axis and disables rotation on the others
  43798. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43799. */
  43800. setEnabledRotationAxis(axis: string): void;
  43801. /**
  43802. * Enables/disables scaling
  43803. * @param enable if scaling should be enabled
  43804. */
  43805. setEnabledScaling(enable: boolean): void;
  43806. private _updateDummy;
  43807. /**
  43808. * Enables a pointer drag behavior on the bounding box of the gizmo
  43809. */
  43810. enableDragBehavior(): void;
  43811. /**
  43812. * Disposes of the gizmo
  43813. */
  43814. dispose(): void;
  43815. /**
  43816. * 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)
  43817. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43818. * @returns the bounding box mesh with the passed in mesh as a child
  43819. */
  43820. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43821. /**
  43822. * CustomMeshes are not supported by this gizmo
  43823. * @param mesh The mesh to replace the default mesh of the gizmo
  43824. */
  43825. setCustomMesh(mesh: Mesh): void;
  43826. }
  43827. }
  43828. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43829. import { Observable } from "babylonjs/Misc/observable";
  43830. import { Nullable } from "babylonjs/types";
  43831. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43833. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43834. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43835. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43836. import "babylonjs/Meshes/Builders/linesBuilder";
  43837. /**
  43838. * Single plane rotation gizmo
  43839. */
  43840. export class PlaneRotationGizmo extends Gizmo {
  43841. /**
  43842. * Drag behavior responsible for the gizmos dragging interactions
  43843. */
  43844. dragBehavior: PointerDragBehavior;
  43845. private _pointerObserver;
  43846. /**
  43847. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43848. */
  43849. snapDistance: number;
  43850. /**
  43851. * Event that fires each time the gizmo snaps to a new location.
  43852. * * snapDistance is the the change in distance
  43853. */
  43854. onSnapObservable: Observable<{
  43855. snapDistance: number;
  43856. }>;
  43857. /**
  43858. * Creates a PlaneRotationGizmo
  43859. * @param gizmoLayer The utility layer the gizmo will be added to
  43860. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43861. * @param color The color of the gizmo
  43862. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43863. */
  43864. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43865. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43866. /**
  43867. * Disposes of the gizmo
  43868. */
  43869. dispose(): void;
  43870. }
  43871. }
  43872. declare module "babylonjs/Gizmos/rotationGizmo" {
  43873. import { Observable } from "babylonjs/Misc/observable";
  43874. import { Nullable } from "babylonjs/types";
  43875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43876. import { Mesh } from "babylonjs/Meshes/mesh";
  43877. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43878. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43879. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43880. /**
  43881. * Gizmo that enables rotating a mesh along 3 axis
  43882. */
  43883. export class RotationGizmo extends Gizmo {
  43884. /**
  43885. * Internal gizmo used for interactions on the x axis
  43886. */
  43887. xGizmo: PlaneRotationGizmo;
  43888. /**
  43889. * Internal gizmo used for interactions on the y axis
  43890. */
  43891. yGizmo: PlaneRotationGizmo;
  43892. /**
  43893. * Internal gizmo used for interactions on the z axis
  43894. */
  43895. zGizmo: PlaneRotationGizmo;
  43896. /** Fires an event when any of it's sub gizmos are dragged */
  43897. onDragStartObservable: Observable<{}>;
  43898. /** Fires an event when any of it's sub gizmos are released from dragging */
  43899. onDragEndObservable: Observable<{}>;
  43900. attachedMesh: Nullable<AbstractMesh>;
  43901. /**
  43902. * Creates a RotationGizmo
  43903. * @param gizmoLayer The utility layer the gizmo will be added to
  43904. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43905. */
  43906. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43907. updateGizmoRotationToMatchAttachedMesh: boolean;
  43908. /**
  43909. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43910. */
  43911. snapDistance: number;
  43912. /**
  43913. * Ratio for the scale of the gizmo (Default: 1)
  43914. */
  43915. scaleRatio: number;
  43916. /**
  43917. * Disposes of the gizmo
  43918. */
  43919. dispose(): void;
  43920. /**
  43921. * CustomMeshes are not supported by this gizmo
  43922. * @param mesh The mesh to replace the default mesh of the gizmo
  43923. */
  43924. setCustomMesh(mesh: Mesh): void;
  43925. }
  43926. }
  43927. declare module "babylonjs/Gizmos/positionGizmo" {
  43928. import { Observable } from "babylonjs/Misc/observable";
  43929. import { Nullable } from "babylonjs/types";
  43930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43931. import { Mesh } from "babylonjs/Meshes/mesh";
  43932. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43933. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43934. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43935. /**
  43936. * Gizmo that enables dragging a mesh along 3 axis
  43937. */
  43938. export class PositionGizmo extends Gizmo {
  43939. /**
  43940. * Internal gizmo used for interactions on the x axis
  43941. */
  43942. xGizmo: AxisDragGizmo;
  43943. /**
  43944. * Internal gizmo used for interactions on the y axis
  43945. */
  43946. yGizmo: AxisDragGizmo;
  43947. /**
  43948. * Internal gizmo used for interactions on the z axis
  43949. */
  43950. zGizmo: AxisDragGizmo;
  43951. /** Fires an event when any of it's sub gizmos are dragged */
  43952. onDragStartObservable: Observable<{}>;
  43953. /** Fires an event when any of it's sub gizmos are released from dragging */
  43954. onDragEndObservable: Observable<{}>;
  43955. attachedMesh: Nullable<AbstractMesh>;
  43956. /**
  43957. * Creates a PositionGizmo
  43958. * @param gizmoLayer The utility layer the gizmo will be added to
  43959. */
  43960. constructor(gizmoLayer?: UtilityLayerRenderer);
  43961. updateGizmoRotationToMatchAttachedMesh: boolean;
  43962. /**
  43963. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43964. */
  43965. snapDistance: number;
  43966. /**
  43967. * Ratio for the scale of the gizmo (Default: 1)
  43968. */
  43969. scaleRatio: number;
  43970. /**
  43971. * Disposes of the gizmo
  43972. */
  43973. dispose(): void;
  43974. /**
  43975. * CustomMeshes are not supported by this gizmo
  43976. * @param mesh The mesh to replace the default mesh of the gizmo
  43977. */
  43978. setCustomMesh(mesh: Mesh): void;
  43979. }
  43980. }
  43981. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43982. import { Scene } from "babylonjs/scene";
  43983. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43984. import { Mesh } from "babylonjs/Meshes/mesh";
  43985. import { Nullable } from "babylonjs/types";
  43986. /**
  43987. * Class containing static functions to help procedurally build meshes
  43988. */
  43989. export class PolyhedronBuilder {
  43990. /**
  43991. * Creates a polyhedron mesh
  43992. * * 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
  43993. * * The parameter `size` (positive float, default 1) sets the polygon size
  43994. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43995. * * 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`
  43996. * * 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
  43997. * * 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)`)
  43998. * * 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
  43999. * * 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
  44000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44003. * @param name defines the name of the mesh
  44004. * @param options defines the options used to create the mesh
  44005. * @param scene defines the hosting scene
  44006. * @returns the polyhedron mesh
  44007. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44008. */
  44009. static CreatePolyhedron(name: string, options: {
  44010. type?: number;
  44011. size?: number;
  44012. sizeX?: number;
  44013. sizeY?: number;
  44014. sizeZ?: number;
  44015. custom?: any;
  44016. faceUV?: Vector4[];
  44017. faceColors?: Color4[];
  44018. flat?: boolean;
  44019. updatable?: boolean;
  44020. sideOrientation?: number;
  44021. frontUVs?: Vector4;
  44022. backUVs?: Vector4;
  44023. }, scene?: Nullable<Scene>): Mesh;
  44024. }
  44025. }
  44026. declare module "babylonjs/Gizmos/scaleGizmo" {
  44027. import { Observable } from "babylonjs/Misc/observable";
  44028. import { Nullable } from "babylonjs/types";
  44029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44030. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44031. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44032. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44033. /**
  44034. * Gizmo that enables scaling a mesh along 3 axis
  44035. */
  44036. export class ScaleGizmo extends Gizmo {
  44037. /**
  44038. * Internal gizmo used for interactions on the x axis
  44039. */
  44040. xGizmo: AxisScaleGizmo;
  44041. /**
  44042. * Internal gizmo used for interactions on the y axis
  44043. */
  44044. yGizmo: AxisScaleGizmo;
  44045. /**
  44046. * Internal gizmo used for interactions on the z axis
  44047. */
  44048. zGizmo: AxisScaleGizmo;
  44049. /**
  44050. * Internal gizmo used to scale all axis equally
  44051. */
  44052. uniformScaleGizmo: AxisScaleGizmo;
  44053. /** Fires an event when any of it's sub gizmos are dragged */
  44054. onDragStartObservable: Observable<{}>;
  44055. /** Fires an event when any of it's sub gizmos are released from dragging */
  44056. onDragEndObservable: Observable<{}>;
  44057. attachedMesh: Nullable<AbstractMesh>;
  44058. /**
  44059. * Creates a ScaleGizmo
  44060. * @param gizmoLayer The utility layer the gizmo will be added to
  44061. */
  44062. constructor(gizmoLayer?: UtilityLayerRenderer);
  44063. updateGizmoRotationToMatchAttachedMesh: boolean;
  44064. /**
  44065. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44066. */
  44067. snapDistance: number;
  44068. /**
  44069. * Ratio for the scale of the gizmo (Default: 1)
  44070. */
  44071. scaleRatio: number;
  44072. /**
  44073. * Disposes of the gizmo
  44074. */
  44075. dispose(): void;
  44076. }
  44077. }
  44078. declare module "babylonjs/Gizmos/gizmoManager" {
  44079. import { Observable } from "babylonjs/Misc/observable";
  44080. import { Nullable } from "babylonjs/types";
  44081. import { Scene, IDisposable } from "babylonjs/scene";
  44082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44083. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44084. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44085. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44086. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44087. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44088. /**
  44089. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44090. */
  44091. export class GizmoManager implements IDisposable {
  44092. private scene;
  44093. /**
  44094. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44095. */
  44096. gizmos: {
  44097. positionGizmo: Nullable<PositionGizmo>;
  44098. rotationGizmo: Nullable<RotationGizmo>;
  44099. scaleGizmo: Nullable<ScaleGizmo>;
  44100. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44101. };
  44102. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44103. clearGizmoOnEmptyPointerEvent: boolean;
  44104. /** Fires an event when the manager is attached to a mesh */
  44105. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44106. private _gizmosEnabled;
  44107. private _pointerObserver;
  44108. private _attachedMesh;
  44109. private _boundingBoxColor;
  44110. private _defaultUtilityLayer;
  44111. private _defaultKeepDepthUtilityLayer;
  44112. /**
  44113. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44114. */
  44115. boundingBoxDragBehavior: SixDofDragBehavior;
  44116. /**
  44117. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44118. */
  44119. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44120. /**
  44121. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44122. */
  44123. usePointerToAttachGizmos: boolean;
  44124. /**
  44125. * Instatiates a gizmo manager
  44126. * @param scene the scene to overlay the gizmos on top of
  44127. */
  44128. constructor(scene: Scene);
  44129. /**
  44130. * Attaches a set of gizmos to the specified mesh
  44131. * @param mesh The mesh the gizmo's should be attached to
  44132. */
  44133. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44134. /**
  44135. * If the position gizmo is enabled
  44136. */
  44137. positionGizmoEnabled: boolean;
  44138. /**
  44139. * If the rotation gizmo is enabled
  44140. */
  44141. rotationGizmoEnabled: boolean;
  44142. /**
  44143. * If the scale gizmo is enabled
  44144. */
  44145. scaleGizmoEnabled: boolean;
  44146. /**
  44147. * If the boundingBox gizmo is enabled
  44148. */
  44149. boundingBoxGizmoEnabled: boolean;
  44150. /**
  44151. * Disposes of the gizmo manager
  44152. */
  44153. dispose(): void;
  44154. }
  44155. }
  44156. declare module "babylonjs/Lights/directionalLight" {
  44157. import { Camera } from "babylonjs/Cameras/camera";
  44158. import { Scene } from "babylonjs/scene";
  44159. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44161. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44162. import { Effect } from "babylonjs/Materials/effect";
  44163. /**
  44164. * A directional light is defined by a direction (what a surprise!).
  44165. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44166. * 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.
  44167. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44168. */
  44169. export class DirectionalLight extends ShadowLight {
  44170. private _shadowFrustumSize;
  44171. /**
  44172. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44173. */
  44174. /**
  44175. * Specifies a fix frustum size for the shadow generation.
  44176. */
  44177. shadowFrustumSize: number;
  44178. private _shadowOrthoScale;
  44179. /**
  44180. * Gets the shadow projection scale against the optimal computed one.
  44181. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44182. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44183. */
  44184. /**
  44185. * Sets the shadow projection scale against the optimal computed one.
  44186. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44187. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44188. */
  44189. shadowOrthoScale: number;
  44190. /**
  44191. * Automatically compute the projection matrix to best fit (including all the casters)
  44192. * on each frame.
  44193. */
  44194. autoUpdateExtends: boolean;
  44195. private _orthoLeft;
  44196. private _orthoRight;
  44197. private _orthoTop;
  44198. private _orthoBottom;
  44199. /**
  44200. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44201. * The directional light is emitted from everywhere in the given direction.
  44202. * It can cast shadows.
  44203. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44204. * @param name The friendly name of the light
  44205. * @param direction The direction of the light
  44206. * @param scene The scene the light belongs to
  44207. */
  44208. constructor(name: string, direction: Vector3, scene: Scene);
  44209. /**
  44210. * Returns the string "DirectionalLight".
  44211. * @return The class name
  44212. */
  44213. getClassName(): string;
  44214. /**
  44215. * Returns the integer 1.
  44216. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44217. */
  44218. getTypeID(): number;
  44219. /**
  44220. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44221. * Returns the DirectionalLight Shadow projection matrix.
  44222. */
  44223. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44224. /**
  44225. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44226. * Returns the DirectionalLight Shadow projection matrix.
  44227. */
  44228. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44229. /**
  44230. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44231. * Returns the DirectionalLight Shadow projection matrix.
  44232. */
  44233. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44234. protected _buildUniformLayout(): void;
  44235. /**
  44236. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44237. * @param effect The effect to update
  44238. * @param lightIndex The index of the light in the effect to update
  44239. * @returns The directional light
  44240. */
  44241. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44242. /**
  44243. * Gets the minZ used for shadow according to both the scene and the light.
  44244. *
  44245. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44246. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44247. * @param activeCamera The camera we are returning the min for
  44248. * @returns the depth min z
  44249. */
  44250. getDepthMinZ(activeCamera: Camera): number;
  44251. /**
  44252. * Gets the maxZ used for shadow according to both the scene and the light.
  44253. *
  44254. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44255. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44256. * @param activeCamera The camera we are returning the max for
  44257. * @returns the depth max z
  44258. */
  44259. getDepthMaxZ(activeCamera: Camera): number;
  44260. /**
  44261. * Prepares the list of defines specific to the light type.
  44262. * @param defines the list of defines
  44263. * @param lightIndex defines the index of the light for the effect
  44264. */
  44265. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44266. }
  44267. }
  44268. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44269. import { Mesh } from "babylonjs/Meshes/mesh";
  44270. /**
  44271. * Class containing static functions to help procedurally build meshes
  44272. */
  44273. export class HemisphereBuilder {
  44274. /**
  44275. * Creates a hemisphere mesh
  44276. * @param name defines the name of the mesh
  44277. * @param options defines the options used to create the mesh
  44278. * @param scene defines the hosting scene
  44279. * @returns the hemisphere mesh
  44280. */
  44281. static CreateHemisphere(name: string, options: {
  44282. segments?: number;
  44283. diameter?: number;
  44284. sideOrientation?: number;
  44285. }, scene: any): Mesh;
  44286. }
  44287. }
  44288. declare module "babylonjs/Lights/spotLight" {
  44289. import { Nullable } from "babylonjs/types";
  44290. import { Scene } from "babylonjs/scene";
  44291. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44293. import { Effect } from "babylonjs/Materials/effect";
  44294. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44295. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44296. /**
  44297. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44298. * These values define a cone of light starting from the position, emitting toward the direction.
  44299. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44300. * and the exponent defines the speed of the decay of the light with distance (reach).
  44301. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44302. */
  44303. export class SpotLight extends ShadowLight {
  44304. private _angle;
  44305. private _innerAngle;
  44306. private _cosHalfAngle;
  44307. private _lightAngleScale;
  44308. private _lightAngleOffset;
  44309. /**
  44310. * Gets the cone angle of the spot light in Radians.
  44311. */
  44312. /**
  44313. * Sets the cone angle of the spot light in Radians.
  44314. */
  44315. angle: number;
  44316. /**
  44317. * Only used in gltf falloff mode, this defines the angle where
  44318. * the directional falloff will start before cutting at angle which could be seen
  44319. * as outer angle.
  44320. */
  44321. /**
  44322. * Only used in gltf falloff mode, this defines the angle where
  44323. * the directional falloff will start before cutting at angle which could be seen
  44324. * as outer angle.
  44325. */
  44326. innerAngle: number;
  44327. private _shadowAngleScale;
  44328. /**
  44329. * Allows scaling the angle of the light for shadow generation only.
  44330. */
  44331. /**
  44332. * Allows scaling the angle of the light for shadow generation only.
  44333. */
  44334. shadowAngleScale: number;
  44335. /**
  44336. * The light decay speed with the distance from the emission spot.
  44337. */
  44338. exponent: number;
  44339. private _projectionTextureMatrix;
  44340. /**
  44341. * Allows reading the projecton texture
  44342. */
  44343. readonly projectionTextureMatrix: Matrix;
  44344. protected _projectionTextureLightNear: number;
  44345. /**
  44346. * Gets the near clip of the Spotlight for texture projection.
  44347. */
  44348. /**
  44349. * Sets the near clip of the Spotlight for texture projection.
  44350. */
  44351. projectionTextureLightNear: number;
  44352. protected _projectionTextureLightFar: number;
  44353. /**
  44354. * Gets the far clip of the Spotlight for texture projection.
  44355. */
  44356. /**
  44357. * Sets the far clip of the Spotlight for texture projection.
  44358. */
  44359. projectionTextureLightFar: number;
  44360. protected _projectionTextureUpDirection: Vector3;
  44361. /**
  44362. * Gets the Up vector of the Spotlight for texture projection.
  44363. */
  44364. /**
  44365. * Sets the Up vector of the Spotlight for texture projection.
  44366. */
  44367. projectionTextureUpDirection: Vector3;
  44368. private _projectionTexture;
  44369. /**
  44370. * Gets the projection texture of the light.
  44371. */
  44372. /**
  44373. * Sets the projection texture of the light.
  44374. */
  44375. projectionTexture: Nullable<BaseTexture>;
  44376. private _projectionTextureViewLightDirty;
  44377. private _projectionTextureProjectionLightDirty;
  44378. private _projectionTextureDirty;
  44379. private _projectionTextureViewTargetVector;
  44380. private _projectionTextureViewLightMatrix;
  44381. private _projectionTextureProjectionLightMatrix;
  44382. private _projectionTextureScalingMatrix;
  44383. /**
  44384. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44385. * It can cast shadows.
  44386. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44387. * @param name The light friendly name
  44388. * @param position The position of the spot light in the scene
  44389. * @param direction The direction of the light in the scene
  44390. * @param angle The cone angle of the light in Radians
  44391. * @param exponent The light decay speed with the distance from the emission spot
  44392. * @param scene The scene the lights belongs to
  44393. */
  44394. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44395. /**
  44396. * Returns the string "SpotLight".
  44397. * @returns the class name
  44398. */
  44399. getClassName(): string;
  44400. /**
  44401. * Returns the integer 2.
  44402. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44403. */
  44404. getTypeID(): number;
  44405. /**
  44406. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44407. */
  44408. protected _setDirection(value: Vector3): void;
  44409. /**
  44410. * Overrides the position setter to recompute the projection texture view light Matrix.
  44411. */
  44412. protected _setPosition(value: Vector3): void;
  44413. /**
  44414. * 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.
  44415. * Returns the SpotLight.
  44416. */
  44417. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44418. protected _computeProjectionTextureViewLightMatrix(): void;
  44419. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44420. /**
  44421. * Main function for light texture projection matrix computing.
  44422. */
  44423. protected _computeProjectionTextureMatrix(): void;
  44424. protected _buildUniformLayout(): void;
  44425. private _computeAngleValues;
  44426. /**
  44427. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44428. * @param effect The effect to update
  44429. * @param lightIndex The index of the light in the effect to update
  44430. * @returns The spot light
  44431. */
  44432. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44433. /**
  44434. * Disposes the light and the associated resources.
  44435. */
  44436. dispose(): void;
  44437. /**
  44438. * Prepares the list of defines specific to the light type.
  44439. * @param defines the list of defines
  44440. * @param lightIndex defines the index of the light for the effect
  44441. */
  44442. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44443. }
  44444. }
  44445. declare module "babylonjs/Gizmos/lightGizmo" {
  44446. import { Nullable } from "babylonjs/types";
  44447. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44448. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44449. import { Light } from "babylonjs/Lights/light";
  44450. /**
  44451. * Gizmo that enables viewing a light
  44452. */
  44453. export class LightGizmo extends Gizmo {
  44454. private _lightMesh;
  44455. private _material;
  44456. /**
  44457. * Creates a LightGizmo
  44458. * @param gizmoLayer The utility layer the gizmo will be added to
  44459. */
  44460. constructor(gizmoLayer?: UtilityLayerRenderer);
  44461. private _light;
  44462. /**
  44463. * The light that the gizmo is attached to
  44464. */
  44465. light: Nullable<Light>;
  44466. /**
  44467. * @hidden
  44468. * Updates the gizmo to match the attached mesh's position/rotation
  44469. */
  44470. protected _update(): void;
  44471. private static _Scale;
  44472. /**
  44473. * Creates the lines for a light mesh
  44474. */
  44475. private static _createLightLines;
  44476. private static _CreateHemisphericLightMesh;
  44477. private static _CreatePointLightMesh;
  44478. private static _CreateSpotLightMesh;
  44479. private static _CreateDirectionalLightMesh;
  44480. }
  44481. }
  44482. declare module "babylonjs/Gizmos/index" {
  44483. export * from "babylonjs/Gizmos/axisDragGizmo";
  44484. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44485. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44486. export * from "babylonjs/Gizmos/gizmo";
  44487. export * from "babylonjs/Gizmos/gizmoManager";
  44488. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44489. export * from "babylonjs/Gizmos/positionGizmo";
  44490. export * from "babylonjs/Gizmos/rotationGizmo";
  44491. export * from "babylonjs/Gizmos/scaleGizmo";
  44492. export * from "babylonjs/Gizmos/lightGizmo";
  44493. }
  44494. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44495. /** @hidden */
  44496. export var backgroundFragmentDeclaration: {
  44497. name: string;
  44498. shader: string;
  44499. };
  44500. }
  44501. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44502. /** @hidden */
  44503. export var backgroundUboDeclaration: {
  44504. name: string;
  44505. shader: string;
  44506. };
  44507. }
  44508. declare module "babylonjs/Shaders/background.fragment" {
  44509. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44510. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44511. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44512. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44513. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44514. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44515. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44516. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44517. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44518. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44519. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44520. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44521. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44522. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44523. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44524. /** @hidden */
  44525. export var backgroundPixelShader: {
  44526. name: string;
  44527. shader: string;
  44528. };
  44529. }
  44530. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44531. /** @hidden */
  44532. export var backgroundVertexDeclaration: {
  44533. name: string;
  44534. shader: string;
  44535. };
  44536. }
  44537. declare module "babylonjs/Shaders/background.vertex" {
  44538. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  44539. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44540. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44541. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44542. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44543. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44544. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44545. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44546. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44547. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44548. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44549. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44550. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44551. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44552. /** @hidden */
  44553. export var backgroundVertexShader: {
  44554. name: string;
  44555. shader: string;
  44556. };
  44557. }
  44558. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44559. import { Nullable, int, float } from "babylonjs/types";
  44560. import { Scene } from "babylonjs/scene";
  44561. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44562. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44564. import { Mesh } from "babylonjs/Meshes/mesh";
  44565. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44566. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44567. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44568. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44569. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44570. import "babylonjs/Shaders/background.fragment";
  44571. import "babylonjs/Shaders/background.vertex";
  44572. /**
  44573. * Background material used to create an efficient environement around your scene.
  44574. */
  44575. export class BackgroundMaterial extends PushMaterial {
  44576. /**
  44577. * Standard reflectance value at parallel view angle.
  44578. */
  44579. static StandardReflectance0: number;
  44580. /**
  44581. * Standard reflectance value at grazing angle.
  44582. */
  44583. static StandardReflectance90: number;
  44584. protected _primaryColor: Color3;
  44585. /**
  44586. * Key light Color (multiply against the environement texture)
  44587. */
  44588. primaryColor: Color3;
  44589. protected __perceptualColor: Nullable<Color3>;
  44590. /**
  44591. * Experimental Internal Use Only.
  44592. *
  44593. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44594. * This acts as a helper to set the primary color to a more "human friendly" value.
  44595. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44596. * output color as close as possible from the chosen value.
  44597. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44598. * part of lighting setup.)
  44599. */
  44600. _perceptualColor: Nullable<Color3>;
  44601. protected _primaryColorShadowLevel: float;
  44602. /**
  44603. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44604. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44605. */
  44606. primaryColorShadowLevel: float;
  44607. protected _primaryColorHighlightLevel: float;
  44608. /**
  44609. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44610. * The primary color is used at the level chosen to define what the white area would look.
  44611. */
  44612. primaryColorHighlightLevel: float;
  44613. protected _reflectionTexture: Nullable<BaseTexture>;
  44614. /**
  44615. * Reflection Texture used in the material.
  44616. * Should be author in a specific way for the best result (refer to the documentation).
  44617. */
  44618. reflectionTexture: Nullable<BaseTexture>;
  44619. protected _reflectionBlur: float;
  44620. /**
  44621. * Reflection Texture level of blur.
  44622. *
  44623. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44624. * texture twice.
  44625. */
  44626. reflectionBlur: float;
  44627. protected _diffuseTexture: Nullable<BaseTexture>;
  44628. /**
  44629. * Diffuse Texture used in the material.
  44630. * Should be author in a specific way for the best result (refer to the documentation).
  44631. */
  44632. diffuseTexture: Nullable<BaseTexture>;
  44633. protected _shadowLights: Nullable<IShadowLight[]>;
  44634. /**
  44635. * Specify the list of lights casting shadow on the material.
  44636. * All scene shadow lights will be included if null.
  44637. */
  44638. shadowLights: Nullable<IShadowLight[]>;
  44639. protected _shadowLevel: float;
  44640. /**
  44641. * Helps adjusting the shadow to a softer level if required.
  44642. * 0 means black shadows and 1 means no shadows.
  44643. */
  44644. shadowLevel: float;
  44645. protected _sceneCenter: Vector3;
  44646. /**
  44647. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44648. * It is usually zero but might be interesting to modify according to your setup.
  44649. */
  44650. sceneCenter: Vector3;
  44651. protected _opacityFresnel: boolean;
  44652. /**
  44653. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44654. * This helps ensuring a nice transition when the camera goes under the ground.
  44655. */
  44656. opacityFresnel: boolean;
  44657. protected _reflectionFresnel: boolean;
  44658. /**
  44659. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44660. * This helps adding a mirror texture on the ground.
  44661. */
  44662. reflectionFresnel: boolean;
  44663. protected _reflectionFalloffDistance: number;
  44664. /**
  44665. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44666. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44667. */
  44668. reflectionFalloffDistance: number;
  44669. protected _reflectionAmount: number;
  44670. /**
  44671. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44672. */
  44673. reflectionAmount: number;
  44674. protected _reflectionReflectance0: number;
  44675. /**
  44676. * This specifies the weight of the reflection at grazing angle.
  44677. */
  44678. reflectionReflectance0: number;
  44679. protected _reflectionReflectance90: number;
  44680. /**
  44681. * This specifies the weight of the reflection at a perpendicular point of view.
  44682. */
  44683. reflectionReflectance90: number;
  44684. /**
  44685. * Sets the reflection reflectance fresnel values according to the default standard
  44686. * empirically know to work well :-)
  44687. */
  44688. reflectionStandardFresnelWeight: number;
  44689. protected _useRGBColor: boolean;
  44690. /**
  44691. * Helps to directly use the maps channels instead of their level.
  44692. */
  44693. useRGBColor: boolean;
  44694. protected _enableNoise: boolean;
  44695. /**
  44696. * This helps reducing the banding effect that could occur on the background.
  44697. */
  44698. enableNoise: boolean;
  44699. /**
  44700. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44701. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44702. * Recommended to be keep at 1.0 except for special cases.
  44703. */
  44704. fovMultiplier: number;
  44705. private _fovMultiplier;
  44706. /**
  44707. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44708. */
  44709. useEquirectangularFOV: boolean;
  44710. private _maxSimultaneousLights;
  44711. /**
  44712. * Number of Simultaneous lights allowed on the material.
  44713. */
  44714. maxSimultaneousLights: int;
  44715. /**
  44716. * Default configuration related to image processing available in the Background Material.
  44717. */
  44718. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44719. /**
  44720. * Keep track of the image processing observer to allow dispose and replace.
  44721. */
  44722. private _imageProcessingObserver;
  44723. /**
  44724. * Attaches a new image processing configuration to the PBR Material.
  44725. * @param configuration (if null the scene configuration will be use)
  44726. */
  44727. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44728. /**
  44729. * Gets the image processing configuration used either in this material.
  44730. */
  44731. /**
  44732. * Sets the Default image processing configuration used either in the this material.
  44733. *
  44734. * If sets to null, the scene one is in use.
  44735. */
  44736. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44737. /**
  44738. * Gets wether the color curves effect is enabled.
  44739. */
  44740. /**
  44741. * Sets wether the color curves effect is enabled.
  44742. */
  44743. cameraColorCurvesEnabled: boolean;
  44744. /**
  44745. * Gets wether the color grading effect is enabled.
  44746. */
  44747. /**
  44748. * Gets wether the color grading effect is enabled.
  44749. */
  44750. cameraColorGradingEnabled: boolean;
  44751. /**
  44752. * Gets wether tonemapping is enabled or not.
  44753. */
  44754. /**
  44755. * Sets wether tonemapping is enabled or not
  44756. */
  44757. cameraToneMappingEnabled: boolean;
  44758. /**
  44759. * The camera exposure used on this material.
  44760. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44761. * This corresponds to a photographic exposure.
  44762. */
  44763. /**
  44764. * The camera exposure used on this material.
  44765. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44766. * This corresponds to a photographic exposure.
  44767. */
  44768. cameraExposure: float;
  44769. /**
  44770. * Gets The camera contrast used on this material.
  44771. */
  44772. /**
  44773. * Sets The camera contrast used on this material.
  44774. */
  44775. cameraContrast: float;
  44776. /**
  44777. * Gets the Color Grading 2D Lookup Texture.
  44778. */
  44779. /**
  44780. * Sets the Color Grading 2D Lookup Texture.
  44781. */
  44782. cameraColorGradingTexture: Nullable<BaseTexture>;
  44783. /**
  44784. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44785. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44786. * 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;
  44787. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44788. */
  44789. /**
  44790. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44791. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44792. * 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;
  44793. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44794. */
  44795. cameraColorCurves: Nullable<ColorCurves>;
  44796. /**
  44797. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44798. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44799. */
  44800. switchToBGR: boolean;
  44801. private _renderTargets;
  44802. private _reflectionControls;
  44803. private _white;
  44804. private _primaryShadowColor;
  44805. private _primaryHighlightColor;
  44806. /**
  44807. * Instantiates a Background Material in the given scene
  44808. * @param name The friendly name of the material
  44809. * @param scene The scene to add the material to
  44810. */
  44811. constructor(name: string, scene: Scene);
  44812. /**
  44813. * Gets a boolean indicating that current material needs to register RTT
  44814. */
  44815. readonly hasRenderTargetTextures: boolean;
  44816. /**
  44817. * The entire material has been created in order to prevent overdraw.
  44818. * @returns false
  44819. */
  44820. needAlphaTesting(): boolean;
  44821. /**
  44822. * The entire material has been created in order to prevent overdraw.
  44823. * @returns true if blending is enable
  44824. */
  44825. needAlphaBlending(): boolean;
  44826. /**
  44827. * Checks wether the material is ready to be rendered for a given mesh.
  44828. * @param mesh The mesh to render
  44829. * @param subMesh The submesh to check against
  44830. * @param useInstances Specify wether or not the material is used with instances
  44831. * @returns true if all the dependencies are ready (Textures, Effects...)
  44832. */
  44833. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44834. /**
  44835. * Compute the primary color according to the chosen perceptual color.
  44836. */
  44837. private _computePrimaryColorFromPerceptualColor;
  44838. /**
  44839. * Compute the highlights and shadow colors according to their chosen levels.
  44840. */
  44841. private _computePrimaryColors;
  44842. /**
  44843. * Build the uniform buffer used in the material.
  44844. */
  44845. buildUniformLayout(): void;
  44846. /**
  44847. * Unbind the material.
  44848. */
  44849. unbind(): void;
  44850. /**
  44851. * Bind only the world matrix to the material.
  44852. * @param world The world matrix to bind.
  44853. */
  44854. bindOnlyWorldMatrix(world: Matrix): void;
  44855. /**
  44856. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44857. * @param world The world matrix to bind.
  44858. * @param subMesh The submesh to bind for.
  44859. */
  44860. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44861. /**
  44862. * Dispose the material.
  44863. * @param forceDisposeEffect Force disposal of the associated effect.
  44864. * @param forceDisposeTextures Force disposal of the associated textures.
  44865. */
  44866. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44867. /**
  44868. * Clones the material.
  44869. * @param name The cloned name.
  44870. * @returns The cloned material.
  44871. */
  44872. clone(name: string): BackgroundMaterial;
  44873. /**
  44874. * Serializes the current material to its JSON representation.
  44875. * @returns The JSON representation.
  44876. */
  44877. serialize(): any;
  44878. /**
  44879. * Gets the class name of the material
  44880. * @returns "BackgroundMaterial"
  44881. */
  44882. getClassName(): string;
  44883. /**
  44884. * Parse a JSON input to create back a background material.
  44885. * @param source The JSON data to parse
  44886. * @param scene The scene to create the parsed material in
  44887. * @param rootUrl The root url of the assets the material depends upon
  44888. * @returns the instantiated BackgroundMaterial.
  44889. */
  44890. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44891. }
  44892. }
  44893. declare module "babylonjs/Helpers/environmentHelper" {
  44894. import { Observable } from "babylonjs/Misc/observable";
  44895. import { Nullable } from "babylonjs/types";
  44896. import { Scene } from "babylonjs/scene";
  44897. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44899. import { Mesh } from "babylonjs/Meshes/mesh";
  44900. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44901. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44902. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44903. import "babylonjs/Meshes/Builders/planeBuilder";
  44904. import "babylonjs/Meshes/Builders/boxBuilder";
  44905. /**
  44906. * Represents the different options available during the creation of
  44907. * a Environment helper.
  44908. *
  44909. * This can control the default ground, skybox and image processing setup of your scene.
  44910. */
  44911. export interface IEnvironmentHelperOptions {
  44912. /**
  44913. * Specifies wether or not to create a ground.
  44914. * True by default.
  44915. */
  44916. createGround: boolean;
  44917. /**
  44918. * Specifies the ground size.
  44919. * 15 by default.
  44920. */
  44921. groundSize: number;
  44922. /**
  44923. * The texture used on the ground for the main color.
  44924. * Comes from the BabylonJS CDN by default.
  44925. *
  44926. * Remarks: Can be either a texture or a url.
  44927. */
  44928. groundTexture: string | BaseTexture;
  44929. /**
  44930. * The color mixed in the ground texture by default.
  44931. * BabylonJS clearColor by default.
  44932. */
  44933. groundColor: Color3;
  44934. /**
  44935. * Specifies the ground opacity.
  44936. * 1 by default.
  44937. */
  44938. groundOpacity: number;
  44939. /**
  44940. * Enables the ground to receive shadows.
  44941. * True by default.
  44942. */
  44943. enableGroundShadow: boolean;
  44944. /**
  44945. * Helps preventing the shadow to be fully black on the ground.
  44946. * 0.5 by default.
  44947. */
  44948. groundShadowLevel: number;
  44949. /**
  44950. * Creates a mirror texture attach to the ground.
  44951. * false by default.
  44952. */
  44953. enableGroundMirror: boolean;
  44954. /**
  44955. * Specifies the ground mirror size ratio.
  44956. * 0.3 by default as the default kernel is 64.
  44957. */
  44958. groundMirrorSizeRatio: number;
  44959. /**
  44960. * Specifies the ground mirror blur kernel size.
  44961. * 64 by default.
  44962. */
  44963. groundMirrorBlurKernel: number;
  44964. /**
  44965. * Specifies the ground mirror visibility amount.
  44966. * 1 by default
  44967. */
  44968. groundMirrorAmount: number;
  44969. /**
  44970. * Specifies the ground mirror reflectance weight.
  44971. * This uses the standard weight of the background material to setup the fresnel effect
  44972. * of the mirror.
  44973. * 1 by default.
  44974. */
  44975. groundMirrorFresnelWeight: number;
  44976. /**
  44977. * Specifies the ground mirror Falloff distance.
  44978. * This can helps reducing the size of the reflection.
  44979. * 0 by Default.
  44980. */
  44981. groundMirrorFallOffDistance: number;
  44982. /**
  44983. * Specifies the ground mirror texture type.
  44984. * Unsigned Int by Default.
  44985. */
  44986. groundMirrorTextureType: number;
  44987. /**
  44988. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44989. * the shown objects.
  44990. */
  44991. groundYBias: number;
  44992. /**
  44993. * Specifies wether or not to create a skybox.
  44994. * True by default.
  44995. */
  44996. createSkybox: boolean;
  44997. /**
  44998. * Specifies the skybox size.
  44999. * 20 by default.
  45000. */
  45001. skyboxSize: number;
  45002. /**
  45003. * The texture used on the skybox for the main color.
  45004. * Comes from the BabylonJS CDN by default.
  45005. *
  45006. * Remarks: Can be either a texture or a url.
  45007. */
  45008. skyboxTexture: string | BaseTexture;
  45009. /**
  45010. * The color mixed in the skybox texture by default.
  45011. * BabylonJS clearColor by default.
  45012. */
  45013. skyboxColor: Color3;
  45014. /**
  45015. * The background rotation around the Y axis of the scene.
  45016. * This helps aligning the key lights of your scene with the background.
  45017. * 0 by default.
  45018. */
  45019. backgroundYRotation: number;
  45020. /**
  45021. * Compute automatically the size of the elements to best fit with the scene.
  45022. */
  45023. sizeAuto: boolean;
  45024. /**
  45025. * Default position of the rootMesh if autoSize is not true.
  45026. */
  45027. rootPosition: Vector3;
  45028. /**
  45029. * Sets up the image processing in the scene.
  45030. * true by default.
  45031. */
  45032. setupImageProcessing: boolean;
  45033. /**
  45034. * The texture used as your environment texture in the scene.
  45035. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45036. *
  45037. * Remarks: Can be either a texture or a url.
  45038. */
  45039. environmentTexture: string | BaseTexture;
  45040. /**
  45041. * The value of the exposure to apply to the scene.
  45042. * 0.6 by default if setupImageProcessing is true.
  45043. */
  45044. cameraExposure: number;
  45045. /**
  45046. * The value of the contrast to apply to the scene.
  45047. * 1.6 by default if setupImageProcessing is true.
  45048. */
  45049. cameraContrast: number;
  45050. /**
  45051. * Specifies wether or not tonemapping should be enabled in the scene.
  45052. * true by default if setupImageProcessing is true.
  45053. */
  45054. toneMappingEnabled: boolean;
  45055. }
  45056. /**
  45057. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45058. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45059. * It also helps with the default setup of your imageProcessing configuration.
  45060. */
  45061. export class EnvironmentHelper {
  45062. /**
  45063. * Default ground texture URL.
  45064. */
  45065. private static _groundTextureCDNUrl;
  45066. /**
  45067. * Default skybox texture URL.
  45068. */
  45069. private static _skyboxTextureCDNUrl;
  45070. /**
  45071. * Default environment texture URL.
  45072. */
  45073. private static _environmentTextureCDNUrl;
  45074. /**
  45075. * Creates the default options for the helper.
  45076. */
  45077. private static _getDefaultOptions;
  45078. private _rootMesh;
  45079. /**
  45080. * Gets the root mesh created by the helper.
  45081. */
  45082. readonly rootMesh: Mesh;
  45083. private _skybox;
  45084. /**
  45085. * Gets the skybox created by the helper.
  45086. */
  45087. readonly skybox: Nullable<Mesh>;
  45088. private _skyboxTexture;
  45089. /**
  45090. * Gets the skybox texture created by the helper.
  45091. */
  45092. readonly skyboxTexture: Nullable<BaseTexture>;
  45093. private _skyboxMaterial;
  45094. /**
  45095. * Gets the skybox material created by the helper.
  45096. */
  45097. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45098. private _ground;
  45099. /**
  45100. * Gets the ground mesh created by the helper.
  45101. */
  45102. readonly ground: Nullable<Mesh>;
  45103. private _groundTexture;
  45104. /**
  45105. * Gets the ground texture created by the helper.
  45106. */
  45107. readonly groundTexture: Nullable<BaseTexture>;
  45108. private _groundMirror;
  45109. /**
  45110. * Gets the ground mirror created by the helper.
  45111. */
  45112. readonly groundMirror: Nullable<MirrorTexture>;
  45113. /**
  45114. * Gets the ground mirror render list to helps pushing the meshes
  45115. * you wish in the ground reflection.
  45116. */
  45117. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45118. private _groundMaterial;
  45119. /**
  45120. * Gets the ground material created by the helper.
  45121. */
  45122. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45123. /**
  45124. * Stores the creation options.
  45125. */
  45126. private readonly _scene;
  45127. private _options;
  45128. /**
  45129. * This observable will be notified with any error during the creation of the environment,
  45130. * mainly texture creation errors.
  45131. */
  45132. onErrorObservable: Observable<{
  45133. message?: string;
  45134. exception?: any;
  45135. }>;
  45136. /**
  45137. * constructor
  45138. * @param options Defines the options we want to customize the helper
  45139. * @param scene The scene to add the material to
  45140. */
  45141. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45142. /**
  45143. * Updates the background according to the new options
  45144. * @param options
  45145. */
  45146. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45147. /**
  45148. * Sets the primary color of all the available elements.
  45149. * @param color the main color to affect to the ground and the background
  45150. */
  45151. setMainColor(color: Color3): void;
  45152. /**
  45153. * Setup the image processing according to the specified options.
  45154. */
  45155. private _setupImageProcessing;
  45156. /**
  45157. * Setup the environment texture according to the specified options.
  45158. */
  45159. private _setupEnvironmentTexture;
  45160. /**
  45161. * Setup the background according to the specified options.
  45162. */
  45163. private _setupBackground;
  45164. /**
  45165. * Get the scene sizes according to the setup.
  45166. */
  45167. private _getSceneSize;
  45168. /**
  45169. * Setup the ground according to the specified options.
  45170. */
  45171. private _setupGround;
  45172. /**
  45173. * Setup the ground material according to the specified options.
  45174. */
  45175. private _setupGroundMaterial;
  45176. /**
  45177. * Setup the ground diffuse texture according to the specified options.
  45178. */
  45179. private _setupGroundDiffuseTexture;
  45180. /**
  45181. * Setup the ground mirror texture according to the specified options.
  45182. */
  45183. private _setupGroundMirrorTexture;
  45184. /**
  45185. * Setup the ground to receive the mirror texture.
  45186. */
  45187. private _setupMirrorInGroundMaterial;
  45188. /**
  45189. * Setup the skybox according to the specified options.
  45190. */
  45191. private _setupSkybox;
  45192. /**
  45193. * Setup the skybox material according to the specified options.
  45194. */
  45195. private _setupSkyboxMaterial;
  45196. /**
  45197. * Setup the skybox reflection texture according to the specified options.
  45198. */
  45199. private _setupSkyboxReflectionTexture;
  45200. private _errorHandler;
  45201. /**
  45202. * Dispose all the elements created by the Helper.
  45203. */
  45204. dispose(): void;
  45205. }
  45206. }
  45207. declare module "babylonjs/Helpers/photoDome" {
  45208. import { Observable } from "babylonjs/Misc/observable";
  45209. import { Nullable } from "babylonjs/types";
  45210. import { Scene } from "babylonjs/scene";
  45211. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45212. import { Mesh } from "babylonjs/Meshes/mesh";
  45213. import { Texture } from "babylonjs/Materials/Textures/texture";
  45214. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45215. import "babylonjs/Meshes/Builders/sphereBuilder";
  45216. /**
  45217. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45218. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45219. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45220. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45221. */
  45222. export class PhotoDome extends TransformNode {
  45223. private _useDirectMapping;
  45224. /**
  45225. * The texture being displayed on the sphere
  45226. */
  45227. protected _photoTexture: Texture;
  45228. /**
  45229. * Gets or sets the texture being displayed on the sphere
  45230. */
  45231. photoTexture: Texture;
  45232. /**
  45233. * Observable raised when an error occured while loading the 360 image
  45234. */
  45235. onLoadErrorObservable: Observable<string>;
  45236. /**
  45237. * The skybox material
  45238. */
  45239. protected _material: BackgroundMaterial;
  45240. /**
  45241. * The surface used for the skybox
  45242. */
  45243. protected _mesh: Mesh;
  45244. /**
  45245. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45246. * Also see the options.resolution property.
  45247. */
  45248. fovMultiplier: number;
  45249. /**
  45250. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45251. * @param name Element's name, child elements will append suffixes for their own names.
  45252. * @param urlsOfPhoto defines the url of the photo to display
  45253. * @param options defines an object containing optional or exposed sub element properties
  45254. * @param onError defines a callback called when an error occured while loading the texture
  45255. */
  45256. constructor(name: string, urlOfPhoto: string, options: {
  45257. resolution?: number;
  45258. size?: number;
  45259. useDirectMapping?: boolean;
  45260. faceForward?: boolean;
  45261. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45262. /**
  45263. * Releases resources associated with this node.
  45264. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45265. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45266. */
  45267. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45268. }
  45269. }
  45270. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45271. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45272. /** @hidden */
  45273. export var rgbdDecodePixelShader: {
  45274. name: string;
  45275. shader: string;
  45276. };
  45277. }
  45278. declare module "babylonjs/Misc/brdfTextureTools" {
  45279. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45280. import { Scene } from "babylonjs/scene";
  45281. import "babylonjs/Shaders/rgbdDecode.fragment";
  45282. /**
  45283. * Class used to host texture specific utilities
  45284. */
  45285. export class BRDFTextureTools {
  45286. /**
  45287. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45288. * @param texture the texture to expand.
  45289. */
  45290. private static _ExpandDefaultBRDFTexture;
  45291. /**
  45292. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45293. * @param scene defines the hosting scene
  45294. * @returns the environment BRDF texture
  45295. */
  45296. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45297. private static _environmentBRDFBase64Texture;
  45298. }
  45299. }
  45300. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45301. import { Nullable } from "babylonjs/types";
  45302. import { IAnimatable } from "babylonjs/Misc/tools";
  45303. import { Color3 } from "babylonjs/Maths/math";
  45304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45305. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45306. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45307. import { Engine } from "babylonjs/Engines/engine";
  45308. import { Scene } from "babylonjs/scene";
  45309. /**
  45310. * @hidden
  45311. */
  45312. export interface IMaterialClearCoatDefines {
  45313. CLEARCOAT: boolean;
  45314. CLEARCOAT_DEFAULTIOR: boolean;
  45315. CLEARCOAT_TEXTURE: boolean;
  45316. CLEARCOAT_TEXTUREDIRECTUV: number;
  45317. CLEARCOAT_BUMP: boolean;
  45318. CLEARCOAT_BUMPDIRECTUV: number;
  45319. CLEARCOAT_TINT: boolean;
  45320. CLEARCOAT_TINT_TEXTURE: boolean;
  45321. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45322. /** @hidden */
  45323. _areTexturesDirty: boolean;
  45324. }
  45325. /**
  45326. * Define the code related to the clear coat parameters of the pbr material.
  45327. */
  45328. export class PBRClearCoatConfiguration {
  45329. /**
  45330. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45331. * The default fits with a polyurethane material.
  45332. */
  45333. private static readonly _DefaultIndiceOfRefraction;
  45334. private _isEnabled;
  45335. /**
  45336. * Defines if the clear coat is enabled in the material.
  45337. */
  45338. isEnabled: boolean;
  45339. /**
  45340. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45341. */
  45342. intensity: number;
  45343. /**
  45344. * Defines the clear coat layer roughness.
  45345. */
  45346. roughness: number;
  45347. private _indiceOfRefraction;
  45348. /**
  45349. * Defines the indice of refraction of the clear coat.
  45350. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45351. * The default fits with a polyurethane material.
  45352. * Changing the default value is more performance intensive.
  45353. */
  45354. indiceOfRefraction: number;
  45355. private _texture;
  45356. /**
  45357. * Stores the clear coat values in a texture.
  45358. */
  45359. texture: Nullable<BaseTexture>;
  45360. private _bumpTexture;
  45361. /**
  45362. * Define the clear coat specific bump texture.
  45363. */
  45364. bumpTexture: Nullable<BaseTexture>;
  45365. private _isTintEnabled;
  45366. /**
  45367. * Defines if the clear coat tint is enabled in the material.
  45368. */
  45369. isTintEnabled: boolean;
  45370. /**
  45371. * Defines the clear coat tint of the material.
  45372. * This is only use if tint is enabled
  45373. */
  45374. tintColor: Color3;
  45375. /**
  45376. * Defines the distance at which the tint color should be found in the
  45377. * clear coat media.
  45378. * This is only use if tint is enabled
  45379. */
  45380. tintColorAtDistance: number;
  45381. /**
  45382. * Defines the clear coat layer thickness.
  45383. * This is only use if tint is enabled
  45384. */
  45385. tintThickness: number;
  45386. private _tintTexture;
  45387. /**
  45388. * Stores the clear tint values in a texture.
  45389. * rgb is tint
  45390. * a is a thickness factor
  45391. */
  45392. tintTexture: Nullable<BaseTexture>;
  45393. /** @hidden */
  45394. private _internalMarkAllSubMeshesAsTexturesDirty;
  45395. /** @hidden */
  45396. _markAllSubMeshesAsTexturesDirty(): void;
  45397. /**
  45398. * Instantiate a new istance of clear coat configuration.
  45399. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45400. */
  45401. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45402. /**
  45403. * Gets wehter the submesh is ready to be used or not.
  45404. * @param defines the list of "defines" to update.
  45405. * @param scene defines the scene the material belongs to.
  45406. * @param engine defines the engine the material belongs to.
  45407. * @param disableBumpMap defines wether the material disables bump or not.
  45408. * @returns - boolean indicating that the submesh is ready or not.
  45409. */
  45410. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45411. /**
  45412. * Checks to see if a texture is used in the material.
  45413. * @param defines the list of "defines" to update.
  45414. * @param scene defines the scene to the material belongs to.
  45415. */
  45416. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45417. /**
  45418. * Binds the material data.
  45419. * @param uniformBuffer defines the Uniform buffer to fill in.
  45420. * @param scene defines the scene the material belongs to.
  45421. * @param engine defines the engine the material belongs to.
  45422. * @param disableBumpMap defines wether the material disables bump or not.
  45423. * @param isFrozen defines wether the material is frozen or not.
  45424. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45425. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45426. */
  45427. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45428. /**
  45429. * Checks to see if a texture is used in the material.
  45430. * @param texture - Base texture to use.
  45431. * @returns - Boolean specifying if a texture is used in the material.
  45432. */
  45433. hasTexture(texture: BaseTexture): boolean;
  45434. /**
  45435. * Returns an array of the actively used textures.
  45436. * @param activeTextures Array of BaseTextures
  45437. */
  45438. getActiveTextures(activeTextures: BaseTexture[]): void;
  45439. /**
  45440. * Returns the animatable textures.
  45441. * @param animatables Array of animatable textures.
  45442. */
  45443. getAnimatables(animatables: IAnimatable[]): void;
  45444. /**
  45445. * Disposes the resources of the material.
  45446. * @param forceDisposeTextures - Forces the disposal of all textures.
  45447. */
  45448. dispose(forceDisposeTextures?: boolean): void;
  45449. /**
  45450. * Get the current class name of the texture useful for serialization or dynamic coding.
  45451. * @returns "PBRClearCoatConfiguration"
  45452. */
  45453. getClassName(): string;
  45454. /**
  45455. * Add fallbacks to the effect fallbacks list.
  45456. * @param defines defines the Base texture to use.
  45457. * @param fallbacks defines the current fallback list.
  45458. * @param currentRank defines the current fallback rank.
  45459. * @returns the new fallback rank.
  45460. */
  45461. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45462. /**
  45463. * Add the required uniforms to the current list.
  45464. * @param uniforms defines the current uniform list.
  45465. */
  45466. static AddUniforms(uniforms: string[]): void;
  45467. /**
  45468. * Add the required samplers to the current list.
  45469. * @param samplers defines the current sampler list.
  45470. */
  45471. static AddSamplers(samplers: string[]): void;
  45472. /**
  45473. * Add the required uniforms to the current buffer.
  45474. * @param uniformBuffer defines the current uniform buffer.
  45475. */
  45476. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45477. /**
  45478. * Makes a duplicate of the current configuration into another one.
  45479. * @param clearCoatConfiguration define the config where to copy the info
  45480. */
  45481. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45482. /**
  45483. * Serializes this clear coat configuration.
  45484. * @returns - An object with the serialized config.
  45485. */
  45486. serialize(): any;
  45487. /**
  45488. * Parses a Clear Coat Configuration from a serialized object.
  45489. * @param source - Serialized object.
  45490. */
  45491. parse(source: any): void;
  45492. }
  45493. }
  45494. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45495. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45496. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45498. import { Vector2 } from "babylonjs/Maths/math";
  45499. import { Scene } from "babylonjs/scene";
  45500. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45501. import { IAnimatable } from "babylonjs/Misc/tools";
  45502. import { Nullable } from "babylonjs/types";
  45503. /**
  45504. * @hidden
  45505. */
  45506. export interface IMaterialAnisotropicDefines {
  45507. ANISOTROPIC: boolean;
  45508. ANISOTROPIC_TEXTURE: boolean;
  45509. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45510. MAINUV1: boolean;
  45511. _areTexturesDirty: boolean;
  45512. _needUVs: boolean;
  45513. }
  45514. /**
  45515. * Define the code related to the anisotropic parameters of the pbr material.
  45516. */
  45517. export class PBRAnisotropicConfiguration {
  45518. private _isEnabled;
  45519. /**
  45520. * Defines if the anisotropy is enabled in the material.
  45521. */
  45522. isEnabled: boolean;
  45523. /**
  45524. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45525. */
  45526. intensity: number;
  45527. /**
  45528. * Defines if the effect is along the tangents, bitangents or in between.
  45529. * By default, the effect is "strectching" the highlights along the tangents.
  45530. */
  45531. direction: Vector2;
  45532. private _texture;
  45533. /**
  45534. * Stores the anisotropy values in a texture.
  45535. * rg is direction (like normal from -1 to 1)
  45536. * b is a intensity
  45537. */
  45538. texture: Nullable<BaseTexture>;
  45539. /** @hidden */
  45540. private _internalMarkAllSubMeshesAsTexturesDirty;
  45541. /** @hidden */
  45542. _markAllSubMeshesAsTexturesDirty(): void;
  45543. /**
  45544. * Instantiate a new istance of anisotropy configuration.
  45545. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45546. */
  45547. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45548. /**
  45549. * Specifies that the submesh is ready to be used.
  45550. * @param defines the list of "defines" to update.
  45551. * @param scene defines the scene the material belongs to.
  45552. * @returns - boolean indicating that the submesh is ready or not.
  45553. */
  45554. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45555. /**
  45556. * Checks to see if a texture is used in the material.
  45557. * @param defines the list of "defines" to update.
  45558. * @param mesh the mesh we are preparing the defines for.
  45559. * @param scene defines the scene the material belongs to.
  45560. */
  45561. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45562. /**
  45563. * Binds the material data.
  45564. * @param uniformBuffer defines the Uniform buffer to fill in.
  45565. * @param scene defines the scene the material belongs to.
  45566. * @param isFrozen defines wether the material is frozen or not.
  45567. */
  45568. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45569. /**
  45570. * Checks to see if a texture is used in the material.
  45571. * @param texture - Base texture to use.
  45572. * @returns - Boolean specifying if a texture is used in the material.
  45573. */
  45574. hasTexture(texture: BaseTexture): boolean;
  45575. /**
  45576. * Returns an array of the actively used textures.
  45577. * @param activeTextures Array of BaseTextures
  45578. */
  45579. getActiveTextures(activeTextures: BaseTexture[]): void;
  45580. /**
  45581. * Returns the animatable textures.
  45582. * @param animatables Array of animatable textures.
  45583. */
  45584. getAnimatables(animatables: IAnimatable[]): void;
  45585. /**
  45586. * Disposes the resources of the material.
  45587. * @param forceDisposeTextures - Forces the disposal of all textures.
  45588. */
  45589. dispose(forceDisposeTextures?: boolean): void;
  45590. /**
  45591. * Get the current class name of the texture useful for serialization or dynamic coding.
  45592. * @returns "PBRAnisotropicConfiguration"
  45593. */
  45594. getClassName(): string;
  45595. /**
  45596. * Add fallbacks to the effect fallbacks list.
  45597. * @param defines defines the Base texture to use.
  45598. * @param fallbacks defines the current fallback list.
  45599. * @param currentRank defines the current fallback rank.
  45600. * @returns the new fallback rank.
  45601. */
  45602. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45603. /**
  45604. * Add the required uniforms to the current list.
  45605. * @param uniforms defines the current uniform list.
  45606. */
  45607. static AddUniforms(uniforms: string[]): void;
  45608. /**
  45609. * Add the required uniforms to the current buffer.
  45610. * @param uniformBuffer defines the current uniform buffer.
  45611. */
  45612. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45613. /**
  45614. * Add the required samplers to the current list.
  45615. * @param samplers defines the current sampler list.
  45616. */
  45617. static AddSamplers(samplers: string[]): void;
  45618. /**
  45619. * Makes a duplicate of the current configuration into another one.
  45620. * @param anisotropicConfiguration define the config where to copy the info
  45621. */
  45622. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45623. /**
  45624. * Serializes this anisotropy configuration.
  45625. * @returns - An object with the serialized config.
  45626. */
  45627. serialize(): any;
  45628. /**
  45629. * Parses a anisotropy Configuration from a serialized object.
  45630. * @param source - Serialized object.
  45631. */
  45632. parse(source: any): void;
  45633. }
  45634. }
  45635. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45636. /**
  45637. * @hidden
  45638. */
  45639. export interface IMaterialBRDFDefines {
  45640. BRDF_V_HEIGHT_CORRELATED: boolean;
  45641. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45642. /** @hidden */
  45643. _areMiscDirty: boolean;
  45644. }
  45645. /**
  45646. * Define the code related to the BRDF parameters of the pbr material.
  45647. */
  45648. export class PBRBRDFConfiguration {
  45649. /**
  45650. * Default value used for the energy conservation.
  45651. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45652. */
  45653. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45654. /**
  45655. * Default value used for the Smith Visibility Height Correlated mode.
  45656. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45657. */
  45658. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45659. private _useEnergyConservation;
  45660. /**
  45661. * Defines if the material uses energy conservation.
  45662. */
  45663. useEnergyConservation: boolean;
  45664. private _useSmithVisibilityHeightCorrelated;
  45665. /**
  45666. * LEGACY Mode set to false
  45667. * Defines if the material uses height smith correlated visibility term.
  45668. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45669. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45670. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45671. * Not relying on height correlated will also disable energy conservation.
  45672. */
  45673. useSmithVisibilityHeightCorrelated: boolean;
  45674. /** @hidden */
  45675. private _internalMarkAllSubMeshesAsMiscDirty;
  45676. /** @hidden */
  45677. _markAllSubMeshesAsMiscDirty(): void;
  45678. /**
  45679. * Instantiate a new istance of clear coat configuration.
  45680. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45681. */
  45682. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45683. /**
  45684. * Checks to see if a texture is used in the material.
  45685. * @param defines the list of "defines" to update.
  45686. */
  45687. prepareDefines(defines: IMaterialBRDFDefines): void;
  45688. /**
  45689. * Get the current class name of the texture useful for serialization or dynamic coding.
  45690. * @returns "PBRClearCoatConfiguration"
  45691. */
  45692. getClassName(): string;
  45693. /**
  45694. * Makes a duplicate of the current configuration into another one.
  45695. * @param brdfConfiguration define the config where to copy the info
  45696. */
  45697. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45698. /**
  45699. * Serializes this BRDF configuration.
  45700. * @returns - An object with the serialized config.
  45701. */
  45702. serialize(): any;
  45703. /**
  45704. * Parses a BRDF Configuration from a serialized object.
  45705. * @param source - Serialized object.
  45706. */
  45707. parse(source: any): void;
  45708. }
  45709. }
  45710. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45711. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45712. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45713. import { Color3 } from "babylonjs/Maths/math";
  45714. import { Scene } from "babylonjs/scene";
  45715. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45716. import { IAnimatable } from "babylonjs/Misc/tools";
  45717. import { Nullable } from "babylonjs/types";
  45718. /**
  45719. * @hidden
  45720. */
  45721. export interface IMaterialSheenDefines {
  45722. SHEEN: boolean;
  45723. SHEEN_TEXTURE: boolean;
  45724. SHEEN_TEXTUREDIRECTUV: number;
  45725. SHEEN_LINKWITHALBEDO: boolean;
  45726. /** @hidden */
  45727. _areTexturesDirty: boolean;
  45728. }
  45729. /**
  45730. * Define the code related to the Sheen parameters of the pbr material.
  45731. */
  45732. export class PBRSheenConfiguration {
  45733. private _isEnabled;
  45734. /**
  45735. * Defines if the material uses sheen.
  45736. */
  45737. isEnabled: boolean;
  45738. private _linkSheenWithAlbedo;
  45739. /**
  45740. * Defines if the sheen is linked to the sheen color.
  45741. */
  45742. linkSheenWithAlbedo: boolean;
  45743. /**
  45744. * Defines the sheen intensity.
  45745. */
  45746. intensity: number;
  45747. /**
  45748. * Defines the sheen color.
  45749. */
  45750. color: Color3;
  45751. private _texture;
  45752. /**
  45753. * Stores the sheen tint values in a texture.
  45754. * rgb is tint
  45755. * a is a intensity
  45756. */
  45757. texture: Nullable<BaseTexture>;
  45758. /** @hidden */
  45759. private _internalMarkAllSubMeshesAsTexturesDirty;
  45760. /** @hidden */
  45761. _markAllSubMeshesAsTexturesDirty(): void;
  45762. /**
  45763. * Instantiate a new istance of clear coat configuration.
  45764. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45765. */
  45766. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45767. /**
  45768. * Specifies that the submesh is ready to be used.
  45769. * @param defines the list of "defines" to update.
  45770. * @param scene defines the scene the material belongs to.
  45771. * @returns - boolean indicating that the submesh is ready or not.
  45772. */
  45773. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45774. /**
  45775. * Checks to see if a texture is used in the material.
  45776. * @param defines the list of "defines" to update.
  45777. * @param scene defines the scene the material belongs to.
  45778. */
  45779. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45780. /**
  45781. * Binds the material data.
  45782. * @param uniformBuffer defines the Uniform buffer to fill in.
  45783. * @param scene defines the scene the material belongs to.
  45784. * @param isFrozen defines wether the material is frozen or not.
  45785. */
  45786. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45787. /**
  45788. * Checks to see if a texture is used in the material.
  45789. * @param texture - Base texture to use.
  45790. * @returns - Boolean specifying if a texture is used in the material.
  45791. */
  45792. hasTexture(texture: BaseTexture): boolean;
  45793. /**
  45794. * Returns an array of the actively used textures.
  45795. * @param activeTextures Array of BaseTextures
  45796. */
  45797. getActiveTextures(activeTextures: BaseTexture[]): void;
  45798. /**
  45799. * Returns the animatable textures.
  45800. * @param animatables Array of animatable textures.
  45801. */
  45802. getAnimatables(animatables: IAnimatable[]): void;
  45803. /**
  45804. * Disposes the resources of the material.
  45805. * @param forceDisposeTextures - Forces the disposal of all textures.
  45806. */
  45807. dispose(forceDisposeTextures?: boolean): void;
  45808. /**
  45809. * Get the current class name of the texture useful for serialization or dynamic coding.
  45810. * @returns "PBRSheenConfiguration"
  45811. */
  45812. getClassName(): string;
  45813. /**
  45814. * Add fallbacks to the effect fallbacks list.
  45815. * @param defines defines the Base texture to use.
  45816. * @param fallbacks defines the current fallback list.
  45817. * @param currentRank defines the current fallback rank.
  45818. * @returns the new fallback rank.
  45819. */
  45820. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45821. /**
  45822. * Add the required uniforms to the current list.
  45823. * @param uniforms defines the current uniform list.
  45824. */
  45825. static AddUniforms(uniforms: string[]): void;
  45826. /**
  45827. * Add the required uniforms to the current buffer.
  45828. * @param uniformBuffer defines the current uniform buffer.
  45829. */
  45830. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45831. /**
  45832. * Add the required samplers to the current list.
  45833. * @param samplers defines the current sampler list.
  45834. */
  45835. static AddSamplers(samplers: string[]): void;
  45836. /**
  45837. * Makes a duplicate of the current configuration into another one.
  45838. * @param sheenConfiguration define the config where to copy the info
  45839. */
  45840. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45841. /**
  45842. * Serializes this BRDF configuration.
  45843. * @returns - An object with the serialized config.
  45844. */
  45845. serialize(): any;
  45846. /**
  45847. * Parses a Sheen Configuration from a serialized object.
  45848. * @param source - Serialized object.
  45849. */
  45850. parse(source: any): void;
  45851. }
  45852. }
  45853. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  45854. import { Nullable } from "babylonjs/types";
  45855. import { IAnimatable } from "babylonjs/Misc/tools";
  45856. import { Color3 } from "babylonjs/Maths/math";
  45857. import { SmartArray } from "babylonjs/Misc/smartArray";
  45858. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45859. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45860. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  45861. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45862. import { Engine } from "babylonjs/Engines/engine";
  45863. import { Scene } from "babylonjs/scene";
  45864. /**
  45865. * @hidden
  45866. */
  45867. export interface IMaterialSubSurfaceDefines {
  45868. SUBSURFACE: boolean;
  45869. SS_REFRACTION: boolean;
  45870. SS_TRANSLUCENCY: boolean;
  45871. SS_SCATERRING: boolean;
  45872. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45873. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45874. SS_REFRACTIONMAP_3D: boolean;
  45875. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45876. SS_LODINREFRACTIONALPHA: boolean;
  45877. SS_GAMMAREFRACTION: boolean;
  45878. SS_RGBDREFRACTION: boolean;
  45879. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45880. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45881. /** @hidden */
  45882. _areTexturesDirty: boolean;
  45883. }
  45884. /**
  45885. * Define the code related to the sub surface parameters of the pbr material.
  45886. */
  45887. export class PBRSubSurfaceConfiguration {
  45888. private _isRefractionEnabled;
  45889. /**
  45890. * Defines if the refraction is enabled in the material.
  45891. */
  45892. isRefractionEnabled: boolean;
  45893. private _isTranslucencyEnabled;
  45894. /**
  45895. * Defines if the translucency is enabled in the material.
  45896. */
  45897. isTranslucencyEnabled: boolean;
  45898. private _isScatteringEnabled;
  45899. /**
  45900. * Defines the refraction intensity of the material.
  45901. * The refraction when enabled replaces the Diffuse part of the material.
  45902. * The intensity helps transitionning between diffuse and refraction.
  45903. */
  45904. refractionIntensity: number;
  45905. /**
  45906. * Defines the translucency intensity of the material.
  45907. * When translucency has been enabled, this defines how much of the "translucency"
  45908. * is addded to the diffuse part of the material.
  45909. */
  45910. translucencyIntensity: number;
  45911. /**
  45912. * Defines the scattering intensity of the material.
  45913. * When scattering has been enabled, this defines how much of the "scattered light"
  45914. * is addded to the diffuse part of the material.
  45915. */
  45916. scatteringIntensity: number;
  45917. private _thicknessTexture;
  45918. /**
  45919. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45920. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45921. * 0 would mean minimumThickness
  45922. * 1 would mean maximumThickness
  45923. * The other channels might be use as a mask to vary the different effects intensity.
  45924. */
  45925. thicknessTexture: Nullable<BaseTexture>;
  45926. private _refractionTexture;
  45927. /**
  45928. * Defines the texture to use for refraction.
  45929. */
  45930. refractionTexture: Nullable<BaseTexture>;
  45931. private _indexOfRefraction;
  45932. /**
  45933. * Defines the indice of refraction used in the material.
  45934. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45935. */
  45936. indexOfRefraction: number;
  45937. private _invertRefractionY;
  45938. /**
  45939. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45940. */
  45941. invertRefractionY: boolean;
  45942. private _linkRefractionWithTransparency;
  45943. /**
  45944. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45945. * Materials half opaque for instance using refraction could benefit from this control.
  45946. */
  45947. linkRefractionWithTransparency: boolean;
  45948. /**
  45949. * Defines the minimum thickness stored in the thickness map.
  45950. * If no thickness map is defined, this value will be used to simulate thickness.
  45951. */
  45952. minimumThickness: number;
  45953. /**
  45954. * Defines the maximum thickness stored in the thickness map.
  45955. */
  45956. maximumThickness: number;
  45957. /**
  45958. * Defines the volume tint of the material.
  45959. * This is used for both translucency and scattering.
  45960. */
  45961. tintColor: Color3;
  45962. /**
  45963. * Defines the distance at which the tint color should be found in the media.
  45964. * This is used for refraction only.
  45965. */
  45966. tintColorAtDistance: number;
  45967. /**
  45968. * Defines how far each channel transmit through the media.
  45969. * It is defined as a color to simplify it selection.
  45970. */
  45971. diffusionDistance: Color3;
  45972. private _useMaskFromThicknessTexture;
  45973. /**
  45974. * Stores the intensity of the different subsurface effects in the thickness texture.
  45975. * * the green channel is the translucency intensity.
  45976. * * the blue channel is the scattering intensity.
  45977. * * the alpha channel is the refraction intensity.
  45978. */
  45979. useMaskFromThicknessTexture: boolean;
  45980. /** @hidden */
  45981. private _internalMarkAllSubMeshesAsTexturesDirty;
  45982. /** @hidden */
  45983. _markAllSubMeshesAsTexturesDirty(): void;
  45984. /**
  45985. * Instantiate a new istance of sub surface configuration.
  45986. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45987. */
  45988. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45989. /**
  45990. * Gets wehter the submesh is ready to be used or not.
  45991. * @param defines the list of "defines" to update.
  45992. * @param scene defines the scene the material belongs to.
  45993. * @returns - boolean indicating that the submesh is ready or not.
  45994. */
  45995. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45996. /**
  45997. * Checks to see if a texture is used in the material.
  45998. * @param defines the list of "defines" to update.
  45999. * @param scene defines the scene to the material belongs to.
  46000. */
  46001. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46002. /**
  46003. * Binds the material data.
  46004. * @param uniformBuffer defines the Uniform buffer to fill in.
  46005. * @param scene defines the scene the material belongs to.
  46006. * @param engine defines the engine the material belongs to.
  46007. * @param isFrozen defines wether the material is frozen or not.
  46008. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46009. */
  46010. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46011. /**
  46012. * Unbinds the material from the mesh.
  46013. * @param activeEffect defines the effect that should be unbound from.
  46014. * @returns true if unbound, otherwise false
  46015. */
  46016. unbind(activeEffect: Effect): boolean;
  46017. /**
  46018. * Returns the texture used for refraction or null if none is used.
  46019. * @param scene defines the scene the material belongs to.
  46020. * @returns - Refraction texture if present. If no refraction texture and refraction
  46021. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46022. */
  46023. private _getRefractionTexture;
  46024. /**
  46025. * Returns true if alpha blending should be disabled.
  46026. */
  46027. readonly disableAlphaBlending: boolean;
  46028. /**
  46029. * Fills the list of render target textures.
  46030. * @param renderTargets the list of render targets to update
  46031. */
  46032. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46033. /**
  46034. * Checks to see if a texture is used in the material.
  46035. * @param texture - Base texture to use.
  46036. * @returns - Boolean specifying if a texture is used in the material.
  46037. */
  46038. hasTexture(texture: BaseTexture): boolean;
  46039. /**
  46040. * Gets a boolean indicating that current material needs to register RTT
  46041. * @returns true if this uses a render target otherwise false.
  46042. */
  46043. hasRenderTargetTextures(): boolean;
  46044. /**
  46045. * Returns an array of the actively used textures.
  46046. * @param activeTextures Array of BaseTextures
  46047. */
  46048. getActiveTextures(activeTextures: BaseTexture[]): void;
  46049. /**
  46050. * Returns the animatable textures.
  46051. * @param animatables Array of animatable textures.
  46052. */
  46053. getAnimatables(animatables: IAnimatable[]): void;
  46054. /**
  46055. * Disposes the resources of the material.
  46056. * @param forceDisposeTextures - Forces the disposal of all textures.
  46057. */
  46058. dispose(forceDisposeTextures?: boolean): void;
  46059. /**
  46060. * Get the current class name of the texture useful for serialization or dynamic coding.
  46061. * @returns "PBRSubSurfaceConfiguration"
  46062. */
  46063. getClassName(): string;
  46064. /**
  46065. * Add fallbacks to the effect fallbacks list.
  46066. * @param defines defines the Base texture to use.
  46067. * @param fallbacks defines the current fallback list.
  46068. * @param currentRank defines the current fallback rank.
  46069. * @returns the new fallback rank.
  46070. */
  46071. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46072. /**
  46073. * Add the required uniforms to the current list.
  46074. * @param uniforms defines the current uniform list.
  46075. */
  46076. static AddUniforms(uniforms: string[]): void;
  46077. /**
  46078. * Add the required samplers to the current list.
  46079. * @param samplers defines the current sampler list.
  46080. */
  46081. static AddSamplers(samplers: string[]): void;
  46082. /**
  46083. * Add the required uniforms to the current buffer.
  46084. * @param uniformBuffer defines the current uniform buffer.
  46085. */
  46086. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46087. /**
  46088. * Makes a duplicate of the current configuration into another one.
  46089. * @param configuration define the config where to copy the info
  46090. */
  46091. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46092. /**
  46093. * Serializes this Sub Surface configuration.
  46094. * @returns - An object with the serialized config.
  46095. */
  46096. serialize(): any;
  46097. /**
  46098. * Parses a Sub Surface Configuration from a serialized object.
  46099. * @param source - Serialized object.
  46100. */
  46101. parse(source: any): void;
  46102. }
  46103. }
  46104. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46105. /** @hidden */
  46106. export var pbrFragmentDeclaration: {
  46107. name: string;
  46108. shader: string;
  46109. };
  46110. }
  46111. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46112. /** @hidden */
  46113. export var pbrUboDeclaration: {
  46114. name: string;
  46115. shader: string;
  46116. };
  46117. }
  46118. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46119. /** @hidden */
  46120. export var pbrFragmentExtraDeclaration: {
  46121. name: string;
  46122. shader: string;
  46123. };
  46124. }
  46125. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46126. /** @hidden */
  46127. export var pbrFragmentSamplersDeclaration: {
  46128. name: string;
  46129. shader: string;
  46130. };
  46131. }
  46132. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46133. /** @hidden */
  46134. export var pbrHelperFunctions: {
  46135. name: string;
  46136. shader: string;
  46137. };
  46138. }
  46139. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46140. /** @hidden */
  46141. export var harmonicsFunctions: {
  46142. name: string;
  46143. shader: string;
  46144. };
  46145. }
  46146. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46147. /** @hidden */
  46148. export var pbrDirectLightingSetupFunctions: {
  46149. name: string;
  46150. shader: string;
  46151. };
  46152. }
  46153. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46154. /** @hidden */
  46155. export var pbrDirectLightingFalloffFunctions: {
  46156. name: string;
  46157. shader: string;
  46158. };
  46159. }
  46160. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46161. /** @hidden */
  46162. export var pbrBRDFFunctions: {
  46163. name: string;
  46164. shader: string;
  46165. };
  46166. }
  46167. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46168. /** @hidden */
  46169. export var pbrDirectLightingFunctions: {
  46170. name: string;
  46171. shader: string;
  46172. };
  46173. }
  46174. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46175. /** @hidden */
  46176. export var pbrIBLFunctions: {
  46177. name: string;
  46178. shader: string;
  46179. };
  46180. }
  46181. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46182. /** @hidden */
  46183. export var pbrDebug: {
  46184. name: string;
  46185. shader: string;
  46186. };
  46187. }
  46188. declare module "babylonjs/Shaders/pbr.fragment" {
  46189. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46190. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46191. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46192. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46193. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46194. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46195. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46196. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46197. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46198. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46199. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46200. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46201. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46202. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46203. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46204. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46205. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46206. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46207. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46208. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46209. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46210. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46211. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46212. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46213. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46214. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46215. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46216. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46217. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46218. /** @hidden */
  46219. export var pbrPixelShader: {
  46220. name: string;
  46221. shader: string;
  46222. };
  46223. }
  46224. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46225. /** @hidden */
  46226. export var pbrVertexDeclaration: {
  46227. name: string;
  46228. shader: string;
  46229. };
  46230. }
  46231. declare module "babylonjs/Shaders/pbr.vertex" {
  46232. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46233. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46234. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46235. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46236. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46237. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46238. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46239. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46240. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46241. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46242. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46243. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46244. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46245. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46246. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46247. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46248. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46249. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46250. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46251. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46252. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46253. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46254. /** @hidden */
  46255. export var pbrVertexShader: {
  46256. name: string;
  46257. shader: string;
  46258. };
  46259. }
  46260. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46261. import { IAnimatable } from "babylonjs/Misc/tools";
  46262. import { Nullable } from "babylonjs/types";
  46263. import { Scene } from "babylonjs/scene";
  46264. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46265. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46267. import { Mesh } from "babylonjs/Meshes/mesh";
  46268. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46269. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46270. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46271. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46272. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46273. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46274. import { Material } from "babylonjs/Materials/material";
  46275. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46276. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46277. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46278. import "babylonjs/Shaders/pbr.fragment";
  46279. import "babylonjs/Shaders/pbr.vertex";
  46280. /**
  46281. * Manages the defines for the PBR Material.
  46282. * @hidden
  46283. */
  46284. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46285. PBR: boolean;
  46286. MAINUV1: boolean;
  46287. MAINUV2: boolean;
  46288. UV1: boolean;
  46289. UV2: boolean;
  46290. ALBEDO: boolean;
  46291. ALBEDODIRECTUV: number;
  46292. VERTEXCOLOR: boolean;
  46293. AMBIENT: boolean;
  46294. AMBIENTDIRECTUV: number;
  46295. AMBIENTINGRAYSCALE: boolean;
  46296. OPACITY: boolean;
  46297. VERTEXALPHA: boolean;
  46298. OPACITYDIRECTUV: number;
  46299. OPACITYRGB: boolean;
  46300. ALPHATEST: boolean;
  46301. DEPTHPREPASS: boolean;
  46302. ALPHABLEND: boolean;
  46303. ALPHAFROMALBEDO: boolean;
  46304. ALPHATESTVALUE: string;
  46305. SPECULAROVERALPHA: boolean;
  46306. RADIANCEOVERALPHA: boolean;
  46307. ALPHAFRESNEL: boolean;
  46308. LINEARALPHAFRESNEL: boolean;
  46309. PREMULTIPLYALPHA: boolean;
  46310. EMISSIVE: boolean;
  46311. EMISSIVEDIRECTUV: number;
  46312. REFLECTIVITY: boolean;
  46313. REFLECTIVITYDIRECTUV: number;
  46314. SPECULARTERM: boolean;
  46315. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46316. MICROSURFACEAUTOMATIC: boolean;
  46317. LODBASEDMICROSFURACE: boolean;
  46318. MICROSURFACEMAP: boolean;
  46319. MICROSURFACEMAPDIRECTUV: number;
  46320. METALLICWORKFLOW: boolean;
  46321. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46322. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46323. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46324. AOSTOREINMETALMAPRED: boolean;
  46325. ENVIRONMENTBRDF: boolean;
  46326. ENVIRONMENTBRDF_RGBD: boolean;
  46327. NORMAL: boolean;
  46328. TANGENT: boolean;
  46329. BUMP: boolean;
  46330. BUMPDIRECTUV: number;
  46331. OBJECTSPACE_NORMALMAP: boolean;
  46332. PARALLAX: boolean;
  46333. PARALLAXOCCLUSION: boolean;
  46334. NORMALXYSCALE: boolean;
  46335. LIGHTMAP: boolean;
  46336. LIGHTMAPDIRECTUV: number;
  46337. USELIGHTMAPASSHADOWMAP: boolean;
  46338. GAMMALIGHTMAP: boolean;
  46339. REFLECTION: boolean;
  46340. REFLECTIONMAP_3D: boolean;
  46341. REFLECTIONMAP_SPHERICAL: boolean;
  46342. REFLECTIONMAP_PLANAR: boolean;
  46343. REFLECTIONMAP_CUBIC: boolean;
  46344. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46345. REFLECTIONMAP_PROJECTION: boolean;
  46346. REFLECTIONMAP_SKYBOX: boolean;
  46347. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46348. REFLECTIONMAP_EXPLICIT: boolean;
  46349. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46350. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46351. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46352. INVERTCUBICMAP: boolean;
  46353. USESPHERICALFROMREFLECTIONMAP: boolean;
  46354. USESPHERICALINVERTEX: boolean;
  46355. REFLECTIONMAP_OPPOSITEZ: boolean;
  46356. LODINREFLECTIONALPHA: boolean;
  46357. GAMMAREFLECTION: boolean;
  46358. RGBDREFLECTION: boolean;
  46359. RADIANCEOCCLUSION: boolean;
  46360. HORIZONOCCLUSION: boolean;
  46361. INSTANCES: boolean;
  46362. NUM_BONE_INFLUENCERS: number;
  46363. BonesPerMesh: number;
  46364. BONETEXTURE: boolean;
  46365. NONUNIFORMSCALING: boolean;
  46366. MORPHTARGETS: boolean;
  46367. MORPHTARGETS_NORMAL: boolean;
  46368. MORPHTARGETS_TANGENT: boolean;
  46369. NUM_MORPH_INFLUENCERS: number;
  46370. IMAGEPROCESSING: boolean;
  46371. VIGNETTE: boolean;
  46372. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46373. VIGNETTEBLENDMODEOPAQUE: boolean;
  46374. TONEMAPPING: boolean;
  46375. TONEMAPPING_ACES: boolean;
  46376. CONTRAST: boolean;
  46377. COLORCURVES: boolean;
  46378. COLORGRADING: boolean;
  46379. COLORGRADING3D: boolean;
  46380. SAMPLER3DGREENDEPTH: boolean;
  46381. SAMPLER3DBGRMAP: boolean;
  46382. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46383. EXPOSURE: boolean;
  46384. MULTIVIEW: boolean;
  46385. USEPHYSICALLIGHTFALLOFF: boolean;
  46386. USEGLTFLIGHTFALLOFF: boolean;
  46387. TWOSIDEDLIGHTING: boolean;
  46388. SHADOWFLOAT: boolean;
  46389. CLIPPLANE: boolean;
  46390. CLIPPLANE2: boolean;
  46391. CLIPPLANE3: boolean;
  46392. CLIPPLANE4: boolean;
  46393. POINTSIZE: boolean;
  46394. FOG: boolean;
  46395. LOGARITHMICDEPTH: boolean;
  46396. FORCENORMALFORWARD: boolean;
  46397. SPECULARAA: boolean;
  46398. CLEARCOAT: boolean;
  46399. CLEARCOAT_DEFAULTIOR: boolean;
  46400. CLEARCOAT_TEXTURE: boolean;
  46401. CLEARCOAT_TEXTUREDIRECTUV: number;
  46402. CLEARCOAT_BUMP: boolean;
  46403. CLEARCOAT_BUMPDIRECTUV: number;
  46404. CLEARCOAT_TINT: boolean;
  46405. CLEARCOAT_TINT_TEXTURE: boolean;
  46406. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46407. ANISOTROPIC: boolean;
  46408. ANISOTROPIC_TEXTURE: boolean;
  46409. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46410. BRDF_V_HEIGHT_CORRELATED: boolean;
  46411. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46412. SHEEN: boolean;
  46413. SHEEN_TEXTURE: boolean;
  46414. SHEEN_TEXTUREDIRECTUV: number;
  46415. SHEEN_LINKWITHALBEDO: boolean;
  46416. SUBSURFACE: boolean;
  46417. SS_REFRACTION: boolean;
  46418. SS_TRANSLUCENCY: boolean;
  46419. SS_SCATERRING: boolean;
  46420. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46421. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46422. SS_REFRACTIONMAP_3D: boolean;
  46423. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46424. SS_LODINREFRACTIONALPHA: boolean;
  46425. SS_GAMMAREFRACTION: boolean;
  46426. SS_RGBDREFRACTION: boolean;
  46427. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46428. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46429. UNLIT: boolean;
  46430. DEBUGMODE: number;
  46431. /**
  46432. * Initializes the PBR Material defines.
  46433. */
  46434. constructor();
  46435. /**
  46436. * Resets the PBR Material defines.
  46437. */
  46438. reset(): void;
  46439. }
  46440. /**
  46441. * The Physically based material base class of BJS.
  46442. *
  46443. * This offers the main features of a standard PBR material.
  46444. * For more information, please refer to the documentation :
  46445. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46446. */
  46447. export abstract class PBRBaseMaterial extends PushMaterial {
  46448. /**
  46449. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46450. */
  46451. static readonly PBRMATERIAL_OPAQUE: number;
  46452. /**
  46453. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46454. */
  46455. static readonly PBRMATERIAL_ALPHATEST: number;
  46456. /**
  46457. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46458. */
  46459. static readonly PBRMATERIAL_ALPHABLEND: number;
  46460. /**
  46461. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46462. * They are also discarded below the alpha cutoff threshold to improve performances.
  46463. */
  46464. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46465. /**
  46466. * Defines the default value of how much AO map is occluding the analytical lights
  46467. * (point spot...).
  46468. */
  46469. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46470. /**
  46471. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46472. */
  46473. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46474. /**
  46475. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46476. * to enhance interoperability with other engines.
  46477. */
  46478. static readonly LIGHTFALLOFF_GLTF: number;
  46479. /**
  46480. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46481. * to enhance interoperability with other materials.
  46482. */
  46483. static readonly LIGHTFALLOFF_STANDARD: number;
  46484. /**
  46485. * Intensity of the direct lights e.g. the four lights available in your scene.
  46486. * This impacts both the direct diffuse and specular highlights.
  46487. */
  46488. protected _directIntensity: number;
  46489. /**
  46490. * Intensity of the emissive part of the material.
  46491. * This helps controlling the emissive effect without modifying the emissive color.
  46492. */
  46493. protected _emissiveIntensity: number;
  46494. /**
  46495. * Intensity of the environment e.g. how much the environment will light the object
  46496. * either through harmonics for rough material or through the refelction for shiny ones.
  46497. */
  46498. protected _environmentIntensity: number;
  46499. /**
  46500. * This is a special control allowing the reduction of the specular highlights coming from the
  46501. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46502. */
  46503. protected _specularIntensity: number;
  46504. /**
  46505. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46506. */
  46507. private _lightingInfos;
  46508. /**
  46509. * Debug Control allowing disabling the bump map on this material.
  46510. */
  46511. protected _disableBumpMap: boolean;
  46512. /**
  46513. * AKA Diffuse Texture in standard nomenclature.
  46514. */
  46515. protected _albedoTexture: BaseTexture;
  46516. /**
  46517. * AKA Occlusion Texture in other nomenclature.
  46518. */
  46519. protected _ambientTexture: BaseTexture;
  46520. /**
  46521. * AKA Occlusion Texture Intensity in other nomenclature.
  46522. */
  46523. protected _ambientTextureStrength: number;
  46524. /**
  46525. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46526. * 1 means it completely occludes it
  46527. * 0 mean it has no impact
  46528. */
  46529. protected _ambientTextureImpactOnAnalyticalLights: number;
  46530. /**
  46531. * Stores the alpha values in a texture.
  46532. */
  46533. protected _opacityTexture: BaseTexture;
  46534. /**
  46535. * Stores the reflection values in a texture.
  46536. */
  46537. protected _reflectionTexture: BaseTexture;
  46538. /**
  46539. * Stores the emissive values in a texture.
  46540. */
  46541. protected _emissiveTexture: BaseTexture;
  46542. /**
  46543. * AKA Specular texture in other nomenclature.
  46544. */
  46545. protected _reflectivityTexture: BaseTexture;
  46546. /**
  46547. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46548. */
  46549. protected _metallicTexture: BaseTexture;
  46550. /**
  46551. * Specifies the metallic scalar of the metallic/roughness workflow.
  46552. * Can also be used to scale the metalness values of the metallic texture.
  46553. */
  46554. protected _metallic: Nullable<number>;
  46555. /**
  46556. * Specifies the roughness scalar of the metallic/roughness workflow.
  46557. * Can also be used to scale the roughness values of the metallic texture.
  46558. */
  46559. protected _roughness: Nullable<number>;
  46560. /**
  46561. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46562. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46563. */
  46564. protected _microSurfaceTexture: BaseTexture;
  46565. /**
  46566. * Stores surface normal data used to displace a mesh in a texture.
  46567. */
  46568. protected _bumpTexture: BaseTexture;
  46569. /**
  46570. * Stores the pre-calculated light information of a mesh in a texture.
  46571. */
  46572. protected _lightmapTexture: BaseTexture;
  46573. /**
  46574. * The color of a material in ambient lighting.
  46575. */
  46576. protected _ambientColor: Color3;
  46577. /**
  46578. * AKA Diffuse Color in other nomenclature.
  46579. */
  46580. protected _albedoColor: Color3;
  46581. /**
  46582. * AKA Specular Color in other nomenclature.
  46583. */
  46584. protected _reflectivityColor: Color3;
  46585. /**
  46586. * The color applied when light is reflected from a material.
  46587. */
  46588. protected _reflectionColor: Color3;
  46589. /**
  46590. * The color applied when light is emitted from a material.
  46591. */
  46592. protected _emissiveColor: Color3;
  46593. /**
  46594. * AKA Glossiness in other nomenclature.
  46595. */
  46596. protected _microSurface: number;
  46597. /**
  46598. * Specifies that the material will use the light map as a show map.
  46599. */
  46600. protected _useLightmapAsShadowmap: boolean;
  46601. /**
  46602. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46603. * makes the reflect vector face the model (under horizon).
  46604. */
  46605. protected _useHorizonOcclusion: boolean;
  46606. /**
  46607. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46608. * too much the area relying on ambient texture to define their ambient occlusion.
  46609. */
  46610. protected _useRadianceOcclusion: boolean;
  46611. /**
  46612. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46613. */
  46614. protected _useAlphaFromAlbedoTexture: boolean;
  46615. /**
  46616. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46617. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46618. */
  46619. protected _useSpecularOverAlpha: boolean;
  46620. /**
  46621. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46622. */
  46623. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46624. /**
  46625. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46626. */
  46627. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46628. /**
  46629. * Specifies if the metallic texture contains the roughness information in its green channel.
  46630. */
  46631. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46632. /**
  46633. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46634. */
  46635. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46636. /**
  46637. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46638. */
  46639. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46640. /**
  46641. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46642. */
  46643. protected _useAmbientInGrayScale: boolean;
  46644. /**
  46645. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46646. * The material will try to infer what glossiness each pixel should be.
  46647. */
  46648. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46649. /**
  46650. * Defines the falloff type used in this material.
  46651. * It by default is Physical.
  46652. */
  46653. protected _lightFalloff: number;
  46654. /**
  46655. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46656. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46657. */
  46658. protected _useRadianceOverAlpha: boolean;
  46659. /**
  46660. * Allows using an object space normal map (instead of tangent space).
  46661. */
  46662. protected _useObjectSpaceNormalMap: boolean;
  46663. /**
  46664. * Allows using the bump map in parallax mode.
  46665. */
  46666. protected _useParallax: boolean;
  46667. /**
  46668. * Allows using the bump map in parallax occlusion mode.
  46669. */
  46670. protected _useParallaxOcclusion: boolean;
  46671. /**
  46672. * Controls the scale bias of the parallax mode.
  46673. */
  46674. protected _parallaxScaleBias: number;
  46675. /**
  46676. * If sets to true, disables all the lights affecting the material.
  46677. */
  46678. protected _disableLighting: boolean;
  46679. /**
  46680. * Number of Simultaneous lights allowed on the material.
  46681. */
  46682. protected _maxSimultaneousLights: number;
  46683. /**
  46684. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46685. */
  46686. protected _invertNormalMapX: boolean;
  46687. /**
  46688. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46689. */
  46690. protected _invertNormalMapY: boolean;
  46691. /**
  46692. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46693. */
  46694. protected _twoSidedLighting: boolean;
  46695. /**
  46696. * Defines the alpha limits in alpha test mode.
  46697. */
  46698. protected _alphaCutOff: number;
  46699. /**
  46700. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46701. */
  46702. protected _forceAlphaTest: boolean;
  46703. /**
  46704. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46705. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46706. */
  46707. protected _useAlphaFresnel: boolean;
  46708. /**
  46709. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46710. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46711. */
  46712. protected _useLinearAlphaFresnel: boolean;
  46713. /**
  46714. * The transparency mode of the material.
  46715. */
  46716. protected _transparencyMode: Nullable<number>;
  46717. /**
  46718. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46719. * from cos thetav and roughness:
  46720. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46721. */
  46722. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46723. /**
  46724. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46725. */
  46726. protected _forceIrradianceInFragment: boolean;
  46727. /**
  46728. * Force normal to face away from face.
  46729. */
  46730. protected _forceNormalForward: boolean;
  46731. /**
  46732. * Enables specular anti aliasing in the PBR shader.
  46733. * It will both interacts on the Geometry for analytical and IBL lighting.
  46734. * It also prefilter the roughness map based on the bump values.
  46735. */
  46736. protected _enableSpecularAntiAliasing: boolean;
  46737. /**
  46738. * Default configuration related to image processing available in the PBR Material.
  46739. */
  46740. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46741. /**
  46742. * Keep track of the image processing observer to allow dispose and replace.
  46743. */
  46744. private _imageProcessingObserver;
  46745. /**
  46746. * Attaches a new image processing configuration to the PBR Material.
  46747. * @param configuration
  46748. */
  46749. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46750. /**
  46751. * Stores the available render targets.
  46752. */
  46753. private _renderTargets;
  46754. /**
  46755. * Sets the global ambient color for the material used in lighting calculations.
  46756. */
  46757. private _globalAmbientColor;
  46758. /**
  46759. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46760. */
  46761. private _useLogarithmicDepth;
  46762. /**
  46763. * If set to true, no lighting calculations will be applied.
  46764. */
  46765. private _unlit;
  46766. private _debugMode;
  46767. /**
  46768. * @hidden
  46769. * This is reserved for the inspector.
  46770. * Defines the material debug mode.
  46771. * It helps seeing only some components of the material while troubleshooting.
  46772. */
  46773. debugMode: number;
  46774. /**
  46775. * @hidden
  46776. * This is reserved for the inspector.
  46777. * Specify from where on screen the debug mode should start.
  46778. * The value goes from -1 (full screen) to 1 (not visible)
  46779. * It helps with side by side comparison against the final render
  46780. * This defaults to -1
  46781. */
  46782. private debugLimit;
  46783. /**
  46784. * @hidden
  46785. * This is reserved for the inspector.
  46786. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46787. * You can use the factor to better multiply the final value.
  46788. */
  46789. private debugFactor;
  46790. /**
  46791. * Defines the clear coat layer parameters for the material.
  46792. */
  46793. readonly clearCoat: PBRClearCoatConfiguration;
  46794. /**
  46795. * Defines the anisotropic parameters for the material.
  46796. */
  46797. readonly anisotropy: PBRAnisotropicConfiguration;
  46798. /**
  46799. * Defines the BRDF parameters for the material.
  46800. */
  46801. readonly brdf: PBRBRDFConfiguration;
  46802. /**
  46803. * Defines the Sheen parameters for the material.
  46804. */
  46805. readonly sheen: PBRSheenConfiguration;
  46806. /**
  46807. * Defines the SubSurface parameters for the material.
  46808. */
  46809. readonly subSurface: PBRSubSurfaceConfiguration;
  46810. /**
  46811. * Custom callback helping to override the default shader used in the material.
  46812. */
  46813. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46814. /**
  46815. * Instantiates a new PBRMaterial instance.
  46816. *
  46817. * @param name The material name
  46818. * @param scene The scene the material will be use in.
  46819. */
  46820. constructor(name: string, scene: Scene);
  46821. /**
  46822. * Gets a boolean indicating that current material needs to register RTT
  46823. */
  46824. readonly hasRenderTargetTextures: boolean;
  46825. /**
  46826. * Gets the name of the material class.
  46827. */
  46828. getClassName(): string;
  46829. /**
  46830. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46831. */
  46832. /**
  46833. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46834. */
  46835. useLogarithmicDepth: boolean;
  46836. /**
  46837. * Gets the current transparency mode.
  46838. */
  46839. /**
  46840. * Sets the transparency mode of the material.
  46841. *
  46842. * | Value | Type | Description |
  46843. * | ----- | ----------------------------------- | ----------- |
  46844. * | 0 | OPAQUE | |
  46845. * | 1 | ALPHATEST | |
  46846. * | 2 | ALPHABLEND | |
  46847. * | 3 | ALPHATESTANDBLEND | |
  46848. *
  46849. */
  46850. transparencyMode: Nullable<number>;
  46851. /**
  46852. * Returns true if alpha blending should be disabled.
  46853. */
  46854. private readonly _disableAlphaBlending;
  46855. /**
  46856. * Specifies whether or not this material should be rendered in alpha blend mode.
  46857. */
  46858. needAlphaBlending(): boolean;
  46859. /**
  46860. * Specifies if the mesh will require alpha blending.
  46861. * @param mesh - BJS mesh.
  46862. */
  46863. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46864. /**
  46865. * Specifies whether or not this material should be rendered in alpha test mode.
  46866. */
  46867. needAlphaTesting(): boolean;
  46868. /**
  46869. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46870. */
  46871. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46872. /**
  46873. * Gets the texture used for the alpha test.
  46874. */
  46875. getAlphaTestTexture(): BaseTexture;
  46876. /**
  46877. * Specifies that the submesh is ready to be used.
  46878. * @param mesh - BJS mesh.
  46879. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46880. * @param useInstances - Specifies that instances should be used.
  46881. * @returns - boolean indicating that the submesh is ready or not.
  46882. */
  46883. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46884. /**
  46885. * Specifies if the material uses metallic roughness workflow.
  46886. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46887. */
  46888. isMetallicWorkflow(): boolean;
  46889. private _prepareEffect;
  46890. private _prepareDefines;
  46891. /**
  46892. * Force shader compilation
  46893. */
  46894. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46895. clipPlane: boolean;
  46896. }>): void;
  46897. /**
  46898. * Initializes the uniform buffer layout for the shader.
  46899. */
  46900. buildUniformLayout(): void;
  46901. /**
  46902. * Unbinds the material from the mesh
  46903. */
  46904. unbind(): void;
  46905. /**
  46906. * Binds the submesh data.
  46907. * @param world - The world matrix.
  46908. * @param mesh - The BJS mesh.
  46909. * @param subMesh - A submesh of the BJS mesh.
  46910. */
  46911. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46912. /**
  46913. * Returns the animatable textures.
  46914. * @returns - Array of animatable textures.
  46915. */
  46916. getAnimatables(): IAnimatable[];
  46917. /**
  46918. * Returns the texture used for reflections.
  46919. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46920. */
  46921. private _getReflectionTexture;
  46922. /**
  46923. * Returns an array of the actively used textures.
  46924. * @returns - Array of BaseTextures
  46925. */
  46926. getActiveTextures(): BaseTexture[];
  46927. /**
  46928. * Checks to see if a texture is used in the material.
  46929. * @param texture - Base texture to use.
  46930. * @returns - Boolean specifying if a texture is used in the material.
  46931. */
  46932. hasTexture(texture: BaseTexture): boolean;
  46933. /**
  46934. * Disposes the resources of the material.
  46935. * @param forceDisposeEffect - Forces the disposal of effects.
  46936. * @param forceDisposeTextures - Forces the disposal of all textures.
  46937. */
  46938. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46939. }
  46940. }
  46941. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  46942. import { Nullable } from "babylonjs/types";
  46943. import { Scene } from "babylonjs/scene";
  46944. import { Color3 } from "babylonjs/Maths/math";
  46945. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46946. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46947. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46948. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  46949. /**
  46950. * The Physically based material of BJS.
  46951. *
  46952. * This offers the main features of a standard PBR material.
  46953. * For more information, please refer to the documentation :
  46954. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46955. */
  46956. export class PBRMaterial extends PBRBaseMaterial {
  46957. /**
  46958. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46959. */
  46960. static readonly PBRMATERIAL_OPAQUE: number;
  46961. /**
  46962. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46963. */
  46964. static readonly PBRMATERIAL_ALPHATEST: number;
  46965. /**
  46966. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46967. */
  46968. static readonly PBRMATERIAL_ALPHABLEND: number;
  46969. /**
  46970. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46971. * They are also discarded below the alpha cutoff threshold to improve performances.
  46972. */
  46973. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46974. /**
  46975. * Defines the default value of how much AO map is occluding the analytical lights
  46976. * (point spot...).
  46977. */
  46978. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46979. /**
  46980. * Intensity of the direct lights e.g. the four lights available in your scene.
  46981. * This impacts both the direct diffuse and specular highlights.
  46982. */
  46983. directIntensity: number;
  46984. /**
  46985. * Intensity of the emissive part of the material.
  46986. * This helps controlling the emissive effect without modifying the emissive color.
  46987. */
  46988. emissiveIntensity: number;
  46989. /**
  46990. * Intensity of the environment e.g. how much the environment will light the object
  46991. * either through harmonics for rough material or through the refelction for shiny ones.
  46992. */
  46993. environmentIntensity: number;
  46994. /**
  46995. * This is a special control allowing the reduction of the specular highlights coming from the
  46996. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46997. */
  46998. specularIntensity: number;
  46999. /**
  47000. * Debug Control allowing disabling the bump map on this material.
  47001. */
  47002. disableBumpMap: boolean;
  47003. /**
  47004. * AKA Diffuse Texture in standard nomenclature.
  47005. */
  47006. albedoTexture: BaseTexture;
  47007. /**
  47008. * AKA Occlusion Texture in other nomenclature.
  47009. */
  47010. ambientTexture: BaseTexture;
  47011. /**
  47012. * AKA Occlusion Texture Intensity in other nomenclature.
  47013. */
  47014. ambientTextureStrength: number;
  47015. /**
  47016. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47017. * 1 means it completely occludes it
  47018. * 0 mean it has no impact
  47019. */
  47020. ambientTextureImpactOnAnalyticalLights: number;
  47021. /**
  47022. * Stores the alpha values in a texture.
  47023. */
  47024. opacityTexture: BaseTexture;
  47025. /**
  47026. * Stores the reflection values in a texture.
  47027. */
  47028. reflectionTexture: Nullable<BaseTexture>;
  47029. /**
  47030. * Stores the emissive values in a texture.
  47031. */
  47032. emissiveTexture: BaseTexture;
  47033. /**
  47034. * AKA Specular texture in other nomenclature.
  47035. */
  47036. reflectivityTexture: BaseTexture;
  47037. /**
  47038. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47039. */
  47040. metallicTexture: BaseTexture;
  47041. /**
  47042. * Specifies the metallic scalar of the metallic/roughness workflow.
  47043. * Can also be used to scale the metalness values of the metallic texture.
  47044. */
  47045. metallic: Nullable<number>;
  47046. /**
  47047. * Specifies the roughness scalar of the metallic/roughness workflow.
  47048. * Can also be used to scale the roughness values of the metallic texture.
  47049. */
  47050. roughness: Nullable<number>;
  47051. /**
  47052. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47053. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47054. */
  47055. microSurfaceTexture: BaseTexture;
  47056. /**
  47057. * Stores surface normal data used to displace a mesh in a texture.
  47058. */
  47059. bumpTexture: BaseTexture;
  47060. /**
  47061. * Stores the pre-calculated light information of a mesh in a texture.
  47062. */
  47063. lightmapTexture: BaseTexture;
  47064. /**
  47065. * Stores the refracted light information in a texture.
  47066. */
  47067. refractionTexture: Nullable<BaseTexture>;
  47068. /**
  47069. * The color of a material in ambient lighting.
  47070. */
  47071. ambientColor: Color3;
  47072. /**
  47073. * AKA Diffuse Color in other nomenclature.
  47074. */
  47075. albedoColor: Color3;
  47076. /**
  47077. * AKA Specular Color in other nomenclature.
  47078. */
  47079. reflectivityColor: Color3;
  47080. /**
  47081. * The color reflected from the material.
  47082. */
  47083. reflectionColor: Color3;
  47084. /**
  47085. * The color emitted from the material.
  47086. */
  47087. emissiveColor: Color3;
  47088. /**
  47089. * AKA Glossiness in other nomenclature.
  47090. */
  47091. microSurface: number;
  47092. /**
  47093. * source material index of refraction (IOR)' / 'destination material IOR.
  47094. */
  47095. indexOfRefraction: number;
  47096. /**
  47097. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47098. */
  47099. invertRefractionY: boolean;
  47100. /**
  47101. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47102. * Materials half opaque for instance using refraction could benefit from this control.
  47103. */
  47104. linkRefractionWithTransparency: boolean;
  47105. /**
  47106. * If true, the light map contains occlusion information instead of lighting info.
  47107. */
  47108. useLightmapAsShadowmap: boolean;
  47109. /**
  47110. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47111. */
  47112. useAlphaFromAlbedoTexture: boolean;
  47113. /**
  47114. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47115. */
  47116. forceAlphaTest: boolean;
  47117. /**
  47118. * Defines the alpha limits in alpha test mode.
  47119. */
  47120. alphaCutOff: number;
  47121. /**
  47122. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47123. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47124. */
  47125. useSpecularOverAlpha: boolean;
  47126. /**
  47127. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47128. */
  47129. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47130. /**
  47131. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47132. */
  47133. useRoughnessFromMetallicTextureAlpha: boolean;
  47134. /**
  47135. * Specifies if the metallic texture contains the roughness information in its green channel.
  47136. */
  47137. useRoughnessFromMetallicTextureGreen: boolean;
  47138. /**
  47139. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47140. */
  47141. useMetallnessFromMetallicTextureBlue: boolean;
  47142. /**
  47143. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47144. */
  47145. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47146. /**
  47147. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47148. */
  47149. useAmbientInGrayScale: boolean;
  47150. /**
  47151. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47152. * The material will try to infer what glossiness each pixel should be.
  47153. */
  47154. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47155. /**
  47156. * BJS is using an harcoded light falloff based on a manually sets up range.
  47157. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47158. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47159. */
  47160. /**
  47161. * BJS is using an harcoded light falloff based on a manually sets up range.
  47162. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47163. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47164. */
  47165. usePhysicalLightFalloff: boolean;
  47166. /**
  47167. * In order to support the falloff compatibility with gltf, a special mode has been added
  47168. * to reproduce the gltf light falloff.
  47169. */
  47170. /**
  47171. * In order to support the falloff compatibility with gltf, a special mode has been added
  47172. * to reproduce the gltf light falloff.
  47173. */
  47174. useGLTFLightFalloff: boolean;
  47175. /**
  47176. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47177. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47178. */
  47179. useRadianceOverAlpha: boolean;
  47180. /**
  47181. * Allows using an object space normal map (instead of tangent space).
  47182. */
  47183. useObjectSpaceNormalMap: boolean;
  47184. /**
  47185. * Allows using the bump map in parallax mode.
  47186. */
  47187. useParallax: boolean;
  47188. /**
  47189. * Allows using the bump map in parallax occlusion mode.
  47190. */
  47191. useParallaxOcclusion: boolean;
  47192. /**
  47193. * Controls the scale bias of the parallax mode.
  47194. */
  47195. parallaxScaleBias: number;
  47196. /**
  47197. * If sets to true, disables all the lights affecting the material.
  47198. */
  47199. disableLighting: boolean;
  47200. /**
  47201. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47202. */
  47203. forceIrradianceInFragment: boolean;
  47204. /**
  47205. * Number of Simultaneous lights allowed on the material.
  47206. */
  47207. maxSimultaneousLights: number;
  47208. /**
  47209. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47210. */
  47211. invertNormalMapX: boolean;
  47212. /**
  47213. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47214. */
  47215. invertNormalMapY: boolean;
  47216. /**
  47217. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47218. */
  47219. twoSidedLighting: boolean;
  47220. /**
  47221. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47222. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47223. */
  47224. useAlphaFresnel: boolean;
  47225. /**
  47226. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47227. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47228. */
  47229. useLinearAlphaFresnel: boolean;
  47230. /**
  47231. * Let user defines the brdf lookup texture used for IBL.
  47232. * A default 8bit version is embedded but you could point at :
  47233. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47234. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47235. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47236. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47237. */
  47238. environmentBRDFTexture: Nullable<BaseTexture>;
  47239. /**
  47240. * Force normal to face away from face.
  47241. */
  47242. forceNormalForward: boolean;
  47243. /**
  47244. * Enables specular anti aliasing in the PBR shader.
  47245. * It will both interacts on the Geometry for analytical and IBL lighting.
  47246. * It also prefilter the roughness map based on the bump values.
  47247. */
  47248. enableSpecularAntiAliasing: boolean;
  47249. /**
  47250. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47251. * makes the reflect vector face the model (under horizon).
  47252. */
  47253. useHorizonOcclusion: boolean;
  47254. /**
  47255. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47256. * too much the area relying on ambient texture to define their ambient occlusion.
  47257. */
  47258. useRadianceOcclusion: boolean;
  47259. /**
  47260. * If set to true, no lighting calculations will be applied.
  47261. */
  47262. unlit: boolean;
  47263. /**
  47264. * Gets the image processing configuration used either in this material.
  47265. */
  47266. /**
  47267. * Sets the Default image processing configuration used either in the this material.
  47268. *
  47269. * If sets to null, the scene one is in use.
  47270. */
  47271. imageProcessingConfiguration: ImageProcessingConfiguration;
  47272. /**
  47273. * Gets wether the color curves effect is enabled.
  47274. */
  47275. /**
  47276. * Sets wether the color curves effect is enabled.
  47277. */
  47278. cameraColorCurvesEnabled: boolean;
  47279. /**
  47280. * Gets wether the color grading effect is enabled.
  47281. */
  47282. /**
  47283. * Gets wether the color grading effect is enabled.
  47284. */
  47285. cameraColorGradingEnabled: boolean;
  47286. /**
  47287. * Gets wether tonemapping is enabled or not.
  47288. */
  47289. /**
  47290. * Sets wether tonemapping is enabled or not
  47291. */
  47292. cameraToneMappingEnabled: boolean;
  47293. /**
  47294. * The camera exposure used on this material.
  47295. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47296. * This corresponds to a photographic exposure.
  47297. */
  47298. /**
  47299. * The camera exposure used on this material.
  47300. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47301. * This corresponds to a photographic exposure.
  47302. */
  47303. cameraExposure: number;
  47304. /**
  47305. * Gets The camera contrast used on this material.
  47306. */
  47307. /**
  47308. * Sets The camera contrast used on this material.
  47309. */
  47310. cameraContrast: number;
  47311. /**
  47312. * Gets the Color Grading 2D Lookup Texture.
  47313. */
  47314. /**
  47315. * Sets the Color Grading 2D Lookup Texture.
  47316. */
  47317. cameraColorGradingTexture: Nullable<BaseTexture>;
  47318. /**
  47319. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47320. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47321. * 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;
  47322. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47323. */
  47324. /**
  47325. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47326. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47327. * 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;
  47328. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47329. */
  47330. cameraColorCurves: Nullable<ColorCurves>;
  47331. /**
  47332. * Instantiates a new PBRMaterial instance.
  47333. *
  47334. * @param name The material name
  47335. * @param scene The scene the material will be use in.
  47336. */
  47337. constructor(name: string, scene: Scene);
  47338. /**
  47339. * Returns the name of this material class.
  47340. */
  47341. getClassName(): string;
  47342. /**
  47343. * Makes a duplicate of the current material.
  47344. * @param name - name to use for the new material.
  47345. */
  47346. clone(name: string): PBRMaterial;
  47347. /**
  47348. * Serializes this PBR Material.
  47349. * @returns - An object with the serialized material.
  47350. */
  47351. serialize(): any;
  47352. /**
  47353. * Parses a PBR Material from a serialized object.
  47354. * @param source - Serialized object.
  47355. * @param scene - BJS scene instance.
  47356. * @param rootUrl - url for the scene object
  47357. * @returns - PBRMaterial
  47358. */
  47359. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47360. }
  47361. }
  47362. declare module "babylonjs/Misc/dds" {
  47363. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47364. import { Engine } from "babylonjs/Engines/engine";
  47365. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47366. import { Nullable } from "babylonjs/types";
  47367. import { Scene } from "babylonjs/scene";
  47368. /**
  47369. * Direct draw surface info
  47370. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47371. */
  47372. export interface DDSInfo {
  47373. /**
  47374. * Width of the texture
  47375. */
  47376. width: number;
  47377. /**
  47378. * Width of the texture
  47379. */
  47380. height: number;
  47381. /**
  47382. * Number of Mipmaps for the texture
  47383. * @see https://en.wikipedia.org/wiki/Mipmap
  47384. */
  47385. mipmapCount: number;
  47386. /**
  47387. * If the textures format is a known fourCC format
  47388. * @see https://www.fourcc.org/
  47389. */
  47390. isFourCC: boolean;
  47391. /**
  47392. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47393. */
  47394. isRGB: boolean;
  47395. /**
  47396. * If the texture is a lumincance format
  47397. */
  47398. isLuminance: boolean;
  47399. /**
  47400. * If this is a cube texture
  47401. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47402. */
  47403. isCube: boolean;
  47404. /**
  47405. * If the texture is a compressed format eg. FOURCC_DXT1
  47406. */
  47407. isCompressed: boolean;
  47408. /**
  47409. * The dxgiFormat of the texture
  47410. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47411. */
  47412. dxgiFormat: number;
  47413. /**
  47414. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47415. */
  47416. textureType: number;
  47417. /**
  47418. * Sphericle polynomial created for the dds texture
  47419. */
  47420. sphericalPolynomial?: SphericalPolynomial;
  47421. }
  47422. /**
  47423. * Class used to provide DDS decompression tools
  47424. */
  47425. export class DDSTools {
  47426. /**
  47427. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47428. */
  47429. static StoreLODInAlphaChannel: boolean;
  47430. /**
  47431. * Gets DDS information from an array buffer
  47432. * @param arrayBuffer defines the array buffer to read data from
  47433. * @returns the DDS information
  47434. */
  47435. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47436. private static _FloatView;
  47437. private static _Int32View;
  47438. private static _ToHalfFloat;
  47439. private static _FromHalfFloat;
  47440. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47441. private static _GetHalfFloatRGBAArrayBuffer;
  47442. private static _GetFloatRGBAArrayBuffer;
  47443. private static _GetFloatAsUIntRGBAArrayBuffer;
  47444. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47445. private static _GetRGBAArrayBuffer;
  47446. private static _ExtractLongWordOrder;
  47447. private static _GetRGBArrayBuffer;
  47448. private static _GetLuminanceArrayBuffer;
  47449. /**
  47450. * Uploads DDS Levels to a Babylon Texture
  47451. * @hidden
  47452. */
  47453. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47454. }
  47455. module "babylonjs/Engines/engine" {
  47456. interface Engine {
  47457. /**
  47458. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47459. * @param rootUrl defines the url where the file to load is located
  47460. * @param scene defines the current scene
  47461. * @param lodScale defines scale to apply to the mip map selection
  47462. * @param lodOffset defines offset to apply to the mip map selection
  47463. * @param onLoad defines an optional callback raised when the texture is loaded
  47464. * @param onError defines an optional callback raised if there is an issue to load the texture
  47465. * @param format defines the format of the data
  47466. * @param forcedExtension defines the extension to use to pick the right loader
  47467. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47468. * @returns the cube texture as an InternalTexture
  47469. */
  47470. 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;
  47471. }
  47472. }
  47473. }
  47474. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47475. import { Nullable } from "babylonjs/types";
  47476. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47477. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47478. /**
  47479. * Implementation of the DDS Texture Loader.
  47480. * @hidden
  47481. */
  47482. export class _DDSTextureLoader implements IInternalTextureLoader {
  47483. /**
  47484. * Defines wether the loader supports cascade loading the different faces.
  47485. */
  47486. readonly supportCascades: boolean;
  47487. /**
  47488. * This returns if the loader support the current file information.
  47489. * @param extension defines the file extension of the file being loaded
  47490. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47491. * @param fallback defines the fallback internal texture if any
  47492. * @param isBase64 defines whether the texture is encoded as a base64
  47493. * @param isBuffer defines whether the texture data are stored as a buffer
  47494. * @returns true if the loader can load the specified file
  47495. */
  47496. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47497. /**
  47498. * Transform the url before loading if required.
  47499. * @param rootUrl the url of the texture
  47500. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47501. * @returns the transformed texture
  47502. */
  47503. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47504. /**
  47505. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47506. * @param rootUrl the url of the texture
  47507. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47508. * @returns the fallback texture
  47509. */
  47510. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47511. /**
  47512. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47513. * @param data contains the texture data
  47514. * @param texture defines the BabylonJS internal texture
  47515. * @param createPolynomials will be true if polynomials have been requested
  47516. * @param onLoad defines the callback to trigger once the texture is ready
  47517. * @param onError defines the callback to trigger in case of error
  47518. */
  47519. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47520. /**
  47521. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47522. * @param data contains the texture data
  47523. * @param texture defines the BabylonJS internal texture
  47524. * @param callback defines the method to call once ready to upload
  47525. */
  47526. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47527. }
  47528. }
  47529. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47530. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47531. /** @hidden */
  47532. export var rgbdEncodePixelShader: {
  47533. name: string;
  47534. shader: string;
  47535. };
  47536. }
  47537. declare module "babylonjs/Misc/environmentTextureTools" {
  47538. import { Nullable } from "babylonjs/types";
  47539. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47540. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47541. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47542. import "babylonjs/Shaders/rgbdEncode.fragment";
  47543. import "babylonjs/Shaders/rgbdDecode.fragment";
  47544. /**
  47545. * Raw texture data and descriptor sufficient for WebGL texture upload
  47546. */
  47547. export interface EnvironmentTextureInfo {
  47548. /**
  47549. * Version of the environment map
  47550. */
  47551. version: number;
  47552. /**
  47553. * Width of image
  47554. */
  47555. width: number;
  47556. /**
  47557. * Irradiance information stored in the file.
  47558. */
  47559. irradiance: any;
  47560. /**
  47561. * Specular information stored in the file.
  47562. */
  47563. specular: any;
  47564. }
  47565. /**
  47566. * Sets of helpers addressing the serialization and deserialization of environment texture
  47567. * stored in a BabylonJS env file.
  47568. * Those files are usually stored as .env files.
  47569. */
  47570. export class EnvironmentTextureTools {
  47571. /**
  47572. * Magic number identifying the env file.
  47573. */
  47574. private static _MagicBytes;
  47575. /**
  47576. * Gets the environment info from an env file.
  47577. * @param data The array buffer containing the .env bytes.
  47578. * @returns the environment file info (the json header) if successfully parsed.
  47579. */
  47580. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47581. /**
  47582. * Creates an environment texture from a loaded cube texture.
  47583. * @param texture defines the cube texture to convert in env file
  47584. * @return a promise containing the environment data if succesfull.
  47585. */
  47586. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47587. /**
  47588. * Creates a JSON representation of the spherical data.
  47589. * @param texture defines the texture containing the polynomials
  47590. * @return the JSON representation of the spherical info
  47591. */
  47592. private static _CreateEnvTextureIrradiance;
  47593. /**
  47594. * Uploads the texture info contained in the env file to the GPU.
  47595. * @param texture defines the internal texture to upload to
  47596. * @param arrayBuffer defines the buffer cotaining the data to load
  47597. * @param info defines the texture info retrieved through the GetEnvInfo method
  47598. * @returns a promise
  47599. */
  47600. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47601. /**
  47602. * Uploads the levels of image data to the GPU.
  47603. * @param texture defines the internal texture to upload to
  47604. * @param imageData defines the array buffer views of image data [mipmap][face]
  47605. * @returns a promise
  47606. */
  47607. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47608. /**
  47609. * Uploads spherical polynomials information to the texture.
  47610. * @param texture defines the texture we are trying to upload the information to
  47611. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47612. */
  47613. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47614. /** @hidden */
  47615. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47616. }
  47617. }
  47618. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47619. import { Nullable } from "babylonjs/types";
  47620. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47621. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47622. /**
  47623. * Implementation of the ENV Texture Loader.
  47624. * @hidden
  47625. */
  47626. export class _ENVTextureLoader implements IInternalTextureLoader {
  47627. /**
  47628. * Defines wether the loader supports cascade loading the different faces.
  47629. */
  47630. readonly supportCascades: boolean;
  47631. /**
  47632. * This returns if the loader support the current file information.
  47633. * @param extension defines the file extension of the file being loaded
  47634. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47635. * @param fallback defines the fallback internal texture if any
  47636. * @param isBase64 defines whether the texture is encoded as a base64
  47637. * @param isBuffer defines whether the texture data are stored as a buffer
  47638. * @returns true if the loader can load the specified file
  47639. */
  47640. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47641. /**
  47642. * Transform the url before loading if required.
  47643. * @param rootUrl the url of the texture
  47644. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47645. * @returns the transformed texture
  47646. */
  47647. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47648. /**
  47649. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47650. * @param rootUrl the url of the texture
  47651. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47652. * @returns the fallback texture
  47653. */
  47654. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47655. /**
  47656. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47657. * @param data contains the texture data
  47658. * @param texture defines the BabylonJS internal texture
  47659. * @param createPolynomials will be true if polynomials have been requested
  47660. * @param onLoad defines the callback to trigger once the texture is ready
  47661. * @param onError defines the callback to trigger in case of error
  47662. */
  47663. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47664. /**
  47665. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47666. * @param data contains the texture data
  47667. * @param texture defines the BabylonJS internal texture
  47668. * @param callback defines the method to call once ready to upload
  47669. */
  47670. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47671. }
  47672. }
  47673. declare module "babylonjs/Misc/khronosTextureContainer" {
  47674. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47675. /**
  47676. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47677. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47678. */
  47679. export class KhronosTextureContainer {
  47680. /** contents of the KTX container file */
  47681. arrayBuffer: any;
  47682. private static HEADER_LEN;
  47683. private static COMPRESSED_2D;
  47684. private static COMPRESSED_3D;
  47685. private static TEX_2D;
  47686. private static TEX_3D;
  47687. /**
  47688. * Gets the openGL type
  47689. */
  47690. glType: number;
  47691. /**
  47692. * Gets the openGL type size
  47693. */
  47694. glTypeSize: number;
  47695. /**
  47696. * Gets the openGL format
  47697. */
  47698. glFormat: number;
  47699. /**
  47700. * Gets the openGL internal format
  47701. */
  47702. glInternalFormat: number;
  47703. /**
  47704. * Gets the base internal format
  47705. */
  47706. glBaseInternalFormat: number;
  47707. /**
  47708. * Gets image width in pixel
  47709. */
  47710. pixelWidth: number;
  47711. /**
  47712. * Gets image height in pixel
  47713. */
  47714. pixelHeight: number;
  47715. /**
  47716. * Gets image depth in pixels
  47717. */
  47718. pixelDepth: number;
  47719. /**
  47720. * Gets the number of array elements
  47721. */
  47722. numberOfArrayElements: number;
  47723. /**
  47724. * Gets the number of faces
  47725. */
  47726. numberOfFaces: number;
  47727. /**
  47728. * Gets the number of mipmap levels
  47729. */
  47730. numberOfMipmapLevels: number;
  47731. /**
  47732. * Gets the bytes of key value data
  47733. */
  47734. bytesOfKeyValueData: number;
  47735. /**
  47736. * Gets the load type
  47737. */
  47738. loadType: number;
  47739. /**
  47740. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47741. */
  47742. isInvalid: boolean;
  47743. /**
  47744. * Creates a new KhronosTextureContainer
  47745. * @param arrayBuffer contents of the KTX container file
  47746. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47747. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47748. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47749. */
  47750. constructor(
  47751. /** contents of the KTX container file */
  47752. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47753. /**
  47754. * Uploads KTX content to a Babylon Texture.
  47755. * It is assumed that the texture has already been created & is currently bound
  47756. * @hidden
  47757. */
  47758. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47759. private _upload2DCompressedLevels;
  47760. }
  47761. }
  47762. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  47763. import { Nullable } from "babylonjs/types";
  47764. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47765. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47766. /**
  47767. * Implementation of the KTX Texture Loader.
  47768. * @hidden
  47769. */
  47770. export class _KTXTextureLoader implements IInternalTextureLoader {
  47771. /**
  47772. * Defines wether the loader supports cascade loading the different faces.
  47773. */
  47774. readonly supportCascades: boolean;
  47775. /**
  47776. * This returns if the loader support the current file information.
  47777. * @param extension defines the file extension of the file being loaded
  47778. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47779. * @param fallback defines the fallback internal texture if any
  47780. * @param isBase64 defines whether the texture is encoded as a base64
  47781. * @param isBuffer defines whether the texture data are stored as a buffer
  47782. * @returns true if the loader can load the specified file
  47783. */
  47784. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47785. /**
  47786. * Transform the url before loading if required.
  47787. * @param rootUrl the url of the texture
  47788. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47789. * @returns the transformed texture
  47790. */
  47791. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47792. /**
  47793. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47794. * @param rootUrl the url of the texture
  47795. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47796. * @returns the fallback texture
  47797. */
  47798. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47799. /**
  47800. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47801. * @param data contains the texture data
  47802. * @param texture defines the BabylonJS internal texture
  47803. * @param createPolynomials will be true if polynomials have been requested
  47804. * @param onLoad defines the callback to trigger once the texture is ready
  47805. * @param onError defines the callback to trigger in case of error
  47806. */
  47807. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47808. /**
  47809. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47810. * @param data contains the texture data
  47811. * @param texture defines the BabylonJS internal texture
  47812. * @param callback defines the method to call once ready to upload
  47813. */
  47814. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47815. }
  47816. }
  47817. declare module "babylonjs/Helpers/sceneHelpers" {
  47818. import { Nullable } from "babylonjs/types";
  47819. import { Mesh } from "babylonjs/Meshes/mesh";
  47820. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47821. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  47822. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  47823. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  47824. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  47825. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  47826. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  47827. import "babylonjs/Meshes/Builders/boxBuilder";
  47828. /** @hidden */
  47829. export var _forceSceneHelpersToBundle: boolean;
  47830. module "babylonjs/scene" {
  47831. interface Scene {
  47832. /**
  47833. * Creates a default light for the scene.
  47834. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47835. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47836. */
  47837. createDefaultLight(replace?: boolean): void;
  47838. /**
  47839. * Creates a default camera for the scene.
  47840. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47841. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47842. * @param replace has default false, when true replaces the active camera in the scene
  47843. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47844. */
  47845. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47846. /**
  47847. * Creates a default camera and a default light.
  47848. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47849. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47850. * @param replace has the default false, when true replaces the active camera/light in the scene
  47851. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47852. */
  47853. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47854. /**
  47855. * Creates a new sky box
  47856. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47857. * @param environmentTexture defines the texture to use as environment texture
  47858. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47859. * @param scale defines the overall scale of the skybox
  47860. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47861. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47862. * @returns a new mesh holding the sky box
  47863. */
  47864. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47865. /**
  47866. * Creates a new environment
  47867. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47868. * @param options defines the options you can use to configure the environment
  47869. * @returns the new EnvironmentHelper
  47870. */
  47871. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47872. /**
  47873. * Creates a new VREXperienceHelper
  47874. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47875. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47876. * @returns a new VREXperienceHelper
  47877. */
  47878. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47879. /**
  47880. * Creates a new XREXperienceHelper
  47881. * @see http://doc.babylonjs.com/how_to/webxr
  47882. * @returns a promise for a new XREXperienceHelper
  47883. */
  47884. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47885. }
  47886. }
  47887. }
  47888. declare module "babylonjs/Helpers/videoDome" {
  47889. import { Scene } from "babylonjs/scene";
  47890. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47891. import { Mesh } from "babylonjs/Meshes/mesh";
  47892. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  47893. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47894. import "babylonjs/Meshes/Builders/sphereBuilder";
  47895. /**
  47896. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47897. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47898. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47899. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47900. */
  47901. export class VideoDome extends TransformNode {
  47902. /**
  47903. * Define the video source as a Monoscopic panoramic 360 video.
  47904. */
  47905. static readonly MODE_MONOSCOPIC: number;
  47906. /**
  47907. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47908. */
  47909. static readonly MODE_TOPBOTTOM: number;
  47910. /**
  47911. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47912. */
  47913. static readonly MODE_SIDEBYSIDE: number;
  47914. private _useDirectMapping;
  47915. /**
  47916. * The video texture being displayed on the sphere
  47917. */
  47918. protected _videoTexture: VideoTexture;
  47919. /**
  47920. * Gets the video texture being displayed on the sphere
  47921. */
  47922. readonly videoTexture: VideoTexture;
  47923. /**
  47924. * The skybox material
  47925. */
  47926. protected _material: BackgroundMaterial;
  47927. /**
  47928. * The surface used for the skybox
  47929. */
  47930. protected _mesh: Mesh;
  47931. /**
  47932. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47933. * Also see the options.resolution property.
  47934. */
  47935. fovMultiplier: number;
  47936. private _videoMode;
  47937. /**
  47938. * Gets or set the current video mode for the video. It can be:
  47939. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47940. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47941. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47942. */
  47943. videoMode: number;
  47944. /**
  47945. * Oberserver used in Stereoscopic VR Mode.
  47946. */
  47947. private _onBeforeCameraRenderObserver;
  47948. /**
  47949. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47950. * @param name Element's name, child elements will append suffixes for their own names.
  47951. * @param urlsOrVideo defines the url(s) or the video element to use
  47952. * @param options An object containing optional or exposed sub element properties
  47953. */
  47954. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47955. resolution?: number;
  47956. clickToPlay?: boolean;
  47957. autoPlay?: boolean;
  47958. loop?: boolean;
  47959. size?: number;
  47960. poster?: string;
  47961. faceForward?: boolean;
  47962. useDirectMapping?: boolean;
  47963. }, scene: Scene);
  47964. private _changeVideoMode;
  47965. /**
  47966. * Releases resources associated with this node.
  47967. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47968. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47969. */
  47970. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47971. }
  47972. }
  47973. declare module "babylonjs/Helpers/index" {
  47974. export * from "babylonjs/Helpers/environmentHelper";
  47975. export * from "babylonjs/Helpers/photoDome";
  47976. export * from "babylonjs/Helpers/sceneHelpers";
  47977. export * from "babylonjs/Helpers/videoDome";
  47978. }
  47979. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  47980. import { PerfCounter } from "babylonjs/Misc/tools";
  47981. import { IDisposable } from "babylonjs/scene";
  47982. import { Engine } from "babylonjs/Engines/engine";
  47983. /**
  47984. * This class can be used to get instrumentation data from a Babylon engine
  47985. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47986. */
  47987. export class EngineInstrumentation implements IDisposable {
  47988. /**
  47989. * Define the instrumented engine.
  47990. */
  47991. engine: Engine;
  47992. private _captureGPUFrameTime;
  47993. private _gpuFrameTimeToken;
  47994. private _gpuFrameTime;
  47995. private _captureShaderCompilationTime;
  47996. private _shaderCompilationTime;
  47997. private _onBeginFrameObserver;
  47998. private _onEndFrameObserver;
  47999. private _onBeforeShaderCompilationObserver;
  48000. private _onAfterShaderCompilationObserver;
  48001. /**
  48002. * Gets the perf counter used for GPU frame time
  48003. */
  48004. readonly gpuFrameTimeCounter: PerfCounter;
  48005. /**
  48006. * Gets the GPU frame time capture status
  48007. */
  48008. /**
  48009. * Enable or disable the GPU frame time capture
  48010. */
  48011. captureGPUFrameTime: boolean;
  48012. /**
  48013. * Gets the perf counter used for shader compilation time
  48014. */
  48015. readonly shaderCompilationTimeCounter: PerfCounter;
  48016. /**
  48017. * Gets the shader compilation time capture status
  48018. */
  48019. /**
  48020. * Enable or disable the shader compilation time capture
  48021. */
  48022. captureShaderCompilationTime: boolean;
  48023. /**
  48024. * Instantiates a new engine instrumentation.
  48025. * This class can be used to get instrumentation data from a Babylon engine
  48026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48027. * @param engine Defines the engine to instrument
  48028. */
  48029. constructor(
  48030. /**
  48031. * Define the instrumented engine.
  48032. */
  48033. engine: Engine);
  48034. /**
  48035. * Dispose and release associated resources.
  48036. */
  48037. dispose(): void;
  48038. }
  48039. }
  48040. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48041. import { PerfCounter } from "babylonjs/Misc/tools";
  48042. import { Scene, IDisposable } from "babylonjs/scene";
  48043. /**
  48044. * This class can be used to get instrumentation data from a Babylon engine
  48045. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48046. */
  48047. export class SceneInstrumentation implements IDisposable {
  48048. /**
  48049. * Defines the scene to instrument
  48050. */
  48051. scene: Scene;
  48052. private _captureActiveMeshesEvaluationTime;
  48053. private _activeMeshesEvaluationTime;
  48054. private _captureRenderTargetsRenderTime;
  48055. private _renderTargetsRenderTime;
  48056. private _captureFrameTime;
  48057. private _frameTime;
  48058. private _captureRenderTime;
  48059. private _renderTime;
  48060. private _captureInterFrameTime;
  48061. private _interFrameTime;
  48062. private _captureParticlesRenderTime;
  48063. private _particlesRenderTime;
  48064. private _captureSpritesRenderTime;
  48065. private _spritesRenderTime;
  48066. private _capturePhysicsTime;
  48067. private _physicsTime;
  48068. private _captureAnimationsTime;
  48069. private _animationsTime;
  48070. private _captureCameraRenderTime;
  48071. private _cameraRenderTime;
  48072. private _onBeforeActiveMeshesEvaluationObserver;
  48073. private _onAfterActiveMeshesEvaluationObserver;
  48074. private _onBeforeRenderTargetsRenderObserver;
  48075. private _onAfterRenderTargetsRenderObserver;
  48076. private _onAfterRenderObserver;
  48077. private _onBeforeDrawPhaseObserver;
  48078. private _onAfterDrawPhaseObserver;
  48079. private _onBeforeAnimationsObserver;
  48080. private _onBeforeParticlesRenderingObserver;
  48081. private _onAfterParticlesRenderingObserver;
  48082. private _onBeforeSpritesRenderingObserver;
  48083. private _onAfterSpritesRenderingObserver;
  48084. private _onBeforePhysicsObserver;
  48085. private _onAfterPhysicsObserver;
  48086. private _onAfterAnimationsObserver;
  48087. private _onBeforeCameraRenderObserver;
  48088. private _onAfterCameraRenderObserver;
  48089. /**
  48090. * Gets the perf counter used for active meshes evaluation time
  48091. */
  48092. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48093. /**
  48094. * Gets the active meshes evaluation time capture status
  48095. */
  48096. /**
  48097. * Enable or disable the active meshes evaluation time capture
  48098. */
  48099. captureActiveMeshesEvaluationTime: boolean;
  48100. /**
  48101. * Gets the perf counter used for render targets render time
  48102. */
  48103. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48104. /**
  48105. * Gets the render targets render time capture status
  48106. */
  48107. /**
  48108. * Enable or disable the render targets render time capture
  48109. */
  48110. captureRenderTargetsRenderTime: boolean;
  48111. /**
  48112. * Gets the perf counter used for particles render time
  48113. */
  48114. readonly particlesRenderTimeCounter: PerfCounter;
  48115. /**
  48116. * Gets the particles render time capture status
  48117. */
  48118. /**
  48119. * Enable or disable the particles render time capture
  48120. */
  48121. captureParticlesRenderTime: boolean;
  48122. /**
  48123. * Gets the perf counter used for sprites render time
  48124. */
  48125. readonly spritesRenderTimeCounter: PerfCounter;
  48126. /**
  48127. * Gets the sprites render time capture status
  48128. */
  48129. /**
  48130. * Enable or disable the sprites render time capture
  48131. */
  48132. captureSpritesRenderTime: boolean;
  48133. /**
  48134. * Gets the perf counter used for physics time
  48135. */
  48136. readonly physicsTimeCounter: PerfCounter;
  48137. /**
  48138. * Gets the physics time capture status
  48139. */
  48140. /**
  48141. * Enable or disable the physics time capture
  48142. */
  48143. capturePhysicsTime: boolean;
  48144. /**
  48145. * Gets the perf counter used for animations time
  48146. */
  48147. readonly animationsTimeCounter: PerfCounter;
  48148. /**
  48149. * Gets the animations time capture status
  48150. */
  48151. /**
  48152. * Enable or disable the animations time capture
  48153. */
  48154. captureAnimationsTime: boolean;
  48155. /**
  48156. * Gets the perf counter used for frame time capture
  48157. */
  48158. readonly frameTimeCounter: PerfCounter;
  48159. /**
  48160. * Gets the frame time capture status
  48161. */
  48162. /**
  48163. * Enable or disable the frame time capture
  48164. */
  48165. captureFrameTime: boolean;
  48166. /**
  48167. * Gets the perf counter used for inter-frames time capture
  48168. */
  48169. readonly interFrameTimeCounter: PerfCounter;
  48170. /**
  48171. * Gets the inter-frames time capture status
  48172. */
  48173. /**
  48174. * Enable or disable the inter-frames time capture
  48175. */
  48176. captureInterFrameTime: boolean;
  48177. /**
  48178. * Gets the perf counter used for render time capture
  48179. */
  48180. readonly renderTimeCounter: PerfCounter;
  48181. /**
  48182. * Gets the render time capture status
  48183. */
  48184. /**
  48185. * Enable or disable the render time capture
  48186. */
  48187. captureRenderTime: boolean;
  48188. /**
  48189. * Gets the perf counter used for camera render time capture
  48190. */
  48191. readonly cameraRenderTimeCounter: PerfCounter;
  48192. /**
  48193. * Gets the camera render time capture status
  48194. */
  48195. /**
  48196. * Enable or disable the camera render time capture
  48197. */
  48198. captureCameraRenderTime: boolean;
  48199. /**
  48200. * Gets the perf counter used for draw calls
  48201. */
  48202. readonly drawCallsCounter: PerfCounter;
  48203. /**
  48204. * Instantiates a new scene instrumentation.
  48205. * This class can be used to get instrumentation data from a Babylon engine
  48206. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48207. * @param scene Defines the scene to instrument
  48208. */
  48209. constructor(
  48210. /**
  48211. * Defines the scene to instrument
  48212. */
  48213. scene: Scene);
  48214. /**
  48215. * Dispose and release associated resources.
  48216. */
  48217. dispose(): void;
  48218. }
  48219. }
  48220. declare module "babylonjs/Instrumentation/index" {
  48221. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48222. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48223. export * from "babylonjs/Instrumentation/timeToken";
  48224. }
  48225. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48226. /** @hidden */
  48227. export var glowMapGenerationPixelShader: {
  48228. name: string;
  48229. shader: string;
  48230. };
  48231. }
  48232. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48233. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48234. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48235. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48236. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48237. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48238. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48239. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48240. /** @hidden */
  48241. export var glowMapGenerationVertexShader: {
  48242. name: string;
  48243. shader: string;
  48244. };
  48245. }
  48246. declare module "babylonjs/Layers/effectLayer" {
  48247. import { Observable } from "babylonjs/Misc/observable";
  48248. import { Nullable } from "babylonjs/types";
  48249. import { Camera } from "babylonjs/Cameras/camera";
  48250. import { Scene } from "babylonjs/scene";
  48251. import { Color4, ISize } from "babylonjs/Maths/math";
  48252. import { Engine } from "babylonjs/Engines/engine";
  48253. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48255. import { Mesh } from "babylonjs/Meshes/mesh";
  48256. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48257. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48258. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48259. import { Effect } from "babylonjs/Materials/effect";
  48260. import { Material } from "babylonjs/Materials/material";
  48261. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48262. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48263. /**
  48264. * Effect layer options. This helps customizing the behaviour
  48265. * of the effect layer.
  48266. */
  48267. export interface IEffectLayerOptions {
  48268. /**
  48269. * Multiplication factor apply to the canvas size to compute the render target size
  48270. * used to generated the objects (the smaller the faster).
  48271. */
  48272. mainTextureRatio: number;
  48273. /**
  48274. * Enforces a fixed size texture to ensure effect stability across devices.
  48275. */
  48276. mainTextureFixedSize?: number;
  48277. /**
  48278. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48279. */
  48280. alphaBlendingMode: number;
  48281. /**
  48282. * The camera attached to the layer.
  48283. */
  48284. camera: Nullable<Camera>;
  48285. /**
  48286. * The rendering group to draw the layer in.
  48287. */
  48288. renderingGroupId: number;
  48289. }
  48290. /**
  48291. * The effect layer Helps adding post process effect blended with the main pass.
  48292. *
  48293. * This can be for instance use to generate glow or higlight effects on the scene.
  48294. *
  48295. * The effect layer class can not be used directly and is intented to inherited from to be
  48296. * customized per effects.
  48297. */
  48298. export abstract class EffectLayer {
  48299. private _vertexBuffers;
  48300. private _indexBuffer;
  48301. private _cachedDefines;
  48302. private _effectLayerMapGenerationEffect;
  48303. private _effectLayerOptions;
  48304. private _mergeEffect;
  48305. protected _scene: Scene;
  48306. protected _engine: Engine;
  48307. protected _maxSize: number;
  48308. protected _mainTextureDesiredSize: ISize;
  48309. protected _mainTexture: RenderTargetTexture;
  48310. protected _shouldRender: boolean;
  48311. protected _postProcesses: PostProcess[];
  48312. protected _textures: BaseTexture[];
  48313. protected _emissiveTextureAndColor: {
  48314. texture: Nullable<BaseTexture>;
  48315. color: Color4;
  48316. };
  48317. /**
  48318. * The name of the layer
  48319. */
  48320. name: string;
  48321. /**
  48322. * The clear color of the texture used to generate the glow map.
  48323. */
  48324. neutralColor: Color4;
  48325. /**
  48326. * Specifies wether the highlight layer is enabled or not.
  48327. */
  48328. isEnabled: boolean;
  48329. /**
  48330. * Gets the camera attached to the layer.
  48331. */
  48332. readonly camera: Nullable<Camera>;
  48333. /**
  48334. * Gets the rendering group id the layer should render in.
  48335. */
  48336. readonly renderingGroupId: number;
  48337. /**
  48338. * An event triggered when the effect layer has been disposed.
  48339. */
  48340. onDisposeObservable: Observable<EffectLayer>;
  48341. /**
  48342. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48343. */
  48344. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48345. /**
  48346. * An event triggered when the generated texture is being merged in the scene.
  48347. */
  48348. onBeforeComposeObservable: Observable<EffectLayer>;
  48349. /**
  48350. * An event triggered when the generated texture has been merged in the scene.
  48351. */
  48352. onAfterComposeObservable: Observable<EffectLayer>;
  48353. /**
  48354. * An event triggered when the efffect layer changes its size.
  48355. */
  48356. onSizeChangedObservable: Observable<EffectLayer>;
  48357. /** @hidden */
  48358. static _SceneComponentInitialization: (scene: Scene) => void;
  48359. /**
  48360. * Instantiates a new effect Layer and references it in the scene.
  48361. * @param name The name of the layer
  48362. * @param scene The scene to use the layer in
  48363. */
  48364. constructor(
  48365. /** The Friendly of the effect in the scene */
  48366. name: string, scene: Scene);
  48367. /**
  48368. * Get the effect name of the layer.
  48369. * @return The effect name
  48370. */
  48371. abstract getEffectName(): string;
  48372. /**
  48373. * Checks for the readiness of the element composing the layer.
  48374. * @param subMesh the mesh to check for
  48375. * @param useInstances specify wether or not to use instances to render the mesh
  48376. * @return true if ready otherwise, false
  48377. */
  48378. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48379. /**
  48380. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48381. * @returns true if the effect requires stencil during the main canvas render pass.
  48382. */
  48383. abstract needStencil(): boolean;
  48384. /**
  48385. * Create the merge effect. This is the shader use to blit the information back
  48386. * to the main canvas at the end of the scene rendering.
  48387. * @returns The effect containing the shader used to merge the effect on the main canvas
  48388. */
  48389. protected abstract _createMergeEffect(): Effect;
  48390. /**
  48391. * Creates the render target textures and post processes used in the effect layer.
  48392. */
  48393. protected abstract _createTextureAndPostProcesses(): void;
  48394. /**
  48395. * Implementation specific of rendering the generating effect on the main canvas.
  48396. * @param effect The effect used to render through
  48397. */
  48398. protected abstract _internalRender(effect: Effect): void;
  48399. /**
  48400. * Sets the required values for both the emissive texture and and the main color.
  48401. */
  48402. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48403. /**
  48404. * Free any resources and references associated to a mesh.
  48405. * Internal use
  48406. * @param mesh The mesh to free.
  48407. */
  48408. abstract _disposeMesh(mesh: Mesh): void;
  48409. /**
  48410. * Serializes this layer (Glow or Highlight for example)
  48411. * @returns a serialized layer object
  48412. */
  48413. abstract serialize?(): any;
  48414. /**
  48415. * Initializes the effect layer with the required options.
  48416. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48417. */
  48418. protected _init(options: Partial<IEffectLayerOptions>): void;
  48419. /**
  48420. * Generates the index buffer of the full screen quad blending to the main canvas.
  48421. */
  48422. private _generateIndexBuffer;
  48423. /**
  48424. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48425. */
  48426. private _genrateVertexBuffer;
  48427. /**
  48428. * Sets the main texture desired size which is the closest power of two
  48429. * of the engine canvas size.
  48430. */
  48431. private _setMainTextureSize;
  48432. /**
  48433. * Creates the main texture for the effect layer.
  48434. */
  48435. protected _createMainTexture(): void;
  48436. /**
  48437. * Adds specific effects defines.
  48438. * @param defines The defines to add specifics to.
  48439. */
  48440. protected _addCustomEffectDefines(defines: string[]): void;
  48441. /**
  48442. * Checks for the readiness of the element composing the layer.
  48443. * @param subMesh the mesh to check for
  48444. * @param useInstances specify wether or not to use instances to render the mesh
  48445. * @param emissiveTexture the associated emissive texture used to generate the glow
  48446. * @return true if ready otherwise, false
  48447. */
  48448. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48449. /**
  48450. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48451. */
  48452. render(): void;
  48453. /**
  48454. * Determine if a given mesh will be used in the current effect.
  48455. * @param mesh mesh to test
  48456. * @returns true if the mesh will be used
  48457. */
  48458. hasMesh(mesh: AbstractMesh): boolean;
  48459. /**
  48460. * Returns true if the layer contains information to display, otherwise false.
  48461. * @returns true if the glow layer should be rendered
  48462. */
  48463. shouldRender(): boolean;
  48464. /**
  48465. * Returns true if the mesh should render, otherwise false.
  48466. * @param mesh The mesh to render
  48467. * @returns true if it should render otherwise false
  48468. */
  48469. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48470. /**
  48471. * Returns true if the mesh can be rendered, otherwise false.
  48472. * @param mesh The mesh to render
  48473. * @param material The material used on the mesh
  48474. * @returns true if it can be rendered otherwise false
  48475. */
  48476. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48477. /**
  48478. * Returns true if the mesh should render, otherwise false.
  48479. * @param mesh The mesh to render
  48480. * @returns true if it should render otherwise false
  48481. */
  48482. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48483. /**
  48484. * Renders the submesh passed in parameter to the generation map.
  48485. */
  48486. protected _renderSubMesh(subMesh: SubMesh): void;
  48487. /**
  48488. * Rebuild the required buffers.
  48489. * @hidden Internal use only.
  48490. */
  48491. _rebuild(): void;
  48492. /**
  48493. * Dispose only the render target textures and post process.
  48494. */
  48495. private _disposeTextureAndPostProcesses;
  48496. /**
  48497. * Dispose the highlight layer and free resources.
  48498. */
  48499. dispose(): void;
  48500. /**
  48501. * Gets the class name of the effect layer
  48502. * @returns the string with the class name of the effect layer
  48503. */
  48504. getClassName(): string;
  48505. /**
  48506. * Creates an effect layer from parsed effect layer data
  48507. * @param parsedEffectLayer defines effect layer data
  48508. * @param scene defines the current scene
  48509. * @param rootUrl defines the root URL containing the effect layer information
  48510. * @returns a parsed effect Layer
  48511. */
  48512. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48513. }
  48514. }
  48515. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  48516. import { Scene } from "babylonjs/scene";
  48517. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48518. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48519. import { AbstractScene } from "babylonjs/abstractScene";
  48520. module "babylonjs/abstractScene" {
  48521. interface AbstractScene {
  48522. /**
  48523. * The list of effect layers (highlights/glow) added to the scene
  48524. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48525. * @see http://doc.babylonjs.com/how_to/glow_layer
  48526. */
  48527. effectLayers: Array<EffectLayer>;
  48528. /**
  48529. * Removes the given effect layer from this scene.
  48530. * @param toRemove defines the effect layer to remove
  48531. * @returns the index of the removed effect layer
  48532. */
  48533. removeEffectLayer(toRemove: EffectLayer): number;
  48534. /**
  48535. * Adds the given effect layer to this scene
  48536. * @param newEffectLayer defines the effect layer to add
  48537. */
  48538. addEffectLayer(newEffectLayer: EffectLayer): void;
  48539. }
  48540. }
  48541. /**
  48542. * Defines the layer scene component responsible to manage any effect layers
  48543. * in a given scene.
  48544. */
  48545. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48546. /**
  48547. * The component name helpfull to identify the component in the list of scene components.
  48548. */
  48549. readonly name: string;
  48550. /**
  48551. * The scene the component belongs to.
  48552. */
  48553. scene: Scene;
  48554. private _engine;
  48555. private _renderEffects;
  48556. private _needStencil;
  48557. private _previousStencilState;
  48558. /**
  48559. * Creates a new instance of the component for the given scene
  48560. * @param scene Defines the scene to register the component in
  48561. */
  48562. constructor(scene: Scene);
  48563. /**
  48564. * Registers the component in a given scene
  48565. */
  48566. register(): void;
  48567. /**
  48568. * Rebuilds the elements related to this component in case of
  48569. * context lost for instance.
  48570. */
  48571. rebuild(): void;
  48572. /**
  48573. * Serializes the component data to the specified json object
  48574. * @param serializationObject The object to serialize to
  48575. */
  48576. serialize(serializationObject: any): void;
  48577. /**
  48578. * Adds all the element from the container to the scene
  48579. * @param container the container holding the elements
  48580. */
  48581. addFromContainer(container: AbstractScene): void;
  48582. /**
  48583. * Removes all the elements in the container from the scene
  48584. * @param container contains the elements to remove
  48585. * @param dispose if the removed element should be disposed (default: false)
  48586. */
  48587. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48588. /**
  48589. * Disposes the component and the associated ressources.
  48590. */
  48591. dispose(): void;
  48592. private _isReadyForMesh;
  48593. private _renderMainTexture;
  48594. private _setStencil;
  48595. private _setStencilBack;
  48596. private _draw;
  48597. private _drawCamera;
  48598. private _drawRenderingGroup;
  48599. }
  48600. }
  48601. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  48602. /** @hidden */
  48603. export var glowMapMergePixelShader: {
  48604. name: string;
  48605. shader: string;
  48606. };
  48607. }
  48608. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  48609. /** @hidden */
  48610. export var glowMapMergeVertexShader: {
  48611. name: string;
  48612. shader: string;
  48613. };
  48614. }
  48615. declare module "babylonjs/Layers/glowLayer" {
  48616. import { Nullable } from "babylonjs/types";
  48617. import { Camera } from "babylonjs/Cameras/camera";
  48618. import { Scene } from "babylonjs/scene";
  48619. import { Color4 } from "babylonjs/Maths/math";
  48620. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48622. import { Mesh } from "babylonjs/Meshes/mesh";
  48623. import { Texture } from "babylonjs/Materials/Textures/texture";
  48624. import { Effect } from "babylonjs/Materials/effect";
  48625. import { Material } from "babylonjs/Materials/material";
  48626. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48627. import "babylonjs/Shaders/glowMapMerge.fragment";
  48628. import "babylonjs/Shaders/glowMapMerge.vertex";
  48629. import "babylonjs/Layers/effectLayerSceneComponent";
  48630. module "babylonjs/abstractScene" {
  48631. interface AbstractScene {
  48632. /**
  48633. * Return a the first highlight layer of the scene with a given name.
  48634. * @param name The name of the highlight layer to look for.
  48635. * @return The highlight layer if found otherwise null.
  48636. */
  48637. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48638. }
  48639. }
  48640. /**
  48641. * Glow layer options. This helps customizing the behaviour
  48642. * of the glow layer.
  48643. */
  48644. export interface IGlowLayerOptions {
  48645. /**
  48646. * Multiplication factor apply to the canvas size to compute the render target size
  48647. * used to generated the glowing objects (the smaller the faster).
  48648. */
  48649. mainTextureRatio: number;
  48650. /**
  48651. * Enforces a fixed size texture to ensure resize independant blur.
  48652. */
  48653. mainTextureFixedSize?: number;
  48654. /**
  48655. * How big is the kernel of the blur texture.
  48656. */
  48657. blurKernelSize: number;
  48658. /**
  48659. * The camera attached to the layer.
  48660. */
  48661. camera: Nullable<Camera>;
  48662. /**
  48663. * Enable MSAA by chosing the number of samples.
  48664. */
  48665. mainTextureSamples?: number;
  48666. /**
  48667. * The rendering group to draw the layer in.
  48668. */
  48669. renderingGroupId: number;
  48670. }
  48671. /**
  48672. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48673. *
  48674. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48675. * glowy meshes to your scene.
  48676. *
  48677. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48678. */
  48679. export class GlowLayer extends EffectLayer {
  48680. /**
  48681. * Effect Name of the layer.
  48682. */
  48683. static readonly EffectName: string;
  48684. /**
  48685. * The default blur kernel size used for the glow.
  48686. */
  48687. static DefaultBlurKernelSize: number;
  48688. /**
  48689. * The default texture size ratio used for the glow.
  48690. */
  48691. static DefaultTextureRatio: number;
  48692. /**
  48693. * Sets the kernel size of the blur.
  48694. */
  48695. /**
  48696. * Gets the kernel size of the blur.
  48697. */
  48698. blurKernelSize: number;
  48699. /**
  48700. * Sets the glow intensity.
  48701. */
  48702. /**
  48703. * Gets the glow intensity.
  48704. */
  48705. intensity: number;
  48706. private _options;
  48707. private _intensity;
  48708. private _horizontalBlurPostprocess1;
  48709. private _verticalBlurPostprocess1;
  48710. private _horizontalBlurPostprocess2;
  48711. private _verticalBlurPostprocess2;
  48712. private _blurTexture1;
  48713. private _blurTexture2;
  48714. private _postProcesses1;
  48715. private _postProcesses2;
  48716. private _includedOnlyMeshes;
  48717. private _excludedMeshes;
  48718. /**
  48719. * Callback used to let the user override the color selection on a per mesh basis
  48720. */
  48721. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48722. /**
  48723. * Callback used to let the user override the texture selection on a per mesh basis
  48724. */
  48725. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48726. /**
  48727. * Instantiates a new glow Layer and references it to the scene.
  48728. * @param name The name of the layer
  48729. * @param scene The scene to use the layer in
  48730. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48731. */
  48732. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48733. /**
  48734. * Get the effect name of the layer.
  48735. * @return The effect name
  48736. */
  48737. getEffectName(): string;
  48738. /**
  48739. * Create the merge effect. This is the shader use to blit the information back
  48740. * to the main canvas at the end of the scene rendering.
  48741. */
  48742. protected _createMergeEffect(): Effect;
  48743. /**
  48744. * Creates the render target textures and post processes used in the glow layer.
  48745. */
  48746. protected _createTextureAndPostProcesses(): void;
  48747. /**
  48748. * Checks for the readiness of the element composing the layer.
  48749. * @param subMesh the mesh to check for
  48750. * @param useInstances specify wether or not to use instances to render the mesh
  48751. * @param emissiveTexture the associated emissive texture used to generate the glow
  48752. * @return true if ready otherwise, false
  48753. */
  48754. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48755. /**
  48756. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48757. */
  48758. needStencil(): boolean;
  48759. /**
  48760. * Returns true if the mesh can be rendered, otherwise false.
  48761. * @param mesh The mesh to render
  48762. * @param material The material used on the mesh
  48763. * @returns true if it can be rendered otherwise false
  48764. */
  48765. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48766. /**
  48767. * Implementation specific of rendering the generating effect on the main canvas.
  48768. * @param effect The effect used to render through
  48769. */
  48770. protected _internalRender(effect: Effect): void;
  48771. /**
  48772. * Sets the required values for both the emissive texture and and the main color.
  48773. */
  48774. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48775. /**
  48776. * Returns true if the mesh should render, otherwise false.
  48777. * @param mesh The mesh to render
  48778. * @returns true if it should render otherwise false
  48779. */
  48780. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48781. /**
  48782. * Adds specific effects defines.
  48783. * @param defines The defines to add specifics to.
  48784. */
  48785. protected _addCustomEffectDefines(defines: string[]): void;
  48786. /**
  48787. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48788. * @param mesh The mesh to exclude from the glow layer
  48789. */
  48790. addExcludedMesh(mesh: Mesh): void;
  48791. /**
  48792. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48793. * @param mesh The mesh to remove
  48794. */
  48795. removeExcludedMesh(mesh: Mesh): void;
  48796. /**
  48797. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48798. * @param mesh The mesh to include in the glow layer
  48799. */
  48800. addIncludedOnlyMesh(mesh: Mesh): void;
  48801. /**
  48802. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48803. * @param mesh The mesh to remove
  48804. */
  48805. removeIncludedOnlyMesh(mesh: Mesh): void;
  48806. /**
  48807. * Determine if a given mesh will be used in the glow layer
  48808. * @param mesh The mesh to test
  48809. * @returns true if the mesh will be highlighted by the current glow layer
  48810. */
  48811. hasMesh(mesh: AbstractMesh): boolean;
  48812. /**
  48813. * Free any resources and references associated to a mesh.
  48814. * Internal use
  48815. * @param mesh The mesh to free.
  48816. * @hidden
  48817. */
  48818. _disposeMesh(mesh: Mesh): void;
  48819. /**
  48820. * Gets the class name of the effect layer
  48821. * @returns the string with the class name of the effect layer
  48822. */
  48823. getClassName(): string;
  48824. /**
  48825. * Serializes this glow layer
  48826. * @returns a serialized glow layer object
  48827. */
  48828. serialize(): any;
  48829. /**
  48830. * Creates a Glow Layer from parsed glow layer data
  48831. * @param parsedGlowLayer defines glow layer data
  48832. * @param scene defines the current scene
  48833. * @param rootUrl defines the root URL containing the glow layer information
  48834. * @returns a parsed Glow Layer
  48835. */
  48836. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48837. }
  48838. }
  48839. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  48840. /** @hidden */
  48841. export var glowBlurPostProcessPixelShader: {
  48842. name: string;
  48843. shader: string;
  48844. };
  48845. }
  48846. declare module "babylonjs/Layers/highlightLayer" {
  48847. import { Observable } from "babylonjs/Misc/observable";
  48848. import { Nullable } from "babylonjs/types";
  48849. import { Camera } from "babylonjs/Cameras/camera";
  48850. import { Scene } from "babylonjs/scene";
  48851. import { Color3, Color4 } from "babylonjs/Maths/math";
  48852. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48854. import { Mesh } from "babylonjs/Meshes/mesh";
  48855. import { Effect } from "babylonjs/Materials/effect";
  48856. import { Material } from "babylonjs/Materials/material";
  48857. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48858. import "babylonjs/Shaders/glowMapMerge.fragment";
  48859. import "babylonjs/Shaders/glowMapMerge.vertex";
  48860. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  48861. module "babylonjs/abstractScene" {
  48862. interface AbstractScene {
  48863. /**
  48864. * Return a the first highlight layer of the scene with a given name.
  48865. * @param name The name of the highlight layer to look for.
  48866. * @return The highlight layer if found otherwise null.
  48867. */
  48868. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48869. }
  48870. }
  48871. /**
  48872. * Highlight layer options. This helps customizing the behaviour
  48873. * of the highlight layer.
  48874. */
  48875. export interface IHighlightLayerOptions {
  48876. /**
  48877. * Multiplication factor apply to the canvas size to compute the render target size
  48878. * used to generated the glowing objects (the smaller the faster).
  48879. */
  48880. mainTextureRatio: number;
  48881. /**
  48882. * Enforces a fixed size texture to ensure resize independant blur.
  48883. */
  48884. mainTextureFixedSize?: number;
  48885. /**
  48886. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48887. * of the picture to blur (the smaller the faster).
  48888. */
  48889. blurTextureSizeRatio: number;
  48890. /**
  48891. * How big in texel of the blur texture is the vertical blur.
  48892. */
  48893. blurVerticalSize: number;
  48894. /**
  48895. * How big in texel of the blur texture is the horizontal blur.
  48896. */
  48897. blurHorizontalSize: number;
  48898. /**
  48899. * Alpha blending mode used to apply the blur. Default is combine.
  48900. */
  48901. alphaBlendingMode: number;
  48902. /**
  48903. * The camera attached to the layer.
  48904. */
  48905. camera: Nullable<Camera>;
  48906. /**
  48907. * Should we display highlight as a solid stroke?
  48908. */
  48909. isStroke?: boolean;
  48910. /**
  48911. * The rendering group to draw the layer in.
  48912. */
  48913. renderingGroupId: number;
  48914. }
  48915. /**
  48916. * The highlight layer Helps adding a glow effect around a mesh.
  48917. *
  48918. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48919. * glowy meshes to your scene.
  48920. *
  48921. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48922. */
  48923. export class HighlightLayer extends EffectLayer {
  48924. name: string;
  48925. /**
  48926. * Effect Name of the highlight layer.
  48927. */
  48928. static readonly EffectName: string;
  48929. /**
  48930. * The neutral color used during the preparation of the glow effect.
  48931. * This is black by default as the blend operation is a blend operation.
  48932. */
  48933. static NeutralColor: Color4;
  48934. /**
  48935. * Stencil value used for glowing meshes.
  48936. */
  48937. static GlowingMeshStencilReference: number;
  48938. /**
  48939. * Stencil value used for the other meshes in the scene.
  48940. */
  48941. static NormalMeshStencilReference: number;
  48942. /**
  48943. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48944. */
  48945. innerGlow: boolean;
  48946. /**
  48947. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48948. */
  48949. outerGlow: boolean;
  48950. /**
  48951. * Specifies the horizontal size of the blur.
  48952. */
  48953. /**
  48954. * Gets the horizontal size of the blur.
  48955. */
  48956. blurHorizontalSize: number;
  48957. /**
  48958. * Specifies the vertical size of the blur.
  48959. */
  48960. /**
  48961. * Gets the vertical size of the blur.
  48962. */
  48963. blurVerticalSize: number;
  48964. /**
  48965. * An event triggered when the highlight layer is being blurred.
  48966. */
  48967. onBeforeBlurObservable: Observable<HighlightLayer>;
  48968. /**
  48969. * An event triggered when the highlight layer has been blurred.
  48970. */
  48971. onAfterBlurObservable: Observable<HighlightLayer>;
  48972. private _instanceGlowingMeshStencilReference;
  48973. private _options;
  48974. private _downSamplePostprocess;
  48975. private _horizontalBlurPostprocess;
  48976. private _verticalBlurPostprocess;
  48977. private _blurTexture;
  48978. private _meshes;
  48979. private _excludedMeshes;
  48980. /**
  48981. * Instantiates a new highlight Layer and references it to the scene..
  48982. * @param name The name of the layer
  48983. * @param scene The scene to use the layer in
  48984. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48985. */
  48986. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48987. /**
  48988. * Get the effect name of the layer.
  48989. * @return The effect name
  48990. */
  48991. getEffectName(): string;
  48992. /**
  48993. * Create the merge effect. This is the shader use to blit the information back
  48994. * to the main canvas at the end of the scene rendering.
  48995. */
  48996. protected _createMergeEffect(): Effect;
  48997. /**
  48998. * Creates the render target textures and post processes used in the highlight layer.
  48999. */
  49000. protected _createTextureAndPostProcesses(): void;
  49001. /**
  49002. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49003. */
  49004. needStencil(): boolean;
  49005. /**
  49006. * Checks for the readiness of the element composing the layer.
  49007. * @param subMesh the mesh to check for
  49008. * @param useInstances specify wether or not to use instances to render the mesh
  49009. * @param emissiveTexture the associated emissive texture used to generate the glow
  49010. * @return true if ready otherwise, false
  49011. */
  49012. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49013. /**
  49014. * Implementation specific of rendering the generating effect on the main canvas.
  49015. * @param effect The effect used to render through
  49016. */
  49017. protected _internalRender(effect: Effect): void;
  49018. /**
  49019. * Returns true if the layer contains information to display, otherwise false.
  49020. */
  49021. shouldRender(): boolean;
  49022. /**
  49023. * Returns true if the mesh should render, otherwise false.
  49024. * @param mesh The mesh to render
  49025. * @returns true if it should render otherwise false
  49026. */
  49027. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49028. /**
  49029. * Sets the required values for both the emissive texture and and the main color.
  49030. */
  49031. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49032. /**
  49033. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49034. * @param mesh The mesh to exclude from the highlight layer
  49035. */
  49036. addExcludedMesh(mesh: Mesh): void;
  49037. /**
  49038. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49039. * @param mesh The mesh to highlight
  49040. */
  49041. removeExcludedMesh(mesh: Mesh): void;
  49042. /**
  49043. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49044. * @param mesh mesh to test
  49045. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49046. */
  49047. hasMesh(mesh: AbstractMesh): boolean;
  49048. /**
  49049. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49050. * @param mesh The mesh to highlight
  49051. * @param color The color of the highlight
  49052. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49053. */
  49054. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49055. /**
  49056. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49057. * @param mesh The mesh to highlight
  49058. */
  49059. removeMesh(mesh: Mesh): void;
  49060. /**
  49061. * Force the stencil to the normal expected value for none glowing parts
  49062. */
  49063. private _defaultStencilReference;
  49064. /**
  49065. * Free any resources and references associated to a mesh.
  49066. * Internal use
  49067. * @param mesh The mesh to free.
  49068. * @hidden
  49069. */
  49070. _disposeMesh(mesh: Mesh): void;
  49071. /**
  49072. * Dispose the highlight layer and free resources.
  49073. */
  49074. dispose(): void;
  49075. /**
  49076. * Gets the class name of the effect layer
  49077. * @returns the string with the class name of the effect layer
  49078. */
  49079. getClassName(): string;
  49080. /**
  49081. * Serializes this Highlight layer
  49082. * @returns a serialized Highlight layer object
  49083. */
  49084. serialize(): any;
  49085. /**
  49086. * Creates a Highlight layer from parsed Highlight layer data
  49087. * @param parsedHightlightLayer defines the Highlight layer data
  49088. * @param scene defines the current scene
  49089. * @param rootUrl defines the root URL containing the Highlight layer information
  49090. * @returns a parsed Highlight layer
  49091. */
  49092. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49093. }
  49094. }
  49095. declare module "babylonjs/Layers/index" {
  49096. export * from "babylonjs/Layers/effectLayer";
  49097. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49098. export * from "babylonjs/Layers/glowLayer";
  49099. export * from "babylonjs/Layers/highlightLayer";
  49100. export * from "babylonjs/Layers/layer";
  49101. export * from "babylonjs/Layers/layerSceneComponent";
  49102. }
  49103. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49104. /** @hidden */
  49105. export var lensFlarePixelShader: {
  49106. name: string;
  49107. shader: string;
  49108. };
  49109. }
  49110. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49111. /** @hidden */
  49112. export var lensFlareVertexShader: {
  49113. name: string;
  49114. shader: string;
  49115. };
  49116. }
  49117. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49118. import { Scene } from "babylonjs/scene";
  49119. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49121. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49122. import "babylonjs/Shaders/lensFlare.fragment";
  49123. import "babylonjs/Shaders/lensFlare.vertex";
  49124. /**
  49125. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49126. * It is usually composed of several `lensFlare`.
  49127. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49128. */
  49129. export class LensFlareSystem {
  49130. /**
  49131. * Define the name of the lens flare system
  49132. */
  49133. name: string;
  49134. /**
  49135. * List of lens flares used in this system.
  49136. */
  49137. lensFlares: LensFlare[];
  49138. /**
  49139. * Define a limit from the border the lens flare can be visible.
  49140. */
  49141. borderLimit: number;
  49142. /**
  49143. * Define a viewport border we do not want to see the lens flare in.
  49144. */
  49145. viewportBorder: number;
  49146. /**
  49147. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49148. */
  49149. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49150. /**
  49151. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49152. */
  49153. layerMask: number;
  49154. /**
  49155. * Define the id of the lens flare system in the scene.
  49156. * (equal to name by default)
  49157. */
  49158. id: string;
  49159. private _scene;
  49160. private _emitter;
  49161. private _vertexBuffers;
  49162. private _indexBuffer;
  49163. private _effect;
  49164. private _positionX;
  49165. private _positionY;
  49166. private _isEnabled;
  49167. /** @hidden */
  49168. static _SceneComponentInitialization: (scene: Scene) => void;
  49169. /**
  49170. * Instantiates a lens flare system.
  49171. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49172. * It is usually composed of several `lensFlare`.
  49173. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49174. * @param name Define the name of the lens flare system in the scene
  49175. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49176. * @param scene Define the scene the lens flare system belongs to
  49177. */
  49178. constructor(
  49179. /**
  49180. * Define the name of the lens flare system
  49181. */
  49182. name: string, emitter: any, scene: Scene);
  49183. /**
  49184. * Define if the lens flare system is enabled.
  49185. */
  49186. isEnabled: boolean;
  49187. /**
  49188. * Get the scene the effects belongs to.
  49189. * @returns the scene holding the lens flare system
  49190. */
  49191. getScene(): Scene;
  49192. /**
  49193. * Get the emitter of the lens flare system.
  49194. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49195. * @returns the emitter of the lens flare system
  49196. */
  49197. getEmitter(): any;
  49198. /**
  49199. * Set the emitter of the lens flare system.
  49200. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49201. * @param newEmitter Define the new emitter of the system
  49202. */
  49203. setEmitter(newEmitter: any): void;
  49204. /**
  49205. * Get the lens flare system emitter position.
  49206. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49207. * @returns the position
  49208. */
  49209. getEmitterPosition(): Vector3;
  49210. /**
  49211. * @hidden
  49212. */
  49213. computeEffectivePosition(globalViewport: Viewport): boolean;
  49214. /** @hidden */
  49215. _isVisible(): boolean;
  49216. /**
  49217. * @hidden
  49218. */
  49219. render(): boolean;
  49220. /**
  49221. * Dispose and release the lens flare with its associated resources.
  49222. */
  49223. dispose(): void;
  49224. /**
  49225. * Parse a lens flare system from a JSON repressentation
  49226. * @param parsedLensFlareSystem Define the JSON to parse
  49227. * @param scene Define the scene the parsed system should be instantiated in
  49228. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49229. * @returns the parsed system
  49230. */
  49231. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49232. /**
  49233. * Serialize the current Lens Flare System into a JSON representation.
  49234. * @returns the serialized JSON
  49235. */
  49236. serialize(): any;
  49237. }
  49238. }
  49239. declare module "babylonjs/LensFlares/lensFlare" {
  49240. import { Nullable } from "babylonjs/types";
  49241. import { Color3 } from "babylonjs/Maths/math";
  49242. import { Texture } from "babylonjs/Materials/Textures/texture";
  49243. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49244. /**
  49245. * This represents one of the lens effect in a `lensFlareSystem`.
  49246. * It controls one of the indiviual texture used in the effect.
  49247. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49248. */
  49249. export class LensFlare {
  49250. /**
  49251. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49252. */
  49253. size: number;
  49254. /**
  49255. * 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.
  49256. */
  49257. position: number;
  49258. /**
  49259. * Define the lens color.
  49260. */
  49261. color: Color3;
  49262. /**
  49263. * Define the lens texture.
  49264. */
  49265. texture: Nullable<Texture>;
  49266. /**
  49267. * Define the alpha mode to render this particular lens.
  49268. */
  49269. alphaMode: number;
  49270. private _system;
  49271. /**
  49272. * Creates a new Lens Flare.
  49273. * This represents one of the lens effect in a `lensFlareSystem`.
  49274. * It controls one of the indiviual texture used in the effect.
  49275. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49276. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49277. * @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.
  49278. * @param color Define the lens color
  49279. * @param imgUrl Define the lens texture url
  49280. * @param system Define the `lensFlareSystem` this flare is part of
  49281. * @returns The newly created Lens Flare
  49282. */
  49283. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49284. /**
  49285. * Instantiates a new Lens Flare.
  49286. * This represents one of the lens effect in a `lensFlareSystem`.
  49287. * It controls one of the indiviual texture used in the effect.
  49288. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49289. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49290. * @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.
  49291. * @param color Define the lens color
  49292. * @param imgUrl Define the lens texture url
  49293. * @param system Define the `lensFlareSystem` this flare is part of
  49294. */
  49295. constructor(
  49296. /**
  49297. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49298. */
  49299. size: number,
  49300. /**
  49301. * 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.
  49302. */
  49303. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49304. /**
  49305. * Dispose and release the lens flare with its associated resources.
  49306. */
  49307. dispose(): void;
  49308. }
  49309. }
  49310. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49311. import { Nullable } from "babylonjs/types";
  49312. import { Scene } from "babylonjs/scene";
  49313. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49314. import { AbstractScene } from "babylonjs/abstractScene";
  49315. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49316. module "babylonjs/abstractScene" {
  49317. interface AbstractScene {
  49318. /**
  49319. * The list of lens flare system added to the scene
  49320. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49321. */
  49322. lensFlareSystems: Array<LensFlareSystem>;
  49323. /**
  49324. * Removes the given lens flare system from this scene.
  49325. * @param toRemove The lens flare system to remove
  49326. * @returns The index of the removed lens flare system
  49327. */
  49328. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49329. /**
  49330. * Adds the given lens flare system to this scene
  49331. * @param newLensFlareSystem The lens flare system to add
  49332. */
  49333. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49334. /**
  49335. * Gets a lens flare system using its name
  49336. * @param name defines the name to look for
  49337. * @returns the lens flare system or null if not found
  49338. */
  49339. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49340. /**
  49341. * Gets a lens flare system using its id
  49342. * @param id defines the id to look for
  49343. * @returns the lens flare system or null if not found
  49344. */
  49345. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49346. }
  49347. }
  49348. /**
  49349. * Defines the lens flare scene component responsible to manage any lens flares
  49350. * in a given scene.
  49351. */
  49352. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49353. /**
  49354. * The component name helpfull to identify the component in the list of scene components.
  49355. */
  49356. readonly name: string;
  49357. /**
  49358. * The scene the component belongs to.
  49359. */
  49360. scene: Scene;
  49361. /**
  49362. * Creates a new instance of the component for the given scene
  49363. * @param scene Defines the scene to register the component in
  49364. */
  49365. constructor(scene: Scene);
  49366. /**
  49367. * Registers the component in a given scene
  49368. */
  49369. register(): void;
  49370. /**
  49371. * Rebuilds the elements related to this component in case of
  49372. * context lost for instance.
  49373. */
  49374. rebuild(): void;
  49375. /**
  49376. * Adds all the element from the container to the scene
  49377. * @param container the container holding the elements
  49378. */
  49379. addFromContainer(container: AbstractScene): void;
  49380. /**
  49381. * Removes all the elements in the container from the scene
  49382. * @param container contains the elements to remove
  49383. * @param dispose if the removed element should be disposed (default: false)
  49384. */
  49385. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49386. /**
  49387. * Serializes the component data to the specified json object
  49388. * @param serializationObject The object to serialize to
  49389. */
  49390. serialize(serializationObject: any): void;
  49391. /**
  49392. * Disposes the component and the associated ressources.
  49393. */
  49394. dispose(): void;
  49395. private _draw;
  49396. }
  49397. }
  49398. declare module "babylonjs/LensFlares/index" {
  49399. export * from "babylonjs/LensFlares/lensFlare";
  49400. export * from "babylonjs/LensFlares/lensFlareSystem";
  49401. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49402. }
  49403. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49404. import { Scene } from "babylonjs/scene";
  49405. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49406. import { AbstractScene } from "babylonjs/abstractScene";
  49407. /**
  49408. * Defines the shadow generator component responsible to manage any shadow generators
  49409. * in a given scene.
  49410. */
  49411. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49412. /**
  49413. * The component name helpfull to identify the component in the list of scene components.
  49414. */
  49415. readonly name: string;
  49416. /**
  49417. * The scene the component belongs to.
  49418. */
  49419. scene: Scene;
  49420. /**
  49421. * Creates a new instance of the component for the given scene
  49422. * @param scene Defines the scene to register the component in
  49423. */
  49424. constructor(scene: Scene);
  49425. /**
  49426. * Registers the component in a given scene
  49427. */
  49428. register(): void;
  49429. /**
  49430. * Rebuilds the elements related to this component in case of
  49431. * context lost for instance.
  49432. */
  49433. rebuild(): void;
  49434. /**
  49435. * Serializes the component data to the specified json object
  49436. * @param serializationObject The object to serialize to
  49437. */
  49438. serialize(serializationObject: any): void;
  49439. /**
  49440. * Adds all the element from the container to the scene
  49441. * @param container the container holding the elements
  49442. */
  49443. addFromContainer(container: AbstractScene): void;
  49444. /**
  49445. * Removes all the elements in the container from the scene
  49446. * @param container contains the elements to remove
  49447. * @param dispose if the removed element should be disposed (default: false)
  49448. */
  49449. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49450. /**
  49451. * Rebuilds the elements related to this component in case of
  49452. * context lost for instance.
  49453. */
  49454. dispose(): void;
  49455. private _gatherRenderTargets;
  49456. }
  49457. }
  49458. declare module "babylonjs/Lights/Shadows/index" {
  49459. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49460. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49461. }
  49462. declare module "babylonjs/Lights/pointLight" {
  49463. import { Scene } from "babylonjs/scene";
  49464. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49466. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49467. import { Effect } from "babylonjs/Materials/effect";
  49468. /**
  49469. * A point light is a light defined by an unique point in world space.
  49470. * The light is emitted in every direction from this point.
  49471. * A good example of a point light is a standard light bulb.
  49472. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49473. */
  49474. export class PointLight extends ShadowLight {
  49475. private _shadowAngle;
  49476. /**
  49477. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49478. * This specifies what angle the shadow will use to be created.
  49479. *
  49480. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49481. */
  49482. /**
  49483. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49484. * This specifies what angle the shadow will use to be created.
  49485. *
  49486. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49487. */
  49488. shadowAngle: number;
  49489. /**
  49490. * Gets the direction if it has been set.
  49491. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49492. */
  49493. /**
  49494. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49495. */
  49496. direction: Vector3;
  49497. /**
  49498. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49499. * A PointLight emits the light in every direction.
  49500. * It can cast shadows.
  49501. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49502. * ```javascript
  49503. * var pointLight = new PointLight("pl", camera.position, scene);
  49504. * ```
  49505. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49506. * @param name The light friendly name
  49507. * @param position The position of the point light in the scene
  49508. * @param scene The scene the lights belongs to
  49509. */
  49510. constructor(name: string, position: Vector3, scene: Scene);
  49511. /**
  49512. * Returns the string "PointLight"
  49513. * @returns the class name
  49514. */
  49515. getClassName(): string;
  49516. /**
  49517. * Returns the integer 0.
  49518. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49519. */
  49520. getTypeID(): number;
  49521. /**
  49522. * Specifies wether or not the shadowmap should be a cube texture.
  49523. * @returns true if the shadowmap needs to be a cube texture.
  49524. */
  49525. needCube(): boolean;
  49526. /**
  49527. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49528. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49529. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49530. */
  49531. getShadowDirection(faceIndex?: number): Vector3;
  49532. /**
  49533. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49534. * - fov = PI / 2
  49535. * - aspect ratio : 1.0
  49536. * - z-near and far equal to the active camera minZ and maxZ.
  49537. * Returns the PointLight.
  49538. */
  49539. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49540. protected _buildUniformLayout(): void;
  49541. /**
  49542. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49543. * @param effect The effect to update
  49544. * @param lightIndex The index of the light in the effect to update
  49545. * @returns The point light
  49546. */
  49547. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49548. /**
  49549. * Prepares the list of defines specific to the light type.
  49550. * @param defines the list of defines
  49551. * @param lightIndex defines the index of the light for the effect
  49552. */
  49553. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49554. }
  49555. }
  49556. declare module "babylonjs/Lights/index" {
  49557. export * from "babylonjs/Lights/light";
  49558. export * from "babylonjs/Lights/shadowLight";
  49559. export * from "babylonjs/Lights/Shadows/index";
  49560. export * from "babylonjs/Lights/directionalLight";
  49561. export * from "babylonjs/Lights/hemisphericLight";
  49562. export * from "babylonjs/Lights/pointLight";
  49563. export * from "babylonjs/Lights/spotLight";
  49564. }
  49565. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  49566. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49567. /**
  49568. * Header information of HDR texture files.
  49569. */
  49570. export interface HDRInfo {
  49571. /**
  49572. * The height of the texture in pixels.
  49573. */
  49574. height: number;
  49575. /**
  49576. * The width of the texture in pixels.
  49577. */
  49578. width: number;
  49579. /**
  49580. * The index of the beginning of the data in the binary file.
  49581. */
  49582. dataPosition: number;
  49583. }
  49584. /**
  49585. * This groups tools to convert HDR texture to native colors array.
  49586. */
  49587. export class HDRTools {
  49588. private static Ldexp;
  49589. private static Rgbe2float;
  49590. private static readStringLine;
  49591. /**
  49592. * Reads header information from an RGBE texture stored in a native array.
  49593. * More information on this format are available here:
  49594. * https://en.wikipedia.org/wiki/RGBE_image_format
  49595. *
  49596. * @param uint8array The binary file stored in native array.
  49597. * @return The header information.
  49598. */
  49599. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49600. /**
  49601. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49602. * This RGBE texture needs to store the information as a panorama.
  49603. *
  49604. * More information on this format are available here:
  49605. * https://en.wikipedia.org/wiki/RGBE_image_format
  49606. *
  49607. * @param buffer The binary file stored in an array buffer.
  49608. * @param size The expected size of the extracted cubemap.
  49609. * @return The Cube Map information.
  49610. */
  49611. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49612. /**
  49613. * Returns the pixels data extracted from an RGBE texture.
  49614. * This pixels will be stored left to right up to down in the R G B order in one array.
  49615. *
  49616. * More information on this format are available here:
  49617. * https://en.wikipedia.org/wiki/RGBE_image_format
  49618. *
  49619. * @param uint8array The binary file stored in an array buffer.
  49620. * @param hdrInfo The header information of the file.
  49621. * @return The pixels data in RGB right to left up to down order.
  49622. */
  49623. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49624. private static RGBE_ReadPixels_RLE;
  49625. }
  49626. }
  49627. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  49628. import { Nullable } from "babylonjs/types";
  49629. import { Scene } from "babylonjs/scene";
  49630. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49631. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49632. /**
  49633. * This represents a texture coming from an HDR input.
  49634. *
  49635. * The only supported format is currently panorama picture stored in RGBE format.
  49636. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49637. */
  49638. export class HDRCubeTexture extends BaseTexture {
  49639. private static _facesMapping;
  49640. private _generateHarmonics;
  49641. private _noMipmap;
  49642. private _textureMatrix;
  49643. private _size;
  49644. private _onLoad;
  49645. private _onError;
  49646. /**
  49647. * The texture URL.
  49648. */
  49649. url: string;
  49650. /**
  49651. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49652. */
  49653. coordinatesMode: number;
  49654. protected _isBlocking: boolean;
  49655. /**
  49656. * Sets wether or not the texture is blocking during loading.
  49657. */
  49658. /**
  49659. * Gets wether or not the texture is blocking during loading.
  49660. */
  49661. isBlocking: boolean;
  49662. protected _rotationY: number;
  49663. /**
  49664. * Sets texture matrix rotation angle around Y axis in radians.
  49665. */
  49666. /**
  49667. * Gets texture matrix rotation angle around Y axis radians.
  49668. */
  49669. rotationY: number;
  49670. /**
  49671. * Gets or sets the center of the bounding box associated with the cube texture
  49672. * It must define where the camera used to render the texture was set
  49673. */
  49674. boundingBoxPosition: Vector3;
  49675. private _boundingBoxSize;
  49676. /**
  49677. * Gets or sets the size of the bounding box associated with the cube texture
  49678. * When defined, the cubemap will switch to local mode
  49679. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49680. * @example https://www.babylonjs-playground.com/#RNASML
  49681. */
  49682. boundingBoxSize: Vector3;
  49683. /**
  49684. * Instantiates an HDRTexture from the following parameters.
  49685. *
  49686. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49687. * @param scene The scene the texture will be used in
  49688. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49689. * @param noMipmap Forces to not generate the mipmap if true
  49690. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49691. * @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)
  49692. * @param reserved Reserved flag for internal use.
  49693. */
  49694. 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>);
  49695. /**
  49696. * Get the current class name of the texture useful for serialization or dynamic coding.
  49697. * @returns "HDRCubeTexture"
  49698. */
  49699. getClassName(): string;
  49700. /**
  49701. * Occurs when the file is raw .hdr file.
  49702. */
  49703. private loadTexture;
  49704. clone(): HDRCubeTexture;
  49705. delayLoad(): void;
  49706. /**
  49707. * Get the texture reflection matrix used to rotate/transform the reflection.
  49708. * @returns the reflection matrix
  49709. */
  49710. getReflectionTextureMatrix(): Matrix;
  49711. /**
  49712. * Set the texture reflection matrix used to rotate/transform the reflection.
  49713. * @param value Define the reflection matrix to set
  49714. */
  49715. setReflectionTextureMatrix(value: Matrix): void;
  49716. /**
  49717. * Parses a JSON representation of an HDR Texture in order to create the texture
  49718. * @param parsedTexture Define the JSON representation
  49719. * @param scene Define the scene the texture should be created in
  49720. * @param rootUrl Define the root url in case we need to load relative dependencies
  49721. * @returns the newly created texture after parsing
  49722. */
  49723. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49724. serialize(): any;
  49725. }
  49726. }
  49727. declare module "babylonjs/Physics/physicsEngine" {
  49728. import { Nullable } from "babylonjs/types";
  49729. import { Vector3 } from "babylonjs/Maths/math";
  49730. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49731. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49732. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49733. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49734. /**
  49735. * Class used to control physics engine
  49736. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49737. */
  49738. export class PhysicsEngine implements IPhysicsEngine {
  49739. private _physicsPlugin;
  49740. /**
  49741. * Global value used to control the smallest number supported by the simulation
  49742. */
  49743. static Epsilon: number;
  49744. private _impostors;
  49745. private _joints;
  49746. /**
  49747. * Gets the gravity vector used by the simulation
  49748. */
  49749. gravity: Vector3;
  49750. /**
  49751. * Factory used to create the default physics plugin.
  49752. * @returns The default physics plugin
  49753. */
  49754. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49755. /**
  49756. * Creates a new Physics Engine
  49757. * @param gravity defines the gravity vector used by the simulation
  49758. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49759. */
  49760. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49761. /**
  49762. * Sets the gravity vector used by the simulation
  49763. * @param gravity defines the gravity vector to use
  49764. */
  49765. setGravity(gravity: Vector3): void;
  49766. /**
  49767. * Set the time step of the physics engine.
  49768. * Default is 1/60.
  49769. * To slow it down, enter 1/600 for example.
  49770. * To speed it up, 1/30
  49771. * @param newTimeStep defines the new timestep to apply to this world.
  49772. */
  49773. setTimeStep(newTimeStep?: number): void;
  49774. /**
  49775. * Get the time step of the physics engine.
  49776. * @returns the current time step
  49777. */
  49778. getTimeStep(): number;
  49779. /**
  49780. * Release all resources
  49781. */
  49782. dispose(): void;
  49783. /**
  49784. * Gets the name of the current physics plugin
  49785. * @returns the name of the plugin
  49786. */
  49787. getPhysicsPluginName(): string;
  49788. /**
  49789. * Adding a new impostor for the impostor tracking.
  49790. * This will be done by the impostor itself.
  49791. * @param impostor the impostor to add
  49792. */
  49793. addImpostor(impostor: PhysicsImpostor): void;
  49794. /**
  49795. * Remove an impostor from the engine.
  49796. * This impostor and its mesh will not longer be updated by the physics engine.
  49797. * @param impostor the impostor to remove
  49798. */
  49799. removeImpostor(impostor: PhysicsImpostor): void;
  49800. /**
  49801. * Add a joint to the physics engine
  49802. * @param mainImpostor defines the main impostor to which the joint is added.
  49803. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49804. * @param joint defines the joint that will connect both impostors.
  49805. */
  49806. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49807. /**
  49808. * Removes a joint from the simulation
  49809. * @param mainImpostor defines the impostor used with the joint
  49810. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49811. * @param joint defines the joint to remove
  49812. */
  49813. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49814. /**
  49815. * Called by the scene. No need to call it.
  49816. * @param delta defines the timespam between frames
  49817. */
  49818. _step(delta: number): void;
  49819. /**
  49820. * Gets the current plugin used to run the simulation
  49821. * @returns current plugin
  49822. */
  49823. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49824. /**
  49825. * Gets the list of physic impostors
  49826. * @returns an array of PhysicsImpostor
  49827. */
  49828. getImpostors(): Array<PhysicsImpostor>;
  49829. /**
  49830. * Gets the impostor for a physics enabled object
  49831. * @param object defines the object impersonated by the impostor
  49832. * @returns the PhysicsImpostor or null if not found
  49833. */
  49834. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49835. /**
  49836. * Gets the impostor for a physics body object
  49837. * @param body defines physics body used by the impostor
  49838. * @returns the PhysicsImpostor or null if not found
  49839. */
  49840. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49841. /**
  49842. * Does a raycast in the physics world
  49843. * @param from when should the ray start?
  49844. * @param to when should the ray end?
  49845. * @returns PhysicsRaycastResult
  49846. */
  49847. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49848. }
  49849. }
  49850. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49851. import { Nullable } from "babylonjs/types";
  49852. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49854. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49855. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49856. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49857. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49858. /** @hidden */
  49859. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49860. private _useDeltaForWorldStep;
  49861. world: any;
  49862. name: string;
  49863. private _physicsMaterials;
  49864. private _fixedTimeStep;
  49865. private _cannonRaycastResult;
  49866. private _raycastResult;
  49867. private _removeAfterStep;
  49868. BJSCANNON: any;
  49869. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49870. setGravity(gravity: Vector3): void;
  49871. setTimeStep(timeStep: number): void;
  49872. getTimeStep(): number;
  49873. executeStep(delta: number): void;
  49874. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49875. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49876. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49877. private _processChildMeshes;
  49878. removePhysicsBody(impostor: PhysicsImpostor): void;
  49879. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49880. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49881. private _addMaterial;
  49882. private _checkWithEpsilon;
  49883. private _createShape;
  49884. private _createHeightmap;
  49885. private _minus90X;
  49886. private _plus90X;
  49887. private _tmpPosition;
  49888. private _tmpDeltaPosition;
  49889. private _tmpUnityRotation;
  49890. private _updatePhysicsBodyTransformation;
  49891. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49892. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49893. isSupported(): boolean;
  49894. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49895. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49896. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49897. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49898. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49899. getBodyMass(impostor: PhysicsImpostor): number;
  49900. getBodyFriction(impostor: PhysicsImpostor): number;
  49901. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49902. getBodyRestitution(impostor: PhysicsImpostor): number;
  49903. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49904. sleepBody(impostor: PhysicsImpostor): void;
  49905. wakeUpBody(impostor: PhysicsImpostor): void;
  49906. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49907. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49908. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49909. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49910. getRadius(impostor: PhysicsImpostor): number;
  49911. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49912. dispose(): void;
  49913. private _extendNamespace;
  49914. /**
  49915. * Does a raycast in the physics world
  49916. * @param from when should the ray start?
  49917. * @param to when should the ray end?
  49918. * @returns PhysicsRaycastResult
  49919. */
  49920. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49921. }
  49922. }
  49923. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49924. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49925. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49926. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49928. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49929. import { Nullable } from "babylonjs/types";
  49930. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49931. /** @hidden */
  49932. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49933. world: any;
  49934. name: string;
  49935. BJSOIMO: any;
  49936. private _raycastResult;
  49937. constructor(iterations?: number, oimoInjection?: any);
  49938. setGravity(gravity: Vector3): void;
  49939. setTimeStep(timeStep: number): void;
  49940. getTimeStep(): number;
  49941. private _tmpImpostorsArray;
  49942. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49943. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49944. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49945. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49946. private _tmpPositionVector;
  49947. removePhysicsBody(impostor: PhysicsImpostor): void;
  49948. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49949. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49950. isSupported(): boolean;
  49951. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49952. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49953. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49954. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49955. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49956. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49957. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49958. getBodyMass(impostor: PhysicsImpostor): number;
  49959. getBodyFriction(impostor: PhysicsImpostor): number;
  49960. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49961. getBodyRestitution(impostor: PhysicsImpostor): number;
  49962. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49963. sleepBody(impostor: PhysicsImpostor): void;
  49964. wakeUpBody(impostor: PhysicsImpostor): void;
  49965. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49966. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49967. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49968. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49969. getRadius(impostor: PhysicsImpostor): number;
  49970. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49971. dispose(): void;
  49972. /**
  49973. * Does a raycast in the physics world
  49974. * @param from when should the ray start?
  49975. * @param to when should the ray end?
  49976. * @returns PhysicsRaycastResult
  49977. */
  49978. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49979. }
  49980. }
  49981. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49982. import { Nullable } from "babylonjs/types";
  49983. import { Scene } from "babylonjs/scene";
  49984. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49985. import { Mesh } from "babylonjs/Meshes/mesh";
  49986. /**
  49987. * Class containing static functions to help procedurally build meshes
  49988. */
  49989. export class RibbonBuilder {
  49990. /**
  49991. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49992. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49993. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49994. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49995. * * 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
  49996. * * 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
  49997. * * 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
  49998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50000. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50001. * * 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
  50002. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50003. * * 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
  50004. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50006. * @param name defines the name of the mesh
  50007. * @param options defines the options used to create the mesh
  50008. * @param scene defines the hosting scene
  50009. * @returns the ribbon mesh
  50010. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50011. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50012. */
  50013. static CreateRibbon(name: string, options: {
  50014. pathArray: Vector3[][];
  50015. closeArray?: boolean;
  50016. closePath?: boolean;
  50017. offset?: number;
  50018. updatable?: boolean;
  50019. sideOrientation?: number;
  50020. frontUVs?: Vector4;
  50021. backUVs?: Vector4;
  50022. instance?: Mesh;
  50023. invertUV?: boolean;
  50024. uvs?: Vector2[];
  50025. colors?: Color4[];
  50026. }, scene?: Nullable<Scene>): Mesh;
  50027. }
  50028. }
  50029. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50030. import { Nullable } from "babylonjs/types";
  50031. import { Scene } from "babylonjs/scene";
  50032. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50033. import { Mesh } from "babylonjs/Meshes/mesh";
  50034. /**
  50035. * Class containing static functions to help procedurally build meshes
  50036. */
  50037. export class ShapeBuilder {
  50038. /**
  50039. * 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.
  50040. * * 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.
  50041. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50042. * * 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.
  50043. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50044. * * 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
  50045. * * 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
  50046. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50048. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50049. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50051. * @param name defines the name of the mesh
  50052. * @param options defines the options used to create the mesh
  50053. * @param scene defines the hosting scene
  50054. * @returns the extruded shape mesh
  50055. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50056. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50057. */
  50058. static ExtrudeShape(name: string, options: {
  50059. shape: Vector3[];
  50060. path: Vector3[];
  50061. scale?: number;
  50062. rotation?: number;
  50063. cap?: number;
  50064. updatable?: boolean;
  50065. sideOrientation?: number;
  50066. frontUVs?: Vector4;
  50067. backUVs?: Vector4;
  50068. instance?: Mesh;
  50069. invertUV?: boolean;
  50070. }, scene?: Nullable<Scene>): Mesh;
  50071. /**
  50072. * Creates an custom extruded shape mesh.
  50073. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50074. * * 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.
  50075. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50076. * * 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
  50077. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50078. * * 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
  50079. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50080. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50081. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50082. * * 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
  50083. * * 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
  50084. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50086. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50087. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50089. * @param name defines the name of the mesh
  50090. * @param options defines the options used to create the mesh
  50091. * @param scene defines the hosting scene
  50092. * @returns the custom extruded shape mesh
  50093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50094. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50096. */
  50097. static ExtrudeShapeCustom(name: string, options: {
  50098. shape: Vector3[];
  50099. path: Vector3[];
  50100. scaleFunction?: any;
  50101. rotationFunction?: any;
  50102. ribbonCloseArray?: boolean;
  50103. ribbonClosePath?: boolean;
  50104. cap?: number;
  50105. updatable?: boolean;
  50106. sideOrientation?: number;
  50107. frontUVs?: Vector4;
  50108. backUVs?: Vector4;
  50109. instance?: Mesh;
  50110. invertUV?: boolean;
  50111. }, scene?: Nullable<Scene>): Mesh;
  50112. private static _ExtrudeShapeGeneric;
  50113. }
  50114. }
  50115. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50116. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50117. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50118. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50119. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50120. import { Nullable } from "babylonjs/types";
  50121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50122. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50123. /**
  50124. * AmmoJS Physics plugin
  50125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50126. * @see https://github.com/kripken/ammo.js/
  50127. */
  50128. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50129. private _useDeltaForWorldStep;
  50130. /**
  50131. * Reference to the Ammo library
  50132. */
  50133. bjsAMMO: any;
  50134. /**
  50135. * Created ammoJS world which physics bodies are added to
  50136. */
  50137. world: any;
  50138. /**
  50139. * Name of the plugin
  50140. */
  50141. name: string;
  50142. private _timeStep;
  50143. private _fixedTimeStep;
  50144. private _maxSteps;
  50145. private _tmpQuaternion;
  50146. private _tmpAmmoTransform;
  50147. private _tmpAmmoQuaternion;
  50148. private _tmpAmmoConcreteContactResultCallback;
  50149. private _collisionConfiguration;
  50150. private _dispatcher;
  50151. private _overlappingPairCache;
  50152. private _solver;
  50153. private _softBodySolver;
  50154. private _tmpAmmoVectorA;
  50155. private _tmpAmmoVectorB;
  50156. private _tmpAmmoVectorC;
  50157. private _tmpAmmoVectorD;
  50158. private _tmpContactCallbackResult;
  50159. private _tmpAmmoVectorRCA;
  50160. private _tmpAmmoVectorRCB;
  50161. private _raycastResult;
  50162. private static readonly DISABLE_COLLISION_FLAG;
  50163. private static readonly KINEMATIC_FLAG;
  50164. private static readonly DISABLE_DEACTIVATION_FLAG;
  50165. /**
  50166. * Initializes the ammoJS plugin
  50167. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50168. * @param ammoInjection can be used to inject your own ammo reference
  50169. */
  50170. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50171. /**
  50172. * Sets the gravity of the physics world (m/(s^2))
  50173. * @param gravity Gravity to set
  50174. */
  50175. setGravity(gravity: Vector3): void;
  50176. /**
  50177. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50178. * @param timeStep timestep to use in seconds
  50179. */
  50180. setTimeStep(timeStep: number): void;
  50181. /**
  50182. * 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)
  50183. * @param fixedTimeStep fixedTimeStep to use in seconds
  50184. */
  50185. setFixedTimeStep(fixedTimeStep: number): void;
  50186. /**
  50187. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50188. * @param maxSteps the maximum number of steps by the physics engine per frame
  50189. */
  50190. setMaxSteps(maxSteps: number): void;
  50191. /**
  50192. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50193. * @returns the current timestep in seconds
  50194. */
  50195. getTimeStep(): number;
  50196. private _isImpostorInContact;
  50197. private _isImpostorPairInContact;
  50198. private _stepSimulation;
  50199. /**
  50200. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50201. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50202. * After the step the babylon meshes are set to the position of the physics imposters
  50203. * @param delta amount of time to step forward
  50204. * @param impostors array of imposters to update before/after the step
  50205. */
  50206. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50207. /**
  50208. * Update babylon mesh to match physics world object
  50209. * @param impostor imposter to match
  50210. */
  50211. private _afterSoftStep;
  50212. /**
  50213. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50214. * @param impostor imposter to match
  50215. */
  50216. private _ropeStep;
  50217. /**
  50218. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50219. * @param impostor imposter to match
  50220. */
  50221. private _softbodyOrClothStep;
  50222. private _tmpVector;
  50223. private _tmpMatrix;
  50224. /**
  50225. * Applies an impulse on the imposter
  50226. * @param impostor imposter to apply impulse to
  50227. * @param force amount of force to be applied to the imposter
  50228. * @param contactPoint the location to apply the impulse on the imposter
  50229. */
  50230. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50231. /**
  50232. * Applies a force on the imposter
  50233. * @param impostor imposter to apply force
  50234. * @param force amount of force to be applied to the imposter
  50235. * @param contactPoint the location to apply the force on the imposter
  50236. */
  50237. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50238. /**
  50239. * Creates a physics body using the plugin
  50240. * @param impostor the imposter to create the physics body on
  50241. */
  50242. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50243. /**
  50244. * Removes the physics body from the imposter and disposes of the body's memory
  50245. * @param impostor imposter to remove the physics body from
  50246. */
  50247. removePhysicsBody(impostor: PhysicsImpostor): void;
  50248. /**
  50249. * Generates a joint
  50250. * @param impostorJoint the imposter joint to create the joint with
  50251. */
  50252. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50253. /**
  50254. * Removes a joint
  50255. * @param impostorJoint the imposter joint to remove the joint from
  50256. */
  50257. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50258. private _addMeshVerts;
  50259. /**
  50260. * Initialise the soft body vertices to match its object's (mesh) vertices
  50261. * Softbody vertices (nodes) are in world space and to match this
  50262. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50263. * @param impostor to create the softbody for
  50264. */
  50265. private _softVertexData;
  50266. /**
  50267. * Create an impostor's soft body
  50268. * @param impostor to create the softbody for
  50269. */
  50270. private _createSoftbody;
  50271. /**
  50272. * Create cloth for an impostor
  50273. * @param impostor to create the softbody for
  50274. */
  50275. private _createCloth;
  50276. /**
  50277. * Create rope for an impostor
  50278. * @param impostor to create the softbody for
  50279. */
  50280. private _createRope;
  50281. private _addHullVerts;
  50282. private _createShape;
  50283. /**
  50284. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50285. * @param impostor imposter containing the physics body and babylon object
  50286. */
  50287. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50288. /**
  50289. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50290. * @param impostor imposter containing the physics body and babylon object
  50291. * @param newPosition new position
  50292. * @param newRotation new rotation
  50293. */
  50294. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50295. /**
  50296. * If this plugin is supported
  50297. * @returns true if its supported
  50298. */
  50299. isSupported(): boolean;
  50300. /**
  50301. * Sets the linear velocity of the physics body
  50302. * @param impostor imposter to set the velocity on
  50303. * @param velocity velocity to set
  50304. */
  50305. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50306. /**
  50307. * Sets the angular velocity of the physics body
  50308. * @param impostor imposter to set the velocity on
  50309. * @param velocity velocity to set
  50310. */
  50311. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50312. /**
  50313. * gets the linear velocity
  50314. * @param impostor imposter to get linear velocity from
  50315. * @returns linear velocity
  50316. */
  50317. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50318. /**
  50319. * gets the angular velocity
  50320. * @param impostor imposter to get angular velocity from
  50321. * @returns angular velocity
  50322. */
  50323. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50324. /**
  50325. * Sets the mass of physics body
  50326. * @param impostor imposter to set the mass on
  50327. * @param mass mass to set
  50328. */
  50329. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50330. /**
  50331. * Gets the mass of the physics body
  50332. * @param impostor imposter to get the mass from
  50333. * @returns mass
  50334. */
  50335. getBodyMass(impostor: PhysicsImpostor): number;
  50336. /**
  50337. * Gets friction of the impostor
  50338. * @param impostor impostor to get friction from
  50339. * @returns friction value
  50340. */
  50341. getBodyFriction(impostor: PhysicsImpostor): number;
  50342. /**
  50343. * Sets friction of the impostor
  50344. * @param impostor impostor to set friction on
  50345. * @param friction friction value
  50346. */
  50347. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50348. /**
  50349. * Gets restitution of the impostor
  50350. * @param impostor impostor to get restitution from
  50351. * @returns restitution value
  50352. */
  50353. getBodyRestitution(impostor: PhysicsImpostor): number;
  50354. /**
  50355. * Sets resitution of the impostor
  50356. * @param impostor impostor to set resitution on
  50357. * @param restitution resitution value
  50358. */
  50359. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50360. /**
  50361. * Gets pressure inside the impostor
  50362. * @param impostor impostor to get pressure from
  50363. * @returns pressure value
  50364. */
  50365. getBodyPressure(impostor: PhysicsImpostor): number;
  50366. /**
  50367. * Sets pressure inside a soft body impostor
  50368. * Cloth and rope must remain 0 pressure
  50369. * @param impostor impostor to set pressure on
  50370. * @param pressure pressure value
  50371. */
  50372. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50373. /**
  50374. * Gets stiffness of the impostor
  50375. * @param impostor impostor to get stiffness from
  50376. * @returns pressure value
  50377. */
  50378. getBodyStiffness(impostor: PhysicsImpostor): number;
  50379. /**
  50380. * Sets stiffness of the impostor
  50381. * @param impostor impostor to set stiffness on
  50382. * @param stiffness stiffness value from 0 to 1
  50383. */
  50384. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50385. /**
  50386. * Gets velocityIterations of the impostor
  50387. * @param impostor impostor to get velocity iterations from
  50388. * @returns velocityIterations value
  50389. */
  50390. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50391. /**
  50392. * Sets velocityIterations of the impostor
  50393. * @param impostor impostor to set velocity iterations on
  50394. * @param velocityIterations velocityIterations value
  50395. */
  50396. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50397. /**
  50398. * Gets positionIterations of the impostor
  50399. * @param impostor impostor to get position iterations from
  50400. * @returns positionIterations value
  50401. */
  50402. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50403. /**
  50404. * Sets positionIterations of the impostor
  50405. * @param impostor impostor to set position on
  50406. * @param positionIterations positionIterations value
  50407. */
  50408. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50409. /**
  50410. * Append an anchor to a cloth object
  50411. * @param impostor is the cloth impostor to add anchor to
  50412. * @param otherImpostor is the rigid impostor to anchor to
  50413. * @param width ratio across width from 0 to 1
  50414. * @param height ratio up height from 0 to 1
  50415. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50416. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50417. */
  50418. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50419. /**
  50420. * Append an hook to a rope object
  50421. * @param impostor is the rope impostor to add hook to
  50422. * @param otherImpostor is the rigid impostor to hook to
  50423. * @param length ratio along the rope from 0 to 1
  50424. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50425. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50426. */
  50427. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50428. /**
  50429. * Sleeps the physics body and stops it from being active
  50430. * @param impostor impostor to sleep
  50431. */
  50432. sleepBody(impostor: PhysicsImpostor): void;
  50433. /**
  50434. * Activates the physics body
  50435. * @param impostor impostor to activate
  50436. */
  50437. wakeUpBody(impostor: PhysicsImpostor): void;
  50438. /**
  50439. * Updates the distance parameters of the joint
  50440. * @param joint joint to update
  50441. * @param maxDistance maximum distance of the joint
  50442. * @param minDistance minimum distance of the joint
  50443. */
  50444. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50445. /**
  50446. * Sets a motor on the joint
  50447. * @param joint joint to set motor on
  50448. * @param speed speed of the motor
  50449. * @param maxForce maximum force of the motor
  50450. * @param motorIndex index of the motor
  50451. */
  50452. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50453. /**
  50454. * Sets the motors limit
  50455. * @param joint joint to set limit on
  50456. * @param upperLimit upper limit
  50457. * @param lowerLimit lower limit
  50458. */
  50459. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50460. /**
  50461. * Syncs the position and rotation of a mesh with the impostor
  50462. * @param mesh mesh to sync
  50463. * @param impostor impostor to update the mesh with
  50464. */
  50465. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50466. /**
  50467. * Gets the radius of the impostor
  50468. * @param impostor impostor to get radius from
  50469. * @returns the radius
  50470. */
  50471. getRadius(impostor: PhysicsImpostor): number;
  50472. /**
  50473. * Gets the box size of the impostor
  50474. * @param impostor impostor to get box size from
  50475. * @param result the resulting box size
  50476. */
  50477. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50478. /**
  50479. * Disposes of the impostor
  50480. */
  50481. dispose(): void;
  50482. /**
  50483. * Does a raycast in the physics world
  50484. * @param from when should the ray start?
  50485. * @param to when should the ray end?
  50486. * @returns PhysicsRaycastResult
  50487. */
  50488. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50489. }
  50490. }
  50491. declare module "babylonjs/Probes/reflectionProbe" {
  50492. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50493. import { Vector3 } from "babylonjs/Maths/math";
  50494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50495. import { Nullable } from "babylonjs/types";
  50496. import { Scene } from "babylonjs/scene";
  50497. module "babylonjs/abstractScene" {
  50498. interface AbstractScene {
  50499. /**
  50500. * The list of reflection probes added to the scene
  50501. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50502. */
  50503. reflectionProbes: Array<ReflectionProbe>;
  50504. /**
  50505. * Removes the given reflection probe from this scene.
  50506. * @param toRemove The reflection probe to remove
  50507. * @returns The index of the removed reflection probe
  50508. */
  50509. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50510. /**
  50511. * Adds the given reflection probe to this scene.
  50512. * @param newReflectionProbe The reflection probe to add
  50513. */
  50514. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50515. }
  50516. }
  50517. /**
  50518. * Class used to generate realtime reflection / refraction cube textures
  50519. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50520. */
  50521. export class ReflectionProbe {
  50522. /** defines the name of the probe */
  50523. name: string;
  50524. private _scene;
  50525. private _renderTargetTexture;
  50526. private _projectionMatrix;
  50527. private _viewMatrix;
  50528. private _target;
  50529. private _add;
  50530. private _attachedMesh;
  50531. private _invertYAxis;
  50532. /** Gets or sets probe position (center of the cube map) */
  50533. position: Vector3;
  50534. /**
  50535. * Creates a new reflection probe
  50536. * @param name defines the name of the probe
  50537. * @param size defines the texture resolution (for each face)
  50538. * @param scene defines the hosting scene
  50539. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50540. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50541. */
  50542. constructor(
  50543. /** defines the name of the probe */
  50544. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50545. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50546. samples: number;
  50547. /** Gets or sets the refresh rate to use (on every frame by default) */
  50548. refreshRate: number;
  50549. /**
  50550. * Gets the hosting scene
  50551. * @returns a Scene
  50552. */
  50553. getScene(): Scene;
  50554. /** Gets the internal CubeTexture used to render to */
  50555. readonly cubeTexture: RenderTargetTexture;
  50556. /** Gets the list of meshes to render */
  50557. readonly renderList: Nullable<AbstractMesh[]>;
  50558. /**
  50559. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50560. * @param mesh defines the mesh to attach to
  50561. */
  50562. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50563. /**
  50564. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50565. * @param renderingGroupId The rendering group id corresponding to its index
  50566. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50567. */
  50568. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50569. /**
  50570. * Clean all associated resources
  50571. */
  50572. dispose(): void;
  50573. /**
  50574. * Converts the reflection probe information to a readable string for debug purpose.
  50575. * @param fullDetails Supports for multiple levels of logging within scene loading
  50576. * @returns the human readable reflection probe info
  50577. */
  50578. toString(fullDetails?: boolean): string;
  50579. /**
  50580. * Get the class name of the relfection probe.
  50581. * @returns "ReflectionProbe"
  50582. */
  50583. getClassName(): string;
  50584. /**
  50585. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50586. * @returns The JSON representation of the texture
  50587. */
  50588. serialize(): any;
  50589. /**
  50590. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50591. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50592. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50593. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50594. * @returns The parsed reflection probe if successful
  50595. */
  50596. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50597. }
  50598. }
  50599. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  50600. /** @hidden */
  50601. export var _BabylonLoaderRegistered: boolean;
  50602. }
  50603. declare module "babylonjs/Loading/Plugins/index" {
  50604. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  50605. }
  50606. declare module "babylonjs/Loading/index" {
  50607. export * from "babylonjs/Loading/loadingScreen";
  50608. export * from "babylonjs/Loading/Plugins/index";
  50609. export * from "babylonjs/Loading/sceneLoader";
  50610. export * from "babylonjs/Loading/sceneLoaderFlags";
  50611. }
  50612. declare module "babylonjs/Materials/Background/index" {
  50613. export * from "babylonjs/Materials/Background/backgroundMaterial";
  50614. }
  50615. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  50616. import { Scene } from "babylonjs/scene";
  50617. import { Color3 } from "babylonjs/Maths/math";
  50618. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50619. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50620. /**
  50621. * The Physically based simple base material of BJS.
  50622. *
  50623. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50624. * It is used as the base class for both the specGloss and metalRough conventions.
  50625. */
  50626. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50627. /**
  50628. * Number of Simultaneous lights allowed on the material.
  50629. */
  50630. maxSimultaneousLights: number;
  50631. /**
  50632. * If sets to true, disables all the lights affecting the material.
  50633. */
  50634. disableLighting: boolean;
  50635. /**
  50636. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50637. */
  50638. environmentTexture: BaseTexture;
  50639. /**
  50640. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50641. */
  50642. invertNormalMapX: boolean;
  50643. /**
  50644. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50645. */
  50646. invertNormalMapY: boolean;
  50647. /**
  50648. * Normal map used in the model.
  50649. */
  50650. normalTexture: BaseTexture;
  50651. /**
  50652. * Emissivie color used to self-illuminate the model.
  50653. */
  50654. emissiveColor: Color3;
  50655. /**
  50656. * Emissivie texture used to self-illuminate the model.
  50657. */
  50658. emissiveTexture: BaseTexture;
  50659. /**
  50660. * Occlusion Channel Strenght.
  50661. */
  50662. occlusionStrength: number;
  50663. /**
  50664. * Occlusion Texture of the material (adding extra occlusion effects).
  50665. */
  50666. occlusionTexture: BaseTexture;
  50667. /**
  50668. * Defines the alpha limits in alpha test mode.
  50669. */
  50670. alphaCutOff: number;
  50671. /**
  50672. * Gets the current double sided mode.
  50673. */
  50674. /**
  50675. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50676. */
  50677. doubleSided: boolean;
  50678. /**
  50679. * Stores the pre-calculated light information of a mesh in a texture.
  50680. */
  50681. lightmapTexture: BaseTexture;
  50682. /**
  50683. * If true, the light map contains occlusion information instead of lighting info.
  50684. */
  50685. useLightmapAsShadowmap: boolean;
  50686. /**
  50687. * Instantiates a new PBRMaterial instance.
  50688. *
  50689. * @param name The material name
  50690. * @param scene The scene the material will be use in.
  50691. */
  50692. constructor(name: string, scene: Scene);
  50693. getClassName(): string;
  50694. }
  50695. }
  50696. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  50697. import { Scene } from "babylonjs/scene";
  50698. import { Color3 } from "babylonjs/Maths/math";
  50699. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50700. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50701. /**
  50702. * The PBR material of BJS following the metal roughness convention.
  50703. *
  50704. * This fits to the PBR convention in the GLTF definition:
  50705. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50706. */
  50707. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50708. /**
  50709. * The base color has two different interpretations depending on the value of metalness.
  50710. * When the material is a metal, the base color is the specific measured reflectance value
  50711. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50712. * of the material.
  50713. */
  50714. baseColor: Color3;
  50715. /**
  50716. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50717. * well as opacity information in the alpha channel.
  50718. */
  50719. baseTexture: BaseTexture;
  50720. /**
  50721. * Specifies the metallic scalar value of the material.
  50722. * Can also be used to scale the metalness values of the metallic texture.
  50723. */
  50724. metallic: number;
  50725. /**
  50726. * Specifies the roughness scalar value of the material.
  50727. * Can also be used to scale the roughness values of the metallic texture.
  50728. */
  50729. roughness: number;
  50730. /**
  50731. * Texture containing both the metallic value in the B channel and the
  50732. * roughness value in the G channel to keep better precision.
  50733. */
  50734. metallicRoughnessTexture: BaseTexture;
  50735. /**
  50736. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50737. *
  50738. * @param name The material name
  50739. * @param scene The scene the material will be use in.
  50740. */
  50741. constructor(name: string, scene: Scene);
  50742. /**
  50743. * Return the currrent class name of the material.
  50744. */
  50745. getClassName(): string;
  50746. /**
  50747. * Makes a duplicate of the current material.
  50748. * @param name - name to use for the new material.
  50749. */
  50750. clone(name: string): PBRMetallicRoughnessMaterial;
  50751. /**
  50752. * Serialize the material to a parsable JSON object.
  50753. */
  50754. serialize(): any;
  50755. /**
  50756. * Parses a JSON object correponding to the serialize function.
  50757. */
  50758. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50759. }
  50760. }
  50761. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  50762. import { Scene } from "babylonjs/scene";
  50763. import { Color3 } from "babylonjs/Maths/math";
  50764. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50765. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50766. /**
  50767. * The PBR material of BJS following the specular glossiness convention.
  50768. *
  50769. * This fits to the PBR convention in the GLTF definition:
  50770. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50771. */
  50772. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50773. /**
  50774. * Specifies the diffuse color of the material.
  50775. */
  50776. diffuseColor: Color3;
  50777. /**
  50778. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50779. * channel.
  50780. */
  50781. diffuseTexture: BaseTexture;
  50782. /**
  50783. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50784. */
  50785. specularColor: Color3;
  50786. /**
  50787. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50788. */
  50789. glossiness: number;
  50790. /**
  50791. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50792. */
  50793. specularGlossinessTexture: BaseTexture;
  50794. /**
  50795. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50796. *
  50797. * @param name The material name
  50798. * @param scene The scene the material will be use in.
  50799. */
  50800. constructor(name: string, scene: Scene);
  50801. /**
  50802. * Return the currrent class name of the material.
  50803. */
  50804. getClassName(): string;
  50805. /**
  50806. * Makes a duplicate of the current material.
  50807. * @param name - name to use for the new material.
  50808. */
  50809. clone(name: string): PBRSpecularGlossinessMaterial;
  50810. /**
  50811. * Serialize the material to a parsable JSON object.
  50812. */
  50813. serialize(): any;
  50814. /**
  50815. * Parses a JSON object correponding to the serialize function.
  50816. */
  50817. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50818. }
  50819. }
  50820. declare module "babylonjs/Materials/PBR/index" {
  50821. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50822. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50823. export * from "babylonjs/Materials/PBR/pbrMaterial";
  50824. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  50825. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  50826. }
  50827. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  50828. import { Nullable } from "babylonjs/types";
  50829. import { Scene } from "babylonjs/scene";
  50830. import { Matrix } from "babylonjs/Maths/math";
  50831. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50832. /**
  50833. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50834. * It can help converting any input color in a desired output one. This can then be used to create effects
  50835. * from sepia, black and white to sixties or futuristic rendering...
  50836. *
  50837. * The only supported format is currently 3dl.
  50838. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50839. */
  50840. export class ColorGradingTexture extends BaseTexture {
  50841. /**
  50842. * The current texture matrix. (will always be identity in color grading texture)
  50843. */
  50844. private _textureMatrix;
  50845. /**
  50846. * The texture URL.
  50847. */
  50848. url: string;
  50849. /**
  50850. * Empty line regex stored for GC.
  50851. */
  50852. private static _noneEmptyLineRegex;
  50853. private _engine;
  50854. /**
  50855. * Instantiates a ColorGradingTexture from the following parameters.
  50856. *
  50857. * @param url The location of the color gradind data (currently only supporting 3dl)
  50858. * @param scene The scene the texture will be used in
  50859. */
  50860. constructor(url: string, scene: Scene);
  50861. /**
  50862. * Returns the texture matrix used in most of the material.
  50863. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50864. */
  50865. getTextureMatrix(): Matrix;
  50866. /**
  50867. * Occurs when the file being loaded is a .3dl LUT file.
  50868. */
  50869. private load3dlTexture;
  50870. /**
  50871. * Starts the loading process of the texture.
  50872. */
  50873. private loadTexture;
  50874. /**
  50875. * Clones the color gradind texture.
  50876. */
  50877. clone(): ColorGradingTexture;
  50878. /**
  50879. * Called during delayed load for textures.
  50880. */
  50881. delayLoad(): void;
  50882. /**
  50883. * Parses a color grading texture serialized by Babylon.
  50884. * @param parsedTexture The texture information being parsedTexture
  50885. * @param scene The scene to load the texture in
  50886. * @param rootUrl The root url of the data assets to load
  50887. * @return A color gradind texture
  50888. */
  50889. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50890. /**
  50891. * Serializes the LUT texture to json format.
  50892. */
  50893. serialize(): any;
  50894. }
  50895. }
  50896. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  50897. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50898. import { Scene } from "babylonjs/scene";
  50899. import { Nullable } from "babylonjs/types";
  50900. /**
  50901. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50902. */
  50903. export class EquiRectangularCubeTexture extends BaseTexture {
  50904. /** The six faces of the cube. */
  50905. private static _FacesMapping;
  50906. private _noMipmap;
  50907. private _onLoad;
  50908. private _onError;
  50909. /** The size of the cubemap. */
  50910. private _size;
  50911. /** The buffer of the image. */
  50912. private _buffer;
  50913. /** The width of the input image. */
  50914. private _width;
  50915. /** The height of the input image. */
  50916. private _height;
  50917. /** The URL to the image. */
  50918. url: string;
  50919. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50920. coordinatesMode: number;
  50921. /**
  50922. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50923. * @param url The location of the image
  50924. * @param scene The scene the texture will be used in
  50925. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50926. * @param noMipmap Forces to not generate the mipmap if true
  50927. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50928. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50929. * @param onLoad — defines a callback called when texture is loaded
  50930. * @param onError — defines a callback called if there is an error
  50931. */
  50932. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50933. /**
  50934. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50935. */
  50936. private loadImage;
  50937. /**
  50938. * Convert the image buffer into a cubemap and create a CubeTexture.
  50939. */
  50940. private loadTexture;
  50941. /**
  50942. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50943. * @param buffer The ArrayBuffer that should be converted.
  50944. * @returns The buffer as Float32Array.
  50945. */
  50946. private getFloat32ArrayFromArrayBuffer;
  50947. /**
  50948. * Get the current class name of the texture useful for serialization or dynamic coding.
  50949. * @returns "EquiRectangularCubeTexture"
  50950. */
  50951. getClassName(): string;
  50952. /**
  50953. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50954. * @returns A clone of the current EquiRectangularCubeTexture.
  50955. */
  50956. clone(): EquiRectangularCubeTexture;
  50957. }
  50958. }
  50959. declare module "babylonjs/Misc/tga" {
  50960. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50961. /**
  50962. * Based on jsTGALoader - Javascript loader for TGA file
  50963. * By Vincent Thibault
  50964. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50965. */
  50966. export class TGATools {
  50967. private static _TYPE_INDEXED;
  50968. private static _TYPE_RGB;
  50969. private static _TYPE_GREY;
  50970. private static _TYPE_RLE_INDEXED;
  50971. private static _TYPE_RLE_RGB;
  50972. private static _TYPE_RLE_GREY;
  50973. private static _ORIGIN_MASK;
  50974. private static _ORIGIN_SHIFT;
  50975. private static _ORIGIN_BL;
  50976. private static _ORIGIN_BR;
  50977. private static _ORIGIN_UL;
  50978. private static _ORIGIN_UR;
  50979. /**
  50980. * Gets the header of a TGA file
  50981. * @param data defines the TGA data
  50982. * @returns the header
  50983. */
  50984. static GetTGAHeader(data: Uint8Array): any;
  50985. /**
  50986. * Uploads TGA content to a Babylon Texture
  50987. * @hidden
  50988. */
  50989. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50990. /** @hidden */
  50991. 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;
  50992. /** @hidden */
  50993. 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;
  50994. /** @hidden */
  50995. 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;
  50996. /** @hidden */
  50997. 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;
  50998. /** @hidden */
  50999. 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;
  51000. /** @hidden */
  51001. 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;
  51002. }
  51003. }
  51004. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51005. import { Nullable } from "babylonjs/types";
  51006. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51007. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51008. /**
  51009. * Implementation of the TGA Texture Loader.
  51010. * @hidden
  51011. */
  51012. export class _TGATextureLoader implements IInternalTextureLoader {
  51013. /**
  51014. * Defines wether the loader supports cascade loading the different faces.
  51015. */
  51016. readonly supportCascades: boolean;
  51017. /**
  51018. * This returns if the loader support the current file information.
  51019. * @param extension defines the file extension of the file being loaded
  51020. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51021. * @param fallback defines the fallback internal texture if any
  51022. * @param isBase64 defines whether the texture is encoded as a base64
  51023. * @param isBuffer defines whether the texture data are stored as a buffer
  51024. * @returns true if the loader can load the specified file
  51025. */
  51026. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51027. /**
  51028. * Transform the url before loading if required.
  51029. * @param rootUrl the url of the texture
  51030. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51031. * @returns the transformed texture
  51032. */
  51033. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51034. /**
  51035. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51036. * @param rootUrl the url of the texture
  51037. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51038. * @returns the fallback texture
  51039. */
  51040. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51041. /**
  51042. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51043. * @param data contains the texture data
  51044. * @param texture defines the BabylonJS internal texture
  51045. * @param createPolynomials will be true if polynomials have been requested
  51046. * @param onLoad defines the callback to trigger once the texture is ready
  51047. * @param onError defines the callback to trigger in case of error
  51048. */
  51049. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51050. /**
  51051. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51052. * @param data contains the texture data
  51053. * @param texture defines the BabylonJS internal texture
  51054. * @param callback defines the method to call once ready to upload
  51055. */
  51056. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51057. }
  51058. }
  51059. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51060. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51061. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51062. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51063. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51064. }
  51065. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51066. import { Scene } from "babylonjs/scene";
  51067. import { Texture } from "babylonjs/Materials/Textures/texture";
  51068. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51069. /**
  51070. * 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.
  51071. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51072. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51073. */
  51074. export class CustomProceduralTexture extends ProceduralTexture {
  51075. private _animate;
  51076. private _time;
  51077. private _config;
  51078. private _texturePath;
  51079. /**
  51080. * Instantiates a new Custom Procedural Texture.
  51081. * 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.
  51082. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51083. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51084. * @param name Define the name of the texture
  51085. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51086. * @param size Define the size of the texture to create
  51087. * @param scene Define the scene the texture belongs to
  51088. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51089. * @param generateMipMaps Define if the texture should creates mip maps or not
  51090. */
  51091. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51092. private _loadJson;
  51093. /**
  51094. * Is the texture ready to be used ? (rendered at least once)
  51095. * @returns true if ready, otherwise, false.
  51096. */
  51097. isReady(): boolean;
  51098. /**
  51099. * Render the texture to its associated render target.
  51100. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51101. */
  51102. render(useCameraPostProcess?: boolean): void;
  51103. /**
  51104. * Update the list of dependant textures samplers in the shader.
  51105. */
  51106. updateTextures(): void;
  51107. /**
  51108. * Update the uniform values of the procedural texture in the shader.
  51109. */
  51110. updateShaderUniforms(): void;
  51111. /**
  51112. * Define if the texture animates or not.
  51113. */
  51114. animate: boolean;
  51115. }
  51116. }
  51117. declare module "babylonjs/Shaders/noise.fragment" {
  51118. /** @hidden */
  51119. export var noisePixelShader: {
  51120. name: string;
  51121. shader: string;
  51122. };
  51123. }
  51124. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51125. import { Nullable } from "babylonjs/types";
  51126. import { Scene } from "babylonjs/scene";
  51127. import { Texture } from "babylonjs/Materials/Textures/texture";
  51128. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51129. import "babylonjs/Shaders/noise.fragment";
  51130. /**
  51131. * Class used to generate noise procedural textures
  51132. */
  51133. export class NoiseProceduralTexture extends ProceduralTexture {
  51134. private _time;
  51135. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51136. brightness: number;
  51137. /** Defines the number of octaves to process */
  51138. octaves: number;
  51139. /** Defines the level of persistence (0.8 by default) */
  51140. persistence: number;
  51141. /** Gets or sets animation speed factor (default is 1) */
  51142. animationSpeedFactor: number;
  51143. /**
  51144. * Creates a new NoiseProceduralTexture
  51145. * @param name defines the name fo the texture
  51146. * @param size defines the size of the texture (default is 256)
  51147. * @param scene defines the hosting scene
  51148. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51149. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51150. */
  51151. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51152. private _updateShaderUniforms;
  51153. protected _getDefines(): string;
  51154. /** Generate the current state of the procedural texture */
  51155. render(useCameraPostProcess?: boolean): void;
  51156. /**
  51157. * Serializes this noise procedural texture
  51158. * @returns a serialized noise procedural texture object
  51159. */
  51160. serialize(): any;
  51161. /**
  51162. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51163. * @param parsedTexture defines parsed texture data
  51164. * @param scene defines the current scene
  51165. * @param rootUrl defines the root URL containing noise procedural texture information
  51166. * @returns a parsed NoiseProceduralTexture
  51167. */
  51168. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51169. }
  51170. }
  51171. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51172. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51173. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51174. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51175. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51176. }
  51177. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51178. import { Nullable } from "babylonjs/types";
  51179. import { Scene } from "babylonjs/scene";
  51180. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51181. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51182. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51183. /**
  51184. * Raw cube texture where the raw buffers are passed in
  51185. */
  51186. export class RawCubeTexture extends CubeTexture {
  51187. /**
  51188. * Creates a cube texture where the raw buffers are passed in.
  51189. * @param scene defines the scene the texture is attached to
  51190. * @param data defines the array of data to use to create each face
  51191. * @param size defines the size of the textures
  51192. * @param format defines the format of the data
  51193. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51194. * @param generateMipMaps defines if the engine should generate the mip levels
  51195. * @param invertY defines if data must be stored with Y axis inverted
  51196. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51197. * @param compression defines the compression used (null by default)
  51198. */
  51199. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51200. /**
  51201. * Updates the raw cube texture.
  51202. * @param data defines the data to store
  51203. * @param format defines the data format
  51204. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51205. * @param invertY defines if data must be stored with Y axis inverted
  51206. * @param compression defines the compression used (null by default)
  51207. * @param level defines which level of the texture to update
  51208. */
  51209. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51210. /**
  51211. * Updates a raw cube texture with RGBD encoded data.
  51212. * @param data defines the array of data [mipmap][face] to use to create each face
  51213. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51214. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51215. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51216. * @returns a promsie that resolves when the operation is complete
  51217. */
  51218. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51219. /**
  51220. * Clones the raw cube texture.
  51221. * @return a new cube texture
  51222. */
  51223. clone(): CubeTexture;
  51224. /** @hidden */
  51225. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51226. }
  51227. }
  51228. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51229. import { Scene } from "babylonjs/scene";
  51230. import { Texture } from "babylonjs/Materials/Textures/texture";
  51231. /**
  51232. * Class used to store 3D textures containing user data
  51233. */
  51234. export class RawTexture3D extends Texture {
  51235. /** Gets or sets the texture format to use */
  51236. format: number;
  51237. private _engine;
  51238. /**
  51239. * Create a new RawTexture3D
  51240. * @param data defines the data of the texture
  51241. * @param width defines the width of the texture
  51242. * @param height defines the height of the texture
  51243. * @param depth defines the depth of the texture
  51244. * @param format defines the texture format to use
  51245. * @param scene defines the hosting scene
  51246. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51247. * @param invertY defines if texture must be stored with Y axis inverted
  51248. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51249. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51250. */
  51251. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51252. /** Gets or sets the texture format to use */
  51253. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51254. /**
  51255. * Update the texture with new data
  51256. * @param data defines the data to store in the texture
  51257. */
  51258. update(data: ArrayBufferView): void;
  51259. }
  51260. }
  51261. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51262. import { Scene } from "babylonjs/scene";
  51263. import { Plane } from "babylonjs/Maths/math";
  51264. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51265. /**
  51266. * Creates a refraction texture used by refraction channel of the standard material.
  51267. * It is like a mirror but to see through a material.
  51268. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51269. */
  51270. export class RefractionTexture extends RenderTargetTexture {
  51271. /**
  51272. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51273. * 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.
  51274. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51275. */
  51276. refractionPlane: Plane;
  51277. /**
  51278. * Define how deep under the surface we should see.
  51279. */
  51280. depth: number;
  51281. /**
  51282. * Creates a refraction texture used by refraction channel of the standard material.
  51283. * It is like a mirror but to see through a material.
  51284. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51285. * @param name Define the texture name
  51286. * @param size Define the size of the underlying texture
  51287. * @param scene Define the scene the refraction belongs to
  51288. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51289. */
  51290. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51291. /**
  51292. * Clone the refraction texture.
  51293. * @returns the cloned texture
  51294. */
  51295. clone(): RefractionTexture;
  51296. /**
  51297. * Serialize the texture to a JSON representation you could use in Parse later on
  51298. * @returns the serialized JSON representation
  51299. */
  51300. serialize(): any;
  51301. }
  51302. }
  51303. declare module "babylonjs/Materials/Textures/index" {
  51304. export * from "babylonjs/Materials/Textures/baseTexture";
  51305. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51306. export * from "babylonjs/Materials/Textures/cubeTexture";
  51307. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51308. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51309. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51310. export * from "babylonjs/Materials/Textures/internalTexture";
  51311. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51312. export * from "babylonjs/Materials/Textures/Loaders/index";
  51313. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51314. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51315. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51316. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51317. export * from "babylonjs/Materials/Textures/rawTexture";
  51318. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51319. export * from "babylonjs/Materials/Textures/refractionTexture";
  51320. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51321. export * from "babylonjs/Materials/Textures/texture";
  51322. export * from "babylonjs/Materials/Textures/videoTexture";
  51323. }
  51324. declare module "babylonjs/Materials/index" {
  51325. export * from "babylonjs/Materials/Background/index";
  51326. export * from "babylonjs/Materials/colorCurves";
  51327. export * from "babylonjs/Materials/effect";
  51328. export * from "babylonjs/Materials/fresnelParameters";
  51329. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51330. export * from "babylonjs/Materials/material";
  51331. export * from "babylonjs/Materials/materialDefines";
  51332. export * from "babylonjs/Materials/materialHelper";
  51333. export * from "babylonjs/Materials/multiMaterial";
  51334. export * from "babylonjs/Materials/PBR/index";
  51335. export * from "babylonjs/Materials/pushMaterial";
  51336. export * from "babylonjs/Materials/shaderMaterial";
  51337. export * from "babylonjs/Materials/standardMaterial";
  51338. export * from "babylonjs/Materials/Textures/index";
  51339. export * from "babylonjs/Materials/uniformBuffer";
  51340. export * from "babylonjs/Materials/materialFlags";
  51341. }
  51342. declare module "babylonjs/Maths/index" {
  51343. export * from "babylonjs/Maths/math.scalar";
  51344. export * from "babylonjs/Maths/math";
  51345. export * from "babylonjs/Maths/sphericalPolynomial";
  51346. }
  51347. declare module "babylonjs/Misc/workerPool" {
  51348. import { IDisposable } from "babylonjs/scene";
  51349. /**
  51350. * Helper class to push actions to a pool of workers.
  51351. */
  51352. export class WorkerPool implements IDisposable {
  51353. private _workerInfos;
  51354. private _pendingActions;
  51355. /**
  51356. * Constructor
  51357. * @param workers Array of workers to use for actions
  51358. */
  51359. constructor(workers: Array<Worker>);
  51360. /**
  51361. * Terminates all workers and clears any pending actions.
  51362. */
  51363. dispose(): void;
  51364. /**
  51365. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51366. * pended until a worker has completed its action.
  51367. * @param action The action to perform. Call onComplete when the action is complete.
  51368. */
  51369. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51370. private _execute;
  51371. }
  51372. }
  51373. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51374. import { IDisposable } from "babylonjs/scene";
  51375. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51376. /**
  51377. * Configuration for Draco compression
  51378. */
  51379. export interface IDracoCompressionConfiguration {
  51380. /**
  51381. * Configuration for the decoder.
  51382. */
  51383. decoder?: {
  51384. /**
  51385. * The url to the WebAssembly module.
  51386. */
  51387. wasmUrl?: string;
  51388. /**
  51389. * The url to the WebAssembly binary.
  51390. */
  51391. wasmBinaryUrl?: string;
  51392. /**
  51393. * The url to the fallback JavaScript module.
  51394. */
  51395. fallbackUrl?: string;
  51396. };
  51397. }
  51398. /**
  51399. * Draco compression (https://google.github.io/draco/)
  51400. *
  51401. * This class wraps the Draco module.
  51402. *
  51403. * **Encoder**
  51404. *
  51405. * The encoder is not currently implemented.
  51406. *
  51407. * **Decoder**
  51408. *
  51409. * 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.
  51410. *
  51411. * To update the configuration, use the following code:
  51412. * ```javascript
  51413. * DracoCompression.Configuration = {
  51414. * decoder: {
  51415. * wasmUrl: "<url to the WebAssembly library>",
  51416. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51417. * fallbackUrl: "<url to the fallback JavaScript library>",
  51418. * }
  51419. * };
  51420. * ```
  51421. *
  51422. * 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.
  51423. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51424. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51425. *
  51426. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51427. * ```javascript
  51428. * var dracoCompression = new DracoCompression();
  51429. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  51430. * [VertexBuffer.PositionKind]: 0
  51431. * });
  51432. * ```
  51433. *
  51434. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51435. */
  51436. export class DracoCompression implements IDisposable {
  51437. private _workerPoolPromise;
  51438. /**
  51439. * The configuration. Defaults to the following urls:
  51440. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51441. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51442. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51443. */
  51444. static Configuration: IDracoCompressionConfiguration;
  51445. /**
  51446. * Returns true if the decoder is available.
  51447. */
  51448. static readonly DecoderAvailable: boolean;
  51449. /**
  51450. * Default number of workers to create when creating the draco compression object.
  51451. */
  51452. static DefaultNumWorkers: number;
  51453. private static GetDefaultNumWorkers;
  51454. /**
  51455. * Constructor
  51456. * @param numWorkers The number of workers for async operations
  51457. */
  51458. constructor(numWorkers?: number);
  51459. /**
  51460. * Stop all async operations and release resources.
  51461. */
  51462. dispose(): void;
  51463. /**
  51464. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51465. * @returns a promise that resolves when ready
  51466. */
  51467. whenReadyAsync(): Promise<void>;
  51468. /**
  51469. * Decode Draco compressed mesh data to vertex data.
  51470. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51471. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51472. * @returns A promise that resolves with the decoded vertex data
  51473. */
  51474. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  51475. [kind: string]: number;
  51476. }): Promise<VertexData>;
  51477. /**
  51478. * The worker function that gets converted to a blob url to pass into a worker.
  51479. */
  51480. private static _Worker;
  51481. private _loadDecoderWasmBinaryAsync;
  51482. }
  51483. }
  51484. declare module "babylonjs/Meshes/Compression/index" {
  51485. export * from "babylonjs/Meshes/Compression/dracoCompression";
  51486. }
  51487. declare module "babylonjs/Meshes/csg" {
  51488. import { Nullable } from "babylonjs/types";
  51489. import { Scene } from "babylonjs/scene";
  51490. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  51491. import { Mesh } from "babylonjs/Meshes/mesh";
  51492. import { Material } from "babylonjs/Materials/material";
  51493. /**
  51494. * Class for building Constructive Solid Geometry
  51495. */
  51496. export class CSG {
  51497. private polygons;
  51498. /**
  51499. * The world matrix
  51500. */
  51501. matrix: Matrix;
  51502. /**
  51503. * Stores the position
  51504. */
  51505. position: Vector3;
  51506. /**
  51507. * Stores the rotation
  51508. */
  51509. rotation: Vector3;
  51510. /**
  51511. * Stores the rotation quaternion
  51512. */
  51513. rotationQuaternion: Nullable<Quaternion>;
  51514. /**
  51515. * Stores the scaling vector
  51516. */
  51517. scaling: Vector3;
  51518. /**
  51519. * Convert the Mesh to CSG
  51520. * @param mesh The Mesh to convert to CSG
  51521. * @returns A new CSG from the Mesh
  51522. */
  51523. static FromMesh(mesh: Mesh): CSG;
  51524. /**
  51525. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51526. * @param polygons Polygons used to construct a CSG solid
  51527. */
  51528. private static FromPolygons;
  51529. /**
  51530. * Clones, or makes a deep copy, of the CSG
  51531. * @returns A new CSG
  51532. */
  51533. clone(): CSG;
  51534. /**
  51535. * Unions this CSG with another CSG
  51536. * @param csg The CSG to union against this CSG
  51537. * @returns The unioned CSG
  51538. */
  51539. union(csg: CSG): CSG;
  51540. /**
  51541. * Unions this CSG with another CSG in place
  51542. * @param csg The CSG to union against this CSG
  51543. */
  51544. unionInPlace(csg: CSG): void;
  51545. /**
  51546. * Subtracts this CSG with another CSG
  51547. * @param csg The CSG to subtract against this CSG
  51548. * @returns A new CSG
  51549. */
  51550. subtract(csg: CSG): CSG;
  51551. /**
  51552. * Subtracts this CSG with another CSG in place
  51553. * @param csg The CSG to subtact against this CSG
  51554. */
  51555. subtractInPlace(csg: CSG): void;
  51556. /**
  51557. * Intersect this CSG with another CSG
  51558. * @param csg The CSG to intersect against this CSG
  51559. * @returns A new CSG
  51560. */
  51561. intersect(csg: CSG): CSG;
  51562. /**
  51563. * Intersects this CSG with another CSG in place
  51564. * @param csg The CSG to intersect against this CSG
  51565. */
  51566. intersectInPlace(csg: CSG): void;
  51567. /**
  51568. * Return a new CSG solid with solid and empty space switched. This solid is
  51569. * not modified.
  51570. * @returns A new CSG solid with solid and empty space switched
  51571. */
  51572. inverse(): CSG;
  51573. /**
  51574. * Inverses the CSG in place
  51575. */
  51576. inverseInPlace(): void;
  51577. /**
  51578. * This is used to keep meshes transformations so they can be restored
  51579. * when we build back a Babylon Mesh
  51580. * NB : All CSG operations are performed in world coordinates
  51581. * @param csg The CSG to copy the transform attributes from
  51582. * @returns This CSG
  51583. */
  51584. copyTransformAttributes(csg: CSG): CSG;
  51585. /**
  51586. * Build Raw mesh from CSG
  51587. * Coordinates here are in world space
  51588. * @param name The name of the mesh geometry
  51589. * @param scene The Scene
  51590. * @param keepSubMeshes Specifies if the submeshes should be kept
  51591. * @returns A new Mesh
  51592. */
  51593. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51594. /**
  51595. * Build Mesh from CSG taking material and transforms into account
  51596. * @param name The name of the Mesh
  51597. * @param material The material of the Mesh
  51598. * @param scene The Scene
  51599. * @param keepSubMeshes Specifies if submeshes should be kept
  51600. * @returns The new Mesh
  51601. */
  51602. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51603. }
  51604. }
  51605. declare module "babylonjs/Meshes/trailMesh" {
  51606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51607. import { Mesh } from "babylonjs/Meshes/mesh";
  51608. import { Scene } from "babylonjs/scene";
  51609. /**
  51610. * Class used to create a trail following a mesh
  51611. */
  51612. export class TrailMesh extends Mesh {
  51613. private _generator;
  51614. private _autoStart;
  51615. private _running;
  51616. private _diameter;
  51617. private _length;
  51618. private _sectionPolygonPointsCount;
  51619. private _sectionVectors;
  51620. private _sectionNormalVectors;
  51621. private _beforeRenderObserver;
  51622. /**
  51623. * @constructor
  51624. * @param name The value used by scene.getMeshByName() to do a lookup.
  51625. * @param generator The mesh to generate a trail.
  51626. * @param scene The scene to add this mesh to.
  51627. * @param diameter Diameter of trailing mesh. Default is 1.
  51628. * @param length Length of trailing mesh. Default is 60.
  51629. * @param autoStart Automatically start trailing mesh. Default true.
  51630. */
  51631. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51632. /**
  51633. * "TrailMesh"
  51634. * @returns "TrailMesh"
  51635. */
  51636. getClassName(): string;
  51637. private _createMesh;
  51638. /**
  51639. * Start trailing mesh.
  51640. */
  51641. start(): void;
  51642. /**
  51643. * Stop trailing mesh.
  51644. */
  51645. stop(): void;
  51646. /**
  51647. * Update trailing mesh geometry.
  51648. */
  51649. update(): void;
  51650. /**
  51651. * Returns a new TrailMesh object.
  51652. * @param name is a string, the name given to the new mesh
  51653. * @param newGenerator use new generator object for cloned trail mesh
  51654. * @returns a new mesh
  51655. */
  51656. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51657. /**
  51658. * Serializes this trail mesh
  51659. * @param serializationObject object to write serialization to
  51660. */
  51661. serialize(serializationObject: any): void;
  51662. /**
  51663. * Parses a serialized trail mesh
  51664. * @param parsedMesh the serialized mesh
  51665. * @param scene the scene to create the trail mesh in
  51666. * @returns the created trail mesh
  51667. */
  51668. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51669. }
  51670. }
  51671. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  51672. import { Vector4 } from "babylonjs/Maths/math";
  51673. import { Mesh } from "babylonjs/Meshes/mesh";
  51674. /**
  51675. * Class containing static functions to help procedurally build meshes
  51676. */
  51677. export class TorusKnotBuilder {
  51678. /**
  51679. * Creates a torus knot mesh
  51680. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51681. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51682. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51683. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51687. * @param name defines the name of the mesh
  51688. * @param options defines the options used to create the mesh
  51689. * @param scene defines the hosting scene
  51690. * @returns the torus knot mesh
  51691. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51692. */
  51693. static CreateTorusKnot(name: string, options: {
  51694. radius?: number;
  51695. tube?: number;
  51696. radialSegments?: number;
  51697. tubularSegments?: number;
  51698. p?: number;
  51699. q?: number;
  51700. updatable?: boolean;
  51701. sideOrientation?: number;
  51702. frontUVs?: Vector4;
  51703. backUVs?: Vector4;
  51704. }, scene: any): Mesh;
  51705. }
  51706. }
  51707. declare module "babylonjs/Meshes/polygonMesh" {
  51708. import { Scene } from "babylonjs/scene";
  51709. import { Vector2, Path2 } from "babylonjs/Maths/math";
  51710. import { Mesh } from "babylonjs/Meshes/mesh";
  51711. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51712. /**
  51713. * Polygon
  51714. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51715. */
  51716. export class Polygon {
  51717. /**
  51718. * Creates a rectangle
  51719. * @param xmin bottom X coord
  51720. * @param ymin bottom Y coord
  51721. * @param xmax top X coord
  51722. * @param ymax top Y coord
  51723. * @returns points that make the resulting rectation
  51724. */
  51725. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  51726. /**
  51727. * Creates a circle
  51728. * @param radius radius of circle
  51729. * @param cx scale in x
  51730. * @param cy scale in y
  51731. * @param numberOfSides number of sides that make up the circle
  51732. * @returns points that make the resulting circle
  51733. */
  51734. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  51735. /**
  51736. * Creates a polygon from input string
  51737. * @param input Input polygon data
  51738. * @returns the parsed points
  51739. */
  51740. static Parse(input: string): Vector2[];
  51741. /**
  51742. * Starts building a polygon from x and y coordinates
  51743. * @param x x coordinate
  51744. * @param y y coordinate
  51745. * @returns the started path2
  51746. */
  51747. static StartingAt(x: number, y: number): Path2;
  51748. }
  51749. /**
  51750. * Builds a polygon
  51751. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  51752. */
  51753. export class PolygonMeshBuilder {
  51754. private _points;
  51755. private _outlinepoints;
  51756. private _holes;
  51757. private _name;
  51758. private _scene;
  51759. private _epoints;
  51760. private _eholes;
  51761. private _addToepoint;
  51762. /**
  51763. * Babylon reference to the earcut plugin.
  51764. */
  51765. bjsEarcut: any;
  51766. /**
  51767. * Creates a PolygonMeshBuilder
  51768. * @param name name of the builder
  51769. * @param contours Path of the polygon
  51770. * @param scene scene to add to when creating the mesh
  51771. * @param earcutInjection can be used to inject your own earcut reference
  51772. */
  51773. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51774. /**
  51775. * Adds a whole within the polygon
  51776. * @param hole Array of points defining the hole
  51777. * @returns this
  51778. */
  51779. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51780. /**
  51781. * Creates the polygon
  51782. * @param updatable If the mesh should be updatable
  51783. * @param depth The depth of the mesh created
  51784. * @returns the created mesh
  51785. */
  51786. build(updatable?: boolean, depth?: number): Mesh;
  51787. /**
  51788. * Creates the polygon
  51789. * @param depth The depth of the mesh created
  51790. * @returns the created VertexData
  51791. */
  51792. buildVertexData(depth?: number): VertexData;
  51793. /**
  51794. * Adds a side to the polygon
  51795. * @param positions points that make the polygon
  51796. * @param normals normals of the polygon
  51797. * @param uvs uvs of the polygon
  51798. * @param indices indices of the polygon
  51799. * @param bounds bounds of the polygon
  51800. * @param points points of the polygon
  51801. * @param depth depth of the polygon
  51802. * @param flip flip of the polygon
  51803. */
  51804. private addSide;
  51805. }
  51806. }
  51807. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  51808. import { Scene } from "babylonjs/scene";
  51809. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  51810. import { Mesh } from "babylonjs/Meshes/mesh";
  51811. import { Nullable } from "babylonjs/types";
  51812. /**
  51813. * Class containing static functions to help procedurally build meshes
  51814. */
  51815. export class PolygonBuilder {
  51816. /**
  51817. * Creates a polygon mesh
  51818. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51819. * * 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
  51820. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51823. * * Remember you can only change the shape positions, not their number when updating a polygon
  51824. * @param name defines the name of the mesh
  51825. * @param options defines the options used to create the mesh
  51826. * @param scene defines the hosting scene
  51827. * @param earcutInjection can be used to inject your own earcut reference
  51828. * @returns the polygon mesh
  51829. */
  51830. static CreatePolygon(name: string, options: {
  51831. shape: Vector3[];
  51832. holes?: Vector3[][];
  51833. depth?: number;
  51834. faceUV?: Vector4[];
  51835. faceColors?: Color4[];
  51836. updatable?: boolean;
  51837. sideOrientation?: number;
  51838. frontUVs?: Vector4;
  51839. backUVs?: Vector4;
  51840. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51841. /**
  51842. * Creates an extruded polygon mesh, with depth in the Y direction.
  51843. * * 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)
  51844. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51845. * @param name defines the name of the mesh
  51846. * @param options defines the options used to create the mesh
  51847. * @param scene defines the hosting scene
  51848. * @param earcutInjection can be used to inject your own earcut reference
  51849. * @returns the polygon mesh
  51850. */
  51851. static ExtrudePolygon(name: string, options: {
  51852. shape: Vector3[];
  51853. holes?: Vector3[][];
  51854. depth?: number;
  51855. faceUV?: Vector4[];
  51856. faceColors?: Color4[];
  51857. updatable?: boolean;
  51858. sideOrientation?: number;
  51859. frontUVs?: Vector4;
  51860. backUVs?: Vector4;
  51861. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51862. }
  51863. }
  51864. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  51865. import { Scene } from "babylonjs/scene";
  51866. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51867. import { Mesh } from "babylonjs/Meshes/mesh";
  51868. import { Nullable } from "babylonjs/types";
  51869. /**
  51870. * Class containing static functions to help procedurally build meshes
  51871. */
  51872. export class LatheBuilder {
  51873. /**
  51874. * Creates lathe mesh.
  51875. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51876. * * 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
  51877. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51878. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51879. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51880. * * 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
  51881. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51882. * * 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
  51883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51885. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51887. * @param name defines the name of the mesh
  51888. * @param options defines the options used to create the mesh
  51889. * @param scene defines the hosting scene
  51890. * @returns the lathe mesh
  51891. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51892. */
  51893. static CreateLathe(name: string, options: {
  51894. shape: Vector3[];
  51895. radius?: number;
  51896. tessellation?: number;
  51897. clip?: number;
  51898. arc?: number;
  51899. closed?: boolean;
  51900. updatable?: boolean;
  51901. sideOrientation?: number;
  51902. frontUVs?: Vector4;
  51903. backUVs?: Vector4;
  51904. cap?: number;
  51905. invertUV?: boolean;
  51906. }, scene?: Nullable<Scene>): Mesh;
  51907. }
  51908. }
  51909. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  51910. import { Nullable } from "babylonjs/types";
  51911. import { Scene } from "babylonjs/scene";
  51912. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51913. import { Mesh } from "babylonjs/Meshes/mesh";
  51914. /**
  51915. * Class containing static functions to help procedurally build meshes
  51916. */
  51917. export class TubeBuilder {
  51918. /**
  51919. * Creates a tube mesh.
  51920. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51921. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51922. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51923. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51924. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51925. * * 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)
  51926. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51927. * * 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
  51928. * * 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
  51929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51931. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51933. * @param name defines the name of the mesh
  51934. * @param options defines the options used to create the mesh
  51935. * @param scene defines the hosting scene
  51936. * @returns the tube mesh
  51937. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51938. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51939. */
  51940. static CreateTube(name: string, options: {
  51941. path: Vector3[];
  51942. radius?: number;
  51943. tessellation?: number;
  51944. radiusFunction?: {
  51945. (i: number, distance: number): number;
  51946. };
  51947. cap?: number;
  51948. arc?: number;
  51949. updatable?: boolean;
  51950. sideOrientation?: number;
  51951. frontUVs?: Vector4;
  51952. backUVs?: Vector4;
  51953. instance?: Mesh;
  51954. invertUV?: boolean;
  51955. }, scene?: Nullable<Scene>): Mesh;
  51956. }
  51957. }
  51958. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  51959. import { Scene } from "babylonjs/scene";
  51960. import { Vector4 } from "babylonjs/Maths/math";
  51961. import { Mesh } from "babylonjs/Meshes/mesh";
  51962. import { Nullable } from "babylonjs/types";
  51963. /**
  51964. * Class containing static functions to help procedurally build meshes
  51965. */
  51966. export class IcoSphereBuilder {
  51967. /**
  51968. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51969. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51970. * * 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`)
  51971. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51972. * * 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
  51973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51976. * @param name defines the name of the mesh
  51977. * @param options defines the options used to create the mesh
  51978. * @param scene defines the hosting scene
  51979. * @returns the icosahedron mesh
  51980. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51981. */
  51982. static CreateIcoSphere(name: string, options: {
  51983. radius?: number;
  51984. radiusX?: number;
  51985. radiusY?: number;
  51986. radiusZ?: number;
  51987. flat?: boolean;
  51988. subdivisions?: number;
  51989. sideOrientation?: number;
  51990. frontUVs?: Vector4;
  51991. backUVs?: Vector4;
  51992. updatable?: boolean;
  51993. }, scene?: Nullable<Scene>): Mesh;
  51994. }
  51995. }
  51996. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  51997. import { Vector3 } from "babylonjs/Maths/math";
  51998. import { Mesh } from "babylonjs/Meshes/mesh";
  51999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52000. /**
  52001. * Class containing static functions to help procedurally build meshes
  52002. */
  52003. export class DecalBuilder {
  52004. /**
  52005. * Creates a decal mesh.
  52006. * 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
  52007. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52008. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52009. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52010. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52011. * @param name defines the name of the mesh
  52012. * @param sourceMesh defines the mesh where the decal must be applied
  52013. * @param options defines the options used to create the mesh
  52014. * @param scene defines the hosting scene
  52015. * @returns the decal mesh
  52016. * @see https://doc.babylonjs.com/how_to/decals
  52017. */
  52018. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52019. position?: Vector3;
  52020. normal?: Vector3;
  52021. size?: Vector3;
  52022. angle?: number;
  52023. }): Mesh;
  52024. }
  52025. }
  52026. declare module "babylonjs/Meshes/meshBuilder" {
  52027. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52028. import { Nullable } from "babylonjs/types";
  52029. import { Scene } from "babylonjs/scene";
  52030. import { Mesh } from "babylonjs/Meshes/mesh";
  52031. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52032. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52034. /**
  52035. * Class containing static functions to help procedurally build meshes
  52036. */
  52037. export class MeshBuilder {
  52038. /**
  52039. * Creates a box mesh
  52040. * * The parameter `size` sets the size (float) of each box side (default 1)
  52041. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52042. * * 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)
  52043. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52047. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52048. * @param name defines the name of the mesh
  52049. * @param options defines the options used to create the mesh
  52050. * @param scene defines the hosting scene
  52051. * @returns the box mesh
  52052. */
  52053. static CreateBox(name: string, options: {
  52054. size?: number;
  52055. width?: number;
  52056. height?: number;
  52057. depth?: number;
  52058. faceUV?: Vector4[];
  52059. faceColors?: Color4[];
  52060. sideOrientation?: number;
  52061. frontUVs?: Vector4;
  52062. backUVs?: Vector4;
  52063. updatable?: boolean;
  52064. }, scene?: Nullable<Scene>): Mesh;
  52065. /**
  52066. * Creates a sphere mesh
  52067. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52068. * * 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`)
  52069. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52070. * * 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
  52071. * * 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)
  52072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52075. * @param name defines the name of the mesh
  52076. * @param options defines the options used to create the mesh
  52077. * @param scene defines the hosting scene
  52078. * @returns the sphere mesh
  52079. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52080. */
  52081. static CreateSphere(name: string, options: {
  52082. segments?: number;
  52083. diameter?: number;
  52084. diameterX?: number;
  52085. diameterY?: number;
  52086. diameterZ?: number;
  52087. arc?: number;
  52088. slice?: number;
  52089. sideOrientation?: number;
  52090. frontUVs?: Vector4;
  52091. backUVs?: Vector4;
  52092. updatable?: boolean;
  52093. }, scene?: Nullable<Scene>): Mesh;
  52094. /**
  52095. * Creates a plane polygonal mesh. By default, this is a disc
  52096. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52097. * * 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
  52098. * * 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
  52099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52102. * @param name defines the name of the mesh
  52103. * @param options defines the options used to create the mesh
  52104. * @param scene defines the hosting scene
  52105. * @returns the plane polygonal mesh
  52106. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52107. */
  52108. static CreateDisc(name: string, options: {
  52109. radius?: number;
  52110. tessellation?: number;
  52111. arc?: number;
  52112. updatable?: boolean;
  52113. sideOrientation?: number;
  52114. frontUVs?: Vector4;
  52115. backUVs?: Vector4;
  52116. }, scene?: Nullable<Scene>): Mesh;
  52117. /**
  52118. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52119. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52120. * * 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`)
  52121. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52122. * * 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
  52123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52126. * @param name defines the name of the mesh
  52127. * @param options defines the options used to create the mesh
  52128. * @param scene defines the hosting scene
  52129. * @returns the icosahedron mesh
  52130. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52131. */
  52132. static CreateIcoSphere(name: string, options: {
  52133. radius?: number;
  52134. radiusX?: number;
  52135. radiusY?: number;
  52136. radiusZ?: number;
  52137. flat?: boolean;
  52138. subdivisions?: number;
  52139. sideOrientation?: number;
  52140. frontUVs?: Vector4;
  52141. backUVs?: Vector4;
  52142. updatable?: boolean;
  52143. }, scene?: Nullable<Scene>): Mesh;
  52144. /**
  52145. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52146. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52147. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52148. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52149. * * 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
  52150. * * 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
  52151. * * 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
  52152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52154. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52155. * * 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
  52156. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52157. * * 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
  52158. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52160. * @param name defines the name of the mesh
  52161. * @param options defines the options used to create the mesh
  52162. * @param scene defines the hosting scene
  52163. * @returns the ribbon mesh
  52164. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52165. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52166. */
  52167. static CreateRibbon(name: string, options: {
  52168. pathArray: Vector3[][];
  52169. closeArray?: boolean;
  52170. closePath?: boolean;
  52171. offset?: number;
  52172. updatable?: boolean;
  52173. sideOrientation?: number;
  52174. frontUVs?: Vector4;
  52175. backUVs?: Vector4;
  52176. instance?: Mesh;
  52177. invertUV?: boolean;
  52178. uvs?: Vector2[];
  52179. colors?: Color4[];
  52180. }, scene?: Nullable<Scene>): Mesh;
  52181. /**
  52182. * Creates a cylinder or a cone mesh
  52183. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52184. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52185. * * 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.
  52186. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52187. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52188. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52189. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52190. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52191. * * 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).
  52192. * * 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
  52193. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52194. * * 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
  52195. * * 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.
  52196. * * If `enclose` is false, a ring surface is one element.
  52197. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52198. * * 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
  52199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52200. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52202. * @param name defines the name of the mesh
  52203. * @param options defines the options used to create the mesh
  52204. * @param scene defines the hosting scene
  52205. * @returns the cylinder mesh
  52206. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52207. */
  52208. static CreateCylinder(name: string, options: {
  52209. height?: number;
  52210. diameterTop?: number;
  52211. diameterBottom?: number;
  52212. diameter?: number;
  52213. tessellation?: number;
  52214. subdivisions?: number;
  52215. arc?: number;
  52216. faceColors?: Color4[];
  52217. faceUV?: Vector4[];
  52218. updatable?: boolean;
  52219. hasRings?: boolean;
  52220. enclose?: boolean;
  52221. sideOrientation?: number;
  52222. frontUVs?: Vector4;
  52223. backUVs?: Vector4;
  52224. }, scene?: Nullable<Scene>): Mesh;
  52225. /**
  52226. * Creates a torus mesh
  52227. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52228. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52229. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52233. * @param name defines the name of the mesh
  52234. * @param options defines the options used to create the mesh
  52235. * @param scene defines the hosting scene
  52236. * @returns the torus mesh
  52237. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52238. */
  52239. static CreateTorus(name: string, options: {
  52240. diameter?: number;
  52241. thickness?: number;
  52242. tessellation?: number;
  52243. updatable?: boolean;
  52244. sideOrientation?: number;
  52245. frontUVs?: Vector4;
  52246. backUVs?: Vector4;
  52247. }, scene?: Nullable<Scene>): Mesh;
  52248. /**
  52249. * Creates a torus knot mesh
  52250. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52251. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52252. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52253. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52255. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52257. * @param name defines the name of the mesh
  52258. * @param options defines the options used to create the mesh
  52259. * @param scene defines the hosting scene
  52260. * @returns the torus knot mesh
  52261. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52262. */
  52263. static CreateTorusKnot(name: string, options: {
  52264. radius?: number;
  52265. tube?: number;
  52266. radialSegments?: number;
  52267. tubularSegments?: number;
  52268. p?: number;
  52269. q?: number;
  52270. updatable?: boolean;
  52271. sideOrientation?: number;
  52272. frontUVs?: Vector4;
  52273. backUVs?: Vector4;
  52274. }, scene?: Nullable<Scene>): Mesh;
  52275. /**
  52276. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52277. * * 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
  52278. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52279. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52280. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52281. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52282. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52283. * * 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
  52284. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52286. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52287. * @param name defines the name of the new line system
  52288. * @param options defines the options used to create the line system
  52289. * @param scene defines the hosting scene
  52290. * @returns a new line system mesh
  52291. */
  52292. static CreateLineSystem(name: string, options: {
  52293. lines: Vector3[][];
  52294. updatable?: boolean;
  52295. instance?: Nullable<LinesMesh>;
  52296. colors?: Nullable<Color4[][]>;
  52297. useVertexAlpha?: boolean;
  52298. }, scene: Nullable<Scene>): LinesMesh;
  52299. /**
  52300. * Creates a line mesh
  52301. * 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
  52302. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52303. * * The parameter `points` is an array successive Vector3
  52304. * * 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
  52305. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52306. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52307. * * When updating an instance, remember that only point positions can change, not the number of points
  52308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52309. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52310. * @param name defines the name of the new line system
  52311. * @param options defines the options used to create the line system
  52312. * @param scene defines the hosting scene
  52313. * @returns a new line mesh
  52314. */
  52315. static CreateLines(name: string, options: {
  52316. points: Vector3[];
  52317. updatable?: boolean;
  52318. instance?: Nullable<LinesMesh>;
  52319. colors?: Color4[];
  52320. useVertexAlpha?: boolean;
  52321. }, scene?: Nullable<Scene>): LinesMesh;
  52322. /**
  52323. * Creates a dashed line mesh
  52324. * * 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
  52325. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52326. * * The parameter `points` is an array successive Vector3
  52327. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52328. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52329. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52330. * * 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
  52331. * * When updating an instance, remember that only point positions can change, not the number of points
  52332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52333. * @param name defines the name of the mesh
  52334. * @param options defines the options used to create the mesh
  52335. * @param scene defines the hosting scene
  52336. * @returns the dashed line mesh
  52337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52338. */
  52339. static CreateDashedLines(name: string, options: {
  52340. points: Vector3[];
  52341. dashSize?: number;
  52342. gapSize?: number;
  52343. dashNb?: number;
  52344. updatable?: boolean;
  52345. instance?: LinesMesh;
  52346. }, scene?: Nullable<Scene>): LinesMesh;
  52347. /**
  52348. * 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.
  52349. * * 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.
  52350. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52351. * * 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.
  52352. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52353. * * 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
  52354. * * 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
  52355. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52358. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52360. * @param name defines the name of the mesh
  52361. * @param options defines the options used to create the mesh
  52362. * @param scene defines the hosting scene
  52363. * @returns the extruded shape mesh
  52364. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52365. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52366. */
  52367. static ExtrudeShape(name: string, options: {
  52368. shape: Vector3[];
  52369. path: Vector3[];
  52370. scale?: number;
  52371. rotation?: number;
  52372. cap?: number;
  52373. updatable?: boolean;
  52374. sideOrientation?: number;
  52375. frontUVs?: Vector4;
  52376. backUVs?: Vector4;
  52377. instance?: Mesh;
  52378. invertUV?: boolean;
  52379. }, scene?: Nullable<Scene>): Mesh;
  52380. /**
  52381. * Creates an custom extruded shape mesh.
  52382. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52383. * * 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.
  52384. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52385. * * 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
  52386. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52387. * * 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
  52388. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52389. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52390. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52391. * * 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
  52392. * * 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
  52393. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52396. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52398. * @param name defines the name of the mesh
  52399. * @param options defines the options used to create the mesh
  52400. * @param scene defines the hosting scene
  52401. * @returns the custom extruded shape mesh
  52402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52403. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52404. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52405. */
  52406. static ExtrudeShapeCustom(name: string, options: {
  52407. shape: Vector3[];
  52408. path: Vector3[];
  52409. scaleFunction?: any;
  52410. rotationFunction?: any;
  52411. ribbonCloseArray?: boolean;
  52412. ribbonClosePath?: boolean;
  52413. cap?: number;
  52414. updatable?: boolean;
  52415. sideOrientation?: number;
  52416. frontUVs?: Vector4;
  52417. backUVs?: Vector4;
  52418. instance?: Mesh;
  52419. invertUV?: boolean;
  52420. }, scene?: Nullable<Scene>): Mesh;
  52421. /**
  52422. * Creates lathe mesh.
  52423. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52424. * * 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
  52425. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52426. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52427. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52428. * * 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
  52429. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52430. * * 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
  52431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52433. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52435. * @param name defines the name of the mesh
  52436. * @param options defines the options used to create the mesh
  52437. * @param scene defines the hosting scene
  52438. * @returns the lathe mesh
  52439. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52440. */
  52441. static CreateLathe(name: string, options: {
  52442. shape: Vector3[];
  52443. radius?: number;
  52444. tessellation?: number;
  52445. clip?: number;
  52446. arc?: number;
  52447. closed?: boolean;
  52448. updatable?: boolean;
  52449. sideOrientation?: number;
  52450. frontUVs?: Vector4;
  52451. backUVs?: Vector4;
  52452. cap?: number;
  52453. invertUV?: boolean;
  52454. }, scene?: Nullable<Scene>): Mesh;
  52455. /**
  52456. * Creates a plane mesh
  52457. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52458. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52459. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52463. * @param name defines the name of the mesh
  52464. * @param options defines the options used to create the mesh
  52465. * @param scene defines the hosting scene
  52466. * @returns the plane mesh
  52467. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52468. */
  52469. static CreatePlane(name: string, options: {
  52470. size?: number;
  52471. width?: number;
  52472. height?: number;
  52473. sideOrientation?: number;
  52474. frontUVs?: Vector4;
  52475. backUVs?: Vector4;
  52476. updatable?: boolean;
  52477. sourcePlane?: Plane;
  52478. }, scene?: Nullable<Scene>): Mesh;
  52479. /**
  52480. * Creates a ground mesh
  52481. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52482. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52484. * @param name defines the name of the mesh
  52485. * @param options defines the options used to create the mesh
  52486. * @param scene defines the hosting scene
  52487. * @returns the ground mesh
  52488. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52489. */
  52490. static CreateGround(name: string, options: {
  52491. width?: number;
  52492. height?: number;
  52493. subdivisions?: number;
  52494. subdivisionsX?: number;
  52495. subdivisionsY?: number;
  52496. updatable?: boolean;
  52497. }, scene?: Nullable<Scene>): Mesh;
  52498. /**
  52499. * Creates a tiled ground mesh
  52500. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52501. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52502. * * 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
  52503. * * 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
  52504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52505. * @param name defines the name of the mesh
  52506. * @param options defines the options used to create the mesh
  52507. * @param scene defines the hosting scene
  52508. * @returns the tiled ground mesh
  52509. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52510. */
  52511. static CreateTiledGround(name: string, options: {
  52512. xmin: number;
  52513. zmin: number;
  52514. xmax: number;
  52515. zmax: number;
  52516. subdivisions?: {
  52517. w: number;
  52518. h: number;
  52519. };
  52520. precision?: {
  52521. w: number;
  52522. h: number;
  52523. };
  52524. updatable?: boolean;
  52525. }, scene?: Nullable<Scene>): Mesh;
  52526. /**
  52527. * Creates a ground mesh from a height map
  52528. * * The parameter `url` sets the URL of the height map image resource.
  52529. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52530. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52531. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52532. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52533. * * 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.
  52534. * * 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).
  52535. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52537. * @param name defines the name of the mesh
  52538. * @param url defines the url to the height map
  52539. * @param options defines the options used to create the mesh
  52540. * @param scene defines the hosting scene
  52541. * @returns the ground mesh
  52542. * @see https://doc.babylonjs.com/babylon101/height_map
  52543. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52544. */
  52545. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52546. width?: number;
  52547. height?: number;
  52548. subdivisions?: number;
  52549. minHeight?: number;
  52550. maxHeight?: number;
  52551. colorFilter?: Color3;
  52552. alphaFilter?: number;
  52553. updatable?: boolean;
  52554. onReady?: (mesh: GroundMesh) => void;
  52555. }, scene?: Nullable<Scene>): GroundMesh;
  52556. /**
  52557. * Creates a polygon mesh
  52558. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52559. * * 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
  52560. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52562. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52563. * * Remember you can only change the shape positions, not their number when updating a polygon
  52564. * @param name defines the name of the mesh
  52565. * @param options defines the options used to create the mesh
  52566. * @param scene defines the hosting scene
  52567. * @param earcutInjection can be used to inject your own earcut reference
  52568. * @returns the polygon mesh
  52569. */
  52570. static CreatePolygon(name: string, options: {
  52571. shape: Vector3[];
  52572. holes?: Vector3[][];
  52573. depth?: number;
  52574. faceUV?: Vector4[];
  52575. faceColors?: Color4[];
  52576. updatable?: boolean;
  52577. sideOrientation?: number;
  52578. frontUVs?: Vector4;
  52579. backUVs?: Vector4;
  52580. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52581. /**
  52582. * Creates an extruded polygon mesh, with depth in the Y direction.
  52583. * * 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)
  52584. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52585. * @param name defines the name of the mesh
  52586. * @param options defines the options used to create the mesh
  52587. * @param scene defines the hosting scene
  52588. * @param earcutInjection can be used to inject your own earcut reference
  52589. * @returns the polygon mesh
  52590. */
  52591. static ExtrudePolygon(name: string, options: {
  52592. shape: Vector3[];
  52593. holes?: Vector3[][];
  52594. depth?: number;
  52595. faceUV?: Vector4[];
  52596. faceColors?: Color4[];
  52597. updatable?: boolean;
  52598. sideOrientation?: number;
  52599. frontUVs?: Vector4;
  52600. backUVs?: Vector4;
  52601. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52602. /**
  52603. * Creates a tube mesh.
  52604. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52605. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52606. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52607. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52608. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52609. * * 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)
  52610. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52611. * * 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
  52612. * * 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
  52613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52614. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52615. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52617. * @param name defines the name of the mesh
  52618. * @param options defines the options used to create the mesh
  52619. * @param scene defines the hosting scene
  52620. * @returns the tube mesh
  52621. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52622. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52623. */
  52624. static CreateTube(name: string, options: {
  52625. path: Vector3[];
  52626. radius?: number;
  52627. tessellation?: number;
  52628. radiusFunction?: {
  52629. (i: number, distance: number): number;
  52630. };
  52631. cap?: number;
  52632. arc?: number;
  52633. updatable?: boolean;
  52634. sideOrientation?: number;
  52635. frontUVs?: Vector4;
  52636. backUVs?: Vector4;
  52637. instance?: Mesh;
  52638. invertUV?: boolean;
  52639. }, scene?: Nullable<Scene>): Mesh;
  52640. /**
  52641. * Creates a polyhedron mesh
  52642. * * 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
  52643. * * The parameter `size` (positive float, default 1) sets the polygon size
  52644. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52645. * * 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`
  52646. * * 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
  52647. * * 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)`)
  52648. * * 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
  52649. * * 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
  52650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52653. * @param name defines the name of the mesh
  52654. * @param options defines the options used to create the mesh
  52655. * @param scene defines the hosting scene
  52656. * @returns the polyhedron mesh
  52657. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52658. */
  52659. static CreatePolyhedron(name: string, options: {
  52660. type?: number;
  52661. size?: number;
  52662. sizeX?: number;
  52663. sizeY?: number;
  52664. sizeZ?: number;
  52665. custom?: any;
  52666. faceUV?: Vector4[];
  52667. faceColors?: Color4[];
  52668. flat?: boolean;
  52669. updatable?: boolean;
  52670. sideOrientation?: number;
  52671. frontUVs?: Vector4;
  52672. backUVs?: Vector4;
  52673. }, scene?: Nullable<Scene>): Mesh;
  52674. /**
  52675. * Creates a decal mesh.
  52676. * 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
  52677. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52678. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52679. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52680. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52681. * @param name defines the name of the mesh
  52682. * @param sourceMesh defines the mesh where the decal must be applied
  52683. * @param options defines the options used to create the mesh
  52684. * @param scene defines the hosting scene
  52685. * @returns the decal mesh
  52686. * @see https://doc.babylonjs.com/how_to/decals
  52687. */
  52688. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52689. position?: Vector3;
  52690. normal?: Vector3;
  52691. size?: Vector3;
  52692. angle?: number;
  52693. }): Mesh;
  52694. }
  52695. }
  52696. declare module "babylonjs/Meshes/meshSimplification" {
  52697. import { Mesh } from "babylonjs/Meshes/mesh";
  52698. /**
  52699. * A simplifier interface for future simplification implementations
  52700. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52701. */
  52702. export interface ISimplifier {
  52703. /**
  52704. * Simplification of a given mesh according to the given settings.
  52705. * Since this requires computation, it is assumed that the function runs async.
  52706. * @param settings The settings of the simplification, including quality and distance
  52707. * @param successCallback A callback that will be called after the mesh was simplified.
  52708. * @param errorCallback in case of an error, this callback will be called. optional.
  52709. */
  52710. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52711. }
  52712. /**
  52713. * Expected simplification settings.
  52714. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52715. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52716. */
  52717. export interface ISimplificationSettings {
  52718. /**
  52719. * Gets or sets the expected quality
  52720. */
  52721. quality: number;
  52722. /**
  52723. * Gets or sets the distance when this optimized version should be used
  52724. */
  52725. distance: number;
  52726. /**
  52727. * Gets an already optimized mesh
  52728. */
  52729. optimizeMesh?: boolean;
  52730. }
  52731. /**
  52732. * Class used to specify simplification options
  52733. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52734. */
  52735. export class SimplificationSettings implements ISimplificationSettings {
  52736. /** expected quality */
  52737. quality: number;
  52738. /** distance when this optimized version should be used */
  52739. distance: number;
  52740. /** already optimized mesh */
  52741. optimizeMesh?: boolean | undefined;
  52742. /**
  52743. * Creates a SimplificationSettings
  52744. * @param quality expected quality
  52745. * @param distance distance when this optimized version should be used
  52746. * @param optimizeMesh already optimized mesh
  52747. */
  52748. constructor(
  52749. /** expected quality */
  52750. quality: number,
  52751. /** distance when this optimized version should be used */
  52752. distance: number,
  52753. /** already optimized mesh */
  52754. optimizeMesh?: boolean | undefined);
  52755. }
  52756. /**
  52757. * Interface used to define a simplification task
  52758. */
  52759. export interface ISimplificationTask {
  52760. /**
  52761. * Array of settings
  52762. */
  52763. settings: Array<ISimplificationSettings>;
  52764. /**
  52765. * Simplification type
  52766. */
  52767. simplificationType: SimplificationType;
  52768. /**
  52769. * Mesh to simplify
  52770. */
  52771. mesh: Mesh;
  52772. /**
  52773. * Callback called on success
  52774. */
  52775. successCallback?: () => void;
  52776. /**
  52777. * Defines if parallel processing can be used
  52778. */
  52779. parallelProcessing: boolean;
  52780. }
  52781. /**
  52782. * Queue used to order the simplification tasks
  52783. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52784. */
  52785. export class SimplificationQueue {
  52786. private _simplificationArray;
  52787. /**
  52788. * Gets a boolean indicating that the process is still running
  52789. */
  52790. running: boolean;
  52791. /**
  52792. * Creates a new queue
  52793. */
  52794. constructor();
  52795. /**
  52796. * Adds a new simplification task
  52797. * @param task defines a task to add
  52798. */
  52799. addTask(task: ISimplificationTask): void;
  52800. /**
  52801. * Execute next task
  52802. */
  52803. executeNext(): void;
  52804. /**
  52805. * Execute a simplification task
  52806. * @param task defines the task to run
  52807. */
  52808. runSimplification(task: ISimplificationTask): void;
  52809. private getSimplifier;
  52810. }
  52811. /**
  52812. * The implemented types of simplification
  52813. * At the moment only Quadratic Error Decimation is implemented
  52814. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52815. */
  52816. export enum SimplificationType {
  52817. /** Quadratic error decimation */
  52818. QUADRATIC = 0
  52819. }
  52820. }
  52821. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  52822. import { Scene } from "babylonjs/scene";
  52823. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  52824. import { ISceneComponent } from "babylonjs/sceneComponent";
  52825. module "babylonjs/scene" {
  52826. interface Scene {
  52827. /** @hidden (Backing field) */
  52828. _simplificationQueue: SimplificationQueue;
  52829. /**
  52830. * Gets or sets the simplification queue attached to the scene
  52831. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52832. */
  52833. simplificationQueue: SimplificationQueue;
  52834. }
  52835. }
  52836. module "babylonjs/Meshes/mesh" {
  52837. interface Mesh {
  52838. /**
  52839. * Simplify the mesh according to the given array of settings.
  52840. * Function will return immediately and will simplify async
  52841. * @param settings a collection of simplification settings
  52842. * @param parallelProcessing should all levels calculate parallel or one after the other
  52843. * @param simplificationType the type of simplification to run
  52844. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  52845. * @returns the current mesh
  52846. */
  52847. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  52848. }
  52849. }
  52850. /**
  52851. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  52852. * created in a scene
  52853. */
  52854. export class SimplicationQueueSceneComponent implements ISceneComponent {
  52855. /**
  52856. * The component name helpfull to identify the component in the list of scene components.
  52857. */
  52858. readonly name: string;
  52859. /**
  52860. * The scene the component belongs to.
  52861. */
  52862. scene: Scene;
  52863. /**
  52864. * Creates a new instance of the component for the given scene
  52865. * @param scene Defines the scene to register the component in
  52866. */
  52867. constructor(scene: Scene);
  52868. /**
  52869. * Registers the component in a given scene
  52870. */
  52871. register(): void;
  52872. /**
  52873. * Rebuilds the elements related to this component in case of
  52874. * context lost for instance.
  52875. */
  52876. rebuild(): void;
  52877. /**
  52878. * Disposes the component and the associated ressources
  52879. */
  52880. dispose(): void;
  52881. private _beforeCameraUpdate;
  52882. }
  52883. }
  52884. declare module "babylonjs/Meshes/Builders/index" {
  52885. export * from "babylonjs/Meshes/Builders/boxBuilder";
  52886. export * from "babylonjs/Meshes/Builders/discBuilder";
  52887. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  52888. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  52889. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  52890. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  52891. export * from "babylonjs/Meshes/Builders/torusBuilder";
  52892. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  52893. export * from "babylonjs/Meshes/Builders/linesBuilder";
  52894. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  52895. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  52896. export * from "babylonjs/Meshes/Builders/latheBuilder";
  52897. export * from "babylonjs/Meshes/Builders/planeBuilder";
  52898. export * from "babylonjs/Meshes/Builders/groundBuilder";
  52899. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  52900. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  52901. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  52902. export * from "babylonjs/Meshes/Builders/decalBuilder";
  52903. }
  52904. declare module "babylonjs/Meshes/index" {
  52905. export * from "babylonjs/Meshes/abstractMesh";
  52906. export * from "babylonjs/Meshes/buffer";
  52907. export * from "babylonjs/Meshes/Compression/index";
  52908. export * from "babylonjs/Meshes/csg";
  52909. export * from "babylonjs/Meshes/geometry";
  52910. export * from "babylonjs/Meshes/groundMesh";
  52911. export * from "babylonjs/Meshes/trailMesh";
  52912. export * from "babylonjs/Meshes/instancedMesh";
  52913. export * from "babylonjs/Meshes/linesMesh";
  52914. export * from "babylonjs/Meshes/mesh";
  52915. export * from "babylonjs/Meshes/mesh.vertexData";
  52916. export * from "babylonjs/Meshes/meshBuilder";
  52917. export * from "babylonjs/Meshes/meshSimplification";
  52918. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  52919. export * from "babylonjs/Meshes/polygonMesh";
  52920. export * from "babylonjs/Meshes/subMesh";
  52921. export * from "babylonjs/Meshes/transformNode";
  52922. export * from "babylonjs/Meshes/Builders/index";
  52923. }
  52924. declare module "babylonjs/Morph/index" {
  52925. export * from "babylonjs/Morph/morphTarget";
  52926. export * from "babylonjs/Morph/morphTargetManager";
  52927. }
  52928. declare module "babylonjs/Offline/database" {
  52929. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  52930. /**
  52931. * Class used to enable access to IndexedDB
  52932. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  52933. */
  52934. export class Database implements IOfflineProvider {
  52935. private _callbackManifestChecked;
  52936. private _currentSceneUrl;
  52937. private _db;
  52938. private _enableSceneOffline;
  52939. private _enableTexturesOffline;
  52940. private _manifestVersionFound;
  52941. private _mustUpdateRessources;
  52942. private _hasReachedQuota;
  52943. private _isSupported;
  52944. private _idbFactory;
  52945. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  52946. private static IsUASupportingBlobStorage;
  52947. /**
  52948. * Gets a boolean indicating if Database storate is enabled (off by default)
  52949. */
  52950. static IDBStorageEnabled: boolean;
  52951. /**
  52952. * Gets a boolean indicating if scene must be saved in the database
  52953. */
  52954. readonly enableSceneOffline: boolean;
  52955. /**
  52956. * Gets a boolean indicating if textures must be saved in the database
  52957. */
  52958. readonly enableTexturesOffline: boolean;
  52959. /**
  52960. * Creates a new Database
  52961. * @param urlToScene defines the url to load the scene
  52962. * @param callbackManifestChecked defines the callback to use when manifest is checked
  52963. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  52964. */
  52965. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  52966. private static _ParseURL;
  52967. private static _ReturnFullUrlLocation;
  52968. private _checkManifestFile;
  52969. /**
  52970. * Open the database and make it available
  52971. * @param successCallback defines the callback to call on success
  52972. * @param errorCallback defines the callback to call on error
  52973. */
  52974. open(successCallback: () => void, errorCallback: () => void): void;
  52975. /**
  52976. * Loads an image from the database
  52977. * @param url defines the url to load from
  52978. * @param image defines the target DOM image
  52979. */
  52980. loadImage(url: string, image: HTMLImageElement): void;
  52981. private _loadImageFromDBAsync;
  52982. private _saveImageIntoDBAsync;
  52983. private _checkVersionFromDB;
  52984. private _loadVersionFromDBAsync;
  52985. private _saveVersionIntoDBAsync;
  52986. /**
  52987. * Loads a file from database
  52988. * @param url defines the URL to load from
  52989. * @param sceneLoaded defines a callback to call on success
  52990. * @param progressCallBack defines a callback to call when progress changed
  52991. * @param errorCallback defines a callback to call on error
  52992. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  52993. */
  52994. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  52995. private _loadFileAsync;
  52996. private _saveFileAsync;
  52997. /**
  52998. * Validates if xhr data is correct
  52999. * @param xhr defines the request to validate
  53000. * @param dataType defines the expected data type
  53001. * @returns true if data is correct
  53002. */
  53003. private static _ValidateXHRData;
  53004. }
  53005. }
  53006. declare module "babylonjs/Offline/index" {
  53007. export * from "babylonjs/Offline/database";
  53008. export * from "babylonjs/Offline/IOfflineProvider";
  53009. }
  53010. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53011. /** @hidden */
  53012. export var gpuUpdateParticlesPixelShader: {
  53013. name: string;
  53014. shader: string;
  53015. };
  53016. }
  53017. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53018. /** @hidden */
  53019. export var gpuUpdateParticlesVertexShader: {
  53020. name: string;
  53021. shader: string;
  53022. };
  53023. }
  53024. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53025. /** @hidden */
  53026. export var clipPlaneFragmentDeclaration2: {
  53027. name: string;
  53028. shader: string;
  53029. };
  53030. }
  53031. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53032. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53033. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53034. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53035. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53036. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53037. /** @hidden */
  53038. export var gpuRenderParticlesPixelShader: {
  53039. name: string;
  53040. shader: string;
  53041. };
  53042. }
  53043. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53044. /** @hidden */
  53045. export var clipPlaneVertexDeclaration2: {
  53046. name: string;
  53047. shader: string;
  53048. };
  53049. }
  53050. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53051. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53052. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53053. /** @hidden */
  53054. export var gpuRenderParticlesVertexShader: {
  53055. name: string;
  53056. shader: string;
  53057. };
  53058. }
  53059. declare module "babylonjs/Particles/gpuParticleSystem" {
  53060. import { Nullable } from "babylonjs/types";
  53061. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53062. import { Observable } from "babylonjs/Misc/observable";
  53063. import { Color4, Color3 } from "babylonjs/Maths/math";
  53064. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53065. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53066. import { Scene, IDisposable } from "babylonjs/scene";
  53067. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53068. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53069. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53070. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53071. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53072. /**
  53073. * This represents a GPU particle system in Babylon
  53074. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53075. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53076. */
  53077. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53078. /**
  53079. * The layer mask we are rendering the particles through.
  53080. */
  53081. layerMask: number;
  53082. private _capacity;
  53083. private _activeCount;
  53084. private _currentActiveCount;
  53085. private _accumulatedCount;
  53086. private _renderEffect;
  53087. private _updateEffect;
  53088. private _buffer0;
  53089. private _buffer1;
  53090. private _spriteBuffer;
  53091. private _updateVAO;
  53092. private _renderVAO;
  53093. private _targetIndex;
  53094. private _sourceBuffer;
  53095. private _targetBuffer;
  53096. private _engine;
  53097. private _currentRenderId;
  53098. private _started;
  53099. private _stopped;
  53100. private _timeDelta;
  53101. private _randomTexture;
  53102. private _randomTexture2;
  53103. private _attributesStrideSize;
  53104. private _updateEffectOptions;
  53105. private _randomTextureSize;
  53106. private _actualFrame;
  53107. private readonly _rawTextureWidth;
  53108. /**
  53109. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53110. */
  53111. static readonly IsSupported: boolean;
  53112. /**
  53113. * An event triggered when the system is disposed.
  53114. */
  53115. onDisposeObservable: Observable<GPUParticleSystem>;
  53116. /**
  53117. * Gets the maximum number of particles active at the same time.
  53118. * @returns The max number of active particles.
  53119. */
  53120. getCapacity(): number;
  53121. /**
  53122. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53123. * to override the particles.
  53124. */
  53125. forceDepthWrite: boolean;
  53126. /**
  53127. * Gets or set the number of active particles
  53128. */
  53129. activeParticleCount: number;
  53130. private _preWarmDone;
  53131. /**
  53132. * Is this system ready to be used/rendered
  53133. * @return true if the system is ready
  53134. */
  53135. isReady(): boolean;
  53136. /**
  53137. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53138. * @returns True if it has been started, otherwise false.
  53139. */
  53140. isStarted(): boolean;
  53141. /**
  53142. * Starts the particle system and begins to emit
  53143. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53144. */
  53145. start(delay?: number): void;
  53146. /**
  53147. * Stops the particle system.
  53148. */
  53149. stop(): void;
  53150. /**
  53151. * Remove all active particles
  53152. */
  53153. reset(): void;
  53154. /**
  53155. * Returns the string "GPUParticleSystem"
  53156. * @returns a string containing the class name
  53157. */
  53158. getClassName(): string;
  53159. private _colorGradientsTexture;
  53160. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53161. /**
  53162. * Adds a new color gradient
  53163. * @param gradient defines the gradient to use (between 0 and 1)
  53164. * @param color1 defines the color to affect to the specified gradient
  53165. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53166. * @returns the current particle system
  53167. */
  53168. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53169. /**
  53170. * Remove a specific color gradient
  53171. * @param gradient defines the gradient to remove
  53172. * @returns the current particle system
  53173. */
  53174. removeColorGradient(gradient: number): GPUParticleSystem;
  53175. private _angularSpeedGradientsTexture;
  53176. private _sizeGradientsTexture;
  53177. private _velocityGradientsTexture;
  53178. private _limitVelocityGradientsTexture;
  53179. private _dragGradientsTexture;
  53180. private _addFactorGradient;
  53181. /**
  53182. * Adds a new size gradient
  53183. * @param gradient defines the gradient to use (between 0 and 1)
  53184. * @param factor defines the size factor to affect to the specified gradient
  53185. * @returns the current particle system
  53186. */
  53187. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53188. /**
  53189. * Remove a specific size gradient
  53190. * @param gradient defines the gradient to remove
  53191. * @returns the current particle system
  53192. */
  53193. removeSizeGradient(gradient: number): GPUParticleSystem;
  53194. /**
  53195. * Adds a new angular speed gradient
  53196. * @param gradient defines the gradient to use (between 0 and 1)
  53197. * @param factor defines the angular speed to affect to the specified gradient
  53198. * @returns the current particle system
  53199. */
  53200. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53201. /**
  53202. * Remove a specific angular speed gradient
  53203. * @param gradient defines the gradient to remove
  53204. * @returns the current particle system
  53205. */
  53206. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53207. /**
  53208. * Adds a new velocity gradient
  53209. * @param gradient defines the gradient to use (between 0 and 1)
  53210. * @param factor defines the velocity to affect to the specified gradient
  53211. * @returns the current particle system
  53212. */
  53213. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53214. /**
  53215. * Remove a specific velocity gradient
  53216. * @param gradient defines the gradient to remove
  53217. * @returns the current particle system
  53218. */
  53219. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53220. /**
  53221. * Adds a new limit velocity gradient
  53222. * @param gradient defines the gradient to use (between 0 and 1)
  53223. * @param factor defines the limit velocity value to affect to the specified gradient
  53224. * @returns the current particle system
  53225. */
  53226. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53227. /**
  53228. * Remove a specific limit velocity gradient
  53229. * @param gradient defines the gradient to remove
  53230. * @returns the current particle system
  53231. */
  53232. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53233. /**
  53234. * Adds a new drag gradient
  53235. * @param gradient defines the gradient to use (between 0 and 1)
  53236. * @param factor defines the drag value to affect to the specified gradient
  53237. * @returns the current particle system
  53238. */
  53239. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53240. /**
  53241. * Remove a specific drag gradient
  53242. * @param gradient defines the gradient to remove
  53243. * @returns the current particle system
  53244. */
  53245. removeDragGradient(gradient: number): GPUParticleSystem;
  53246. /**
  53247. * Not supported by GPUParticleSystem
  53248. * @param gradient defines the gradient to use (between 0 and 1)
  53249. * @param factor defines the emit rate value to affect to the specified gradient
  53250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53251. * @returns the current particle system
  53252. */
  53253. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53254. /**
  53255. * Not supported by GPUParticleSystem
  53256. * @param gradient defines the gradient to remove
  53257. * @returns the current particle system
  53258. */
  53259. removeEmitRateGradient(gradient: number): IParticleSystem;
  53260. /**
  53261. * Not supported by GPUParticleSystem
  53262. * @param gradient defines the gradient to use (between 0 and 1)
  53263. * @param factor defines the start size value to affect to the specified gradient
  53264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53265. * @returns the current particle system
  53266. */
  53267. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53268. /**
  53269. * Not supported by GPUParticleSystem
  53270. * @param gradient defines the gradient to remove
  53271. * @returns the current particle system
  53272. */
  53273. removeStartSizeGradient(gradient: number): IParticleSystem;
  53274. /**
  53275. * Not supported by GPUParticleSystem
  53276. * @param gradient defines the gradient to use (between 0 and 1)
  53277. * @param min defines the color remap minimal range
  53278. * @param max defines the color remap maximal range
  53279. * @returns the current particle system
  53280. */
  53281. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53282. /**
  53283. * Not supported by GPUParticleSystem
  53284. * @param gradient defines the gradient to remove
  53285. * @returns the current particle system
  53286. */
  53287. removeColorRemapGradient(): IParticleSystem;
  53288. /**
  53289. * Not supported by GPUParticleSystem
  53290. * @param gradient defines the gradient to use (between 0 and 1)
  53291. * @param min defines the alpha remap minimal range
  53292. * @param max defines the alpha remap maximal range
  53293. * @returns the current particle system
  53294. */
  53295. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53296. /**
  53297. * Not supported by GPUParticleSystem
  53298. * @param gradient defines the gradient to remove
  53299. * @returns the current particle system
  53300. */
  53301. removeAlphaRemapGradient(): IParticleSystem;
  53302. /**
  53303. * Not supported by GPUParticleSystem
  53304. * @param gradient defines the gradient to use (between 0 and 1)
  53305. * @param color defines the color to affect to the specified gradient
  53306. * @returns the current particle system
  53307. */
  53308. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53309. /**
  53310. * Not supported by GPUParticleSystem
  53311. * @param gradient defines the gradient to remove
  53312. * @returns the current particle system
  53313. */
  53314. removeRampGradient(): IParticleSystem;
  53315. /**
  53316. * Not supported by GPUParticleSystem
  53317. * @returns the list of ramp gradients
  53318. */
  53319. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53320. /**
  53321. * Not supported by GPUParticleSystem
  53322. * Gets or sets a boolean indicating that ramp gradients must be used
  53323. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53324. */
  53325. useRampGradients: boolean;
  53326. /**
  53327. * Not supported by GPUParticleSystem
  53328. * @param gradient defines the gradient to use (between 0 and 1)
  53329. * @param factor defines the life time factor to affect to the specified gradient
  53330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53331. * @returns the current particle system
  53332. */
  53333. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53334. /**
  53335. * Not supported by GPUParticleSystem
  53336. * @param gradient defines the gradient to remove
  53337. * @returns the current particle system
  53338. */
  53339. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53340. /**
  53341. * Instantiates a GPU particle system.
  53342. * 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.
  53343. * @param name The name of the particle system
  53344. * @param options The options used to create the system
  53345. * @param scene The scene the particle system belongs to
  53346. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53347. */
  53348. constructor(name: string, options: Partial<{
  53349. capacity: number;
  53350. randomTextureSize: number;
  53351. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53352. protected _reset(): void;
  53353. private _createUpdateVAO;
  53354. private _createRenderVAO;
  53355. private _initialize;
  53356. /** @hidden */
  53357. _recreateUpdateEffect(): void;
  53358. /** @hidden */
  53359. _recreateRenderEffect(): void;
  53360. /**
  53361. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53362. * @param preWarm defines if we are in the pre-warmimg phase
  53363. */
  53364. animate(preWarm?: boolean): void;
  53365. private _createFactorGradientTexture;
  53366. private _createSizeGradientTexture;
  53367. private _createAngularSpeedGradientTexture;
  53368. private _createVelocityGradientTexture;
  53369. private _createLimitVelocityGradientTexture;
  53370. private _createDragGradientTexture;
  53371. private _createColorGradientTexture;
  53372. /**
  53373. * Renders the particle system in its current state
  53374. * @param preWarm defines if the system should only update the particles but not render them
  53375. * @returns the current number of particles
  53376. */
  53377. render(preWarm?: boolean): number;
  53378. /**
  53379. * Rebuilds the particle system
  53380. */
  53381. rebuild(): void;
  53382. private _releaseBuffers;
  53383. private _releaseVAOs;
  53384. /**
  53385. * Disposes the particle system and free the associated resources
  53386. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53387. */
  53388. dispose(disposeTexture?: boolean): void;
  53389. /**
  53390. * Clones the particle system.
  53391. * @param name The name of the cloned object
  53392. * @param newEmitter The new emitter to use
  53393. * @returns the cloned particle system
  53394. */
  53395. clone(name: string, newEmitter: any): GPUParticleSystem;
  53396. /**
  53397. * Serializes the particle system to a JSON object.
  53398. * @returns the JSON object
  53399. */
  53400. serialize(): any;
  53401. /**
  53402. * Parses a JSON object to create a GPU particle system.
  53403. * @param parsedParticleSystem The JSON object to parse
  53404. * @param scene The scene to create the particle system in
  53405. * @param rootUrl The root url to use to load external dependencies like texture
  53406. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53407. * @returns the parsed GPU particle system
  53408. */
  53409. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53410. }
  53411. }
  53412. declare module "babylonjs/Particles/particleSystemSet" {
  53413. import { Nullable } from "babylonjs/types";
  53414. import { Color3 } from "babylonjs/Maths/math";
  53415. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53417. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53418. import { Scene, IDisposable } from "babylonjs/scene";
  53419. /**
  53420. * Represents a set of particle systems working together to create a specific effect
  53421. */
  53422. export class ParticleSystemSet implements IDisposable {
  53423. private _emitterCreationOptions;
  53424. private _emitterNode;
  53425. /**
  53426. * Gets the particle system list
  53427. */
  53428. systems: IParticleSystem[];
  53429. /**
  53430. * Gets the emitter node used with this set
  53431. */
  53432. readonly emitterNode: Nullable<TransformNode>;
  53433. /**
  53434. * Creates a new emitter mesh as a sphere
  53435. * @param options defines the options used to create the sphere
  53436. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53437. * @param scene defines the hosting scene
  53438. */
  53439. setEmitterAsSphere(options: {
  53440. diameter: number;
  53441. segments: number;
  53442. color: Color3;
  53443. }, renderingGroupId: number, scene: Scene): void;
  53444. /**
  53445. * Starts all particle systems of the set
  53446. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53447. */
  53448. start(emitter?: AbstractMesh): void;
  53449. /**
  53450. * Release all associated resources
  53451. */
  53452. dispose(): void;
  53453. /**
  53454. * Serialize the set into a JSON compatible object
  53455. * @returns a JSON compatible representation of the set
  53456. */
  53457. serialize(): any;
  53458. /**
  53459. * Parse a new ParticleSystemSet from a serialized source
  53460. * @param data defines a JSON compatible representation of the set
  53461. * @param scene defines the hosting scene
  53462. * @param gpu defines if we want GPU particles or CPU particles
  53463. * @returns a new ParticleSystemSet
  53464. */
  53465. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53466. }
  53467. }
  53468. declare module "babylonjs/Particles/particleHelper" {
  53469. import { Nullable } from "babylonjs/types";
  53470. import { Scene } from "babylonjs/scene";
  53471. import { Vector3 } from "babylonjs/Maths/math";
  53472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53473. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53474. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  53475. /**
  53476. * This class is made for on one-liner static method to help creating particle system set.
  53477. */
  53478. export class ParticleHelper {
  53479. /**
  53480. * Gets or sets base Assets URL
  53481. */
  53482. static BaseAssetsUrl: string;
  53483. /**
  53484. * Create a default particle system that you can tweak
  53485. * @param emitter defines the emitter to use
  53486. * @param capacity defines the system capacity (default is 500 particles)
  53487. * @param scene defines the hosting scene
  53488. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53489. * @returns the new Particle system
  53490. */
  53491. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53492. /**
  53493. * This is the main static method (one-liner) of this helper to create different particle systems
  53494. * @param type This string represents the type to the particle system to create
  53495. * @param scene The scene where the particle system should live
  53496. * @param gpu If the system will use gpu
  53497. * @returns the ParticleSystemSet created
  53498. */
  53499. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53500. /**
  53501. * Static function used to export a particle system to a ParticleSystemSet variable.
  53502. * Please note that the emitter shape is not exported
  53503. * @param systems defines the particle systems to export
  53504. * @returns the created particle system set
  53505. */
  53506. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53507. }
  53508. }
  53509. declare module "babylonjs/Particles/particleSystemComponent" {
  53510. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53511. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53512. import "babylonjs/Shaders/particles.vertex";
  53513. module "babylonjs/Engines/engine" {
  53514. interface Engine {
  53515. /**
  53516. * Create an effect to use with particle systems.
  53517. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53518. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53519. * @param uniformsNames defines a list of attribute names
  53520. * @param samplers defines an array of string used to represent textures
  53521. * @param defines defines the string containing the defines to use to compile the shaders
  53522. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53523. * @param onCompiled defines a function to call when the effect creation is successful
  53524. * @param onError defines a function to call when the effect creation has failed
  53525. * @returns the new Effect
  53526. */
  53527. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53528. }
  53529. }
  53530. module "babylonjs/Meshes/mesh" {
  53531. interface Mesh {
  53532. /**
  53533. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53534. * @returns an array of IParticleSystem
  53535. */
  53536. getEmittedParticleSystems(): IParticleSystem[];
  53537. /**
  53538. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53539. * @returns an array of IParticleSystem
  53540. */
  53541. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53542. }
  53543. }
  53544. /**
  53545. * @hidden
  53546. */
  53547. export var _IDoNeedToBeInTheBuild: number;
  53548. }
  53549. declare module "babylonjs/Particles/index" {
  53550. export * from "babylonjs/Particles/baseParticleSystem";
  53551. export * from "babylonjs/Particles/EmitterTypes/index";
  53552. export * from "babylonjs/Particles/gpuParticleSystem";
  53553. export * from "babylonjs/Particles/IParticleSystem";
  53554. export * from "babylonjs/Particles/particle";
  53555. export * from "babylonjs/Particles/particleHelper";
  53556. export * from "babylonjs/Particles/particleSystem";
  53557. export * from "babylonjs/Particles/particleSystemComponent";
  53558. export * from "babylonjs/Particles/particleSystemSet";
  53559. export * from "babylonjs/Particles/solidParticle";
  53560. export * from "babylonjs/Particles/solidParticleSystem";
  53561. export * from "babylonjs/Particles/subEmitter";
  53562. }
  53563. declare module "babylonjs/Physics/physicsEngineComponent" {
  53564. import { Nullable } from "babylonjs/types";
  53565. import { Observable, Observer } from "babylonjs/Misc/observable";
  53566. import { Vector3 } from "babylonjs/Maths/math";
  53567. import { Mesh } from "babylonjs/Meshes/mesh";
  53568. import { ISceneComponent } from "babylonjs/sceneComponent";
  53569. import { Scene } from "babylonjs/scene";
  53570. import { Node } from "babylonjs/node";
  53571. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53572. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53573. module "babylonjs/scene" {
  53574. interface Scene {
  53575. /** @hidden (Backing field) */
  53576. _physicsEngine: Nullable<IPhysicsEngine>;
  53577. /**
  53578. * Gets the current physics engine
  53579. * @returns a IPhysicsEngine or null if none attached
  53580. */
  53581. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53582. /**
  53583. * Enables physics to the current scene
  53584. * @param gravity defines the scene's gravity for the physics engine
  53585. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53586. * @return a boolean indicating if the physics engine was initialized
  53587. */
  53588. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53589. /**
  53590. * Disables and disposes the physics engine associated with the scene
  53591. */
  53592. disablePhysicsEngine(): void;
  53593. /**
  53594. * Gets a boolean indicating if there is an active physics engine
  53595. * @returns a boolean indicating if there is an active physics engine
  53596. */
  53597. isPhysicsEnabled(): boolean;
  53598. /**
  53599. * Deletes a physics compound impostor
  53600. * @param compound defines the compound to delete
  53601. */
  53602. deleteCompoundImpostor(compound: any): void;
  53603. /**
  53604. * An event triggered when physic simulation is about to be run
  53605. */
  53606. onBeforePhysicsObservable: Observable<Scene>;
  53607. /**
  53608. * An event triggered when physic simulation has been done
  53609. */
  53610. onAfterPhysicsObservable: Observable<Scene>;
  53611. }
  53612. }
  53613. module "babylonjs/Meshes/abstractMesh" {
  53614. interface AbstractMesh {
  53615. /** @hidden */
  53616. _physicsImpostor: Nullable<PhysicsImpostor>;
  53617. /**
  53618. * Gets or sets impostor used for physic simulation
  53619. * @see http://doc.babylonjs.com/features/physics_engine
  53620. */
  53621. physicsImpostor: Nullable<PhysicsImpostor>;
  53622. /**
  53623. * Gets the current physics impostor
  53624. * @see http://doc.babylonjs.com/features/physics_engine
  53625. * @returns a physics impostor or null
  53626. */
  53627. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53628. /** Apply a physic impulse to the mesh
  53629. * @param force defines the force to apply
  53630. * @param contactPoint defines where to apply the force
  53631. * @returns the current mesh
  53632. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53633. */
  53634. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53635. /**
  53636. * Creates a physic joint between two meshes
  53637. * @param otherMesh defines the other mesh to use
  53638. * @param pivot1 defines the pivot to use on this mesh
  53639. * @param pivot2 defines the pivot to use on the other mesh
  53640. * @param options defines additional options (can be plugin dependent)
  53641. * @returns the current mesh
  53642. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53643. */
  53644. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53645. /** @hidden */
  53646. _disposePhysicsObserver: Nullable<Observer<Node>>;
  53647. }
  53648. }
  53649. /**
  53650. * Defines the physics engine scene component responsible to manage a physics engine
  53651. */
  53652. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53653. /**
  53654. * The component name helpful to identify the component in the list of scene components.
  53655. */
  53656. readonly name: string;
  53657. /**
  53658. * The scene the component belongs to.
  53659. */
  53660. scene: Scene;
  53661. /**
  53662. * Creates a new instance of the component for the given scene
  53663. * @param scene Defines the scene to register the component in
  53664. */
  53665. constructor(scene: Scene);
  53666. /**
  53667. * Registers the component in a given scene
  53668. */
  53669. register(): void;
  53670. /**
  53671. * Rebuilds the elements related to this component in case of
  53672. * context lost for instance.
  53673. */
  53674. rebuild(): void;
  53675. /**
  53676. * Disposes the component and the associated ressources
  53677. */
  53678. dispose(): void;
  53679. }
  53680. }
  53681. declare module "babylonjs/Physics/physicsHelper" {
  53682. import { Nullable } from "babylonjs/types";
  53683. import { Vector3 } from "babylonjs/Maths/math";
  53684. import { Mesh } from "babylonjs/Meshes/mesh";
  53685. import { Scene } from "babylonjs/scene";
  53686. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53687. /**
  53688. * A helper for physics simulations
  53689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53690. */
  53691. export class PhysicsHelper {
  53692. private _scene;
  53693. private _physicsEngine;
  53694. /**
  53695. * Initializes the Physics helper
  53696. * @param scene Babylon.js scene
  53697. */
  53698. constructor(scene: Scene);
  53699. /**
  53700. * Applies a radial explosion impulse
  53701. * @param origin the origin of the explosion
  53702. * @param radiusOrEventOptions the radius or the options of radial explosion
  53703. * @param strength the explosion strength
  53704. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53705. * @returns A physics radial explosion event, or null
  53706. */
  53707. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53708. /**
  53709. * Applies a radial explosion force
  53710. * @param origin the origin of the explosion
  53711. * @param radiusOrEventOptions the radius or the options of radial explosion
  53712. * @param strength the explosion strength
  53713. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53714. * @returns A physics radial explosion event, or null
  53715. */
  53716. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53717. /**
  53718. * Creates a gravitational field
  53719. * @param origin the origin of the explosion
  53720. * @param radiusOrEventOptions the radius or the options of radial explosion
  53721. * @param strength the explosion strength
  53722. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53723. * @returns A physics gravitational field event, or null
  53724. */
  53725. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  53726. /**
  53727. * Creates a physics updraft event
  53728. * @param origin the origin of the updraft
  53729. * @param radiusOrEventOptions the radius or the options of the updraft
  53730. * @param strength the strength of the updraft
  53731. * @param height the height of the updraft
  53732. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  53733. * @returns A physics updraft event, or null
  53734. */
  53735. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  53736. /**
  53737. * Creates a physics vortex event
  53738. * @param origin the of the vortex
  53739. * @param radiusOrEventOptions the radius or the options of the vortex
  53740. * @param strength the strength of the vortex
  53741. * @param height the height of the vortex
  53742. * @returns a Physics vortex event, or null
  53743. * A physics vortex event or null
  53744. */
  53745. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  53746. }
  53747. /**
  53748. * Represents a physics radial explosion event
  53749. */
  53750. class PhysicsRadialExplosionEvent {
  53751. private _scene;
  53752. private _options;
  53753. private _sphere;
  53754. private _dataFetched;
  53755. /**
  53756. * Initializes a radial explosioin event
  53757. * @param _scene BabylonJS scene
  53758. * @param _options The options for the vortex event
  53759. */
  53760. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  53761. /**
  53762. * Returns the data related to the radial explosion event (sphere).
  53763. * @returns The radial explosion event data
  53764. */
  53765. getData(): PhysicsRadialExplosionEventData;
  53766. /**
  53767. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  53768. * @param impostor A physics imposter
  53769. * @param origin the origin of the explosion
  53770. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  53771. */
  53772. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  53773. /**
  53774. * Triggers affecterd impostors callbacks
  53775. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  53776. */
  53777. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  53778. /**
  53779. * Disposes the sphere.
  53780. * @param force Specifies if the sphere should be disposed by force
  53781. */
  53782. dispose(force?: boolean): void;
  53783. /*** Helpers ***/
  53784. private _prepareSphere;
  53785. private _intersectsWithSphere;
  53786. }
  53787. /**
  53788. * Represents a gravitational field event
  53789. */
  53790. class PhysicsGravitationalFieldEvent {
  53791. private _physicsHelper;
  53792. private _scene;
  53793. private _origin;
  53794. private _options;
  53795. private _tickCallback;
  53796. private _sphere;
  53797. private _dataFetched;
  53798. /**
  53799. * Initializes the physics gravitational field event
  53800. * @param _physicsHelper A physics helper
  53801. * @param _scene BabylonJS scene
  53802. * @param _origin The origin position of the gravitational field event
  53803. * @param _options The options for the vortex event
  53804. */
  53805. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  53806. /**
  53807. * Returns the data related to the gravitational field event (sphere).
  53808. * @returns A gravitational field event
  53809. */
  53810. getData(): PhysicsGravitationalFieldEventData;
  53811. /**
  53812. * Enables the gravitational field.
  53813. */
  53814. enable(): void;
  53815. /**
  53816. * Disables the gravitational field.
  53817. */
  53818. disable(): void;
  53819. /**
  53820. * Disposes the sphere.
  53821. * @param force The force to dispose from the gravitational field event
  53822. */
  53823. dispose(force?: boolean): void;
  53824. private _tick;
  53825. }
  53826. /**
  53827. * Represents a physics updraft event
  53828. */
  53829. class PhysicsUpdraftEvent {
  53830. private _scene;
  53831. private _origin;
  53832. private _options;
  53833. private _physicsEngine;
  53834. private _originTop;
  53835. private _originDirection;
  53836. private _tickCallback;
  53837. private _cylinder;
  53838. private _cylinderPosition;
  53839. private _dataFetched;
  53840. /**
  53841. * Initializes the physics updraft event
  53842. * @param _scene BabylonJS scene
  53843. * @param _origin The origin position of the updraft
  53844. * @param _options The options for the updraft event
  53845. */
  53846. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  53847. /**
  53848. * Returns the data related to the updraft event (cylinder).
  53849. * @returns A physics updraft event
  53850. */
  53851. getData(): PhysicsUpdraftEventData;
  53852. /**
  53853. * Enables the updraft.
  53854. */
  53855. enable(): void;
  53856. /**
  53857. * Disables the updraft.
  53858. */
  53859. disable(): void;
  53860. /**
  53861. * Disposes the cylinder.
  53862. * @param force Specifies if the updraft should be disposed by force
  53863. */
  53864. dispose(force?: boolean): void;
  53865. private getImpostorHitData;
  53866. private _tick;
  53867. /*** Helpers ***/
  53868. private _prepareCylinder;
  53869. private _intersectsWithCylinder;
  53870. }
  53871. /**
  53872. * Represents a physics vortex event
  53873. */
  53874. class PhysicsVortexEvent {
  53875. private _scene;
  53876. private _origin;
  53877. private _options;
  53878. private _physicsEngine;
  53879. private _originTop;
  53880. private _tickCallback;
  53881. private _cylinder;
  53882. private _cylinderPosition;
  53883. private _dataFetched;
  53884. /**
  53885. * Initializes the physics vortex event
  53886. * @param _scene The BabylonJS scene
  53887. * @param _origin The origin position of the vortex
  53888. * @param _options The options for the vortex event
  53889. */
  53890. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  53891. /**
  53892. * Returns the data related to the vortex event (cylinder).
  53893. * @returns The physics vortex event data
  53894. */
  53895. getData(): PhysicsVortexEventData;
  53896. /**
  53897. * Enables the vortex.
  53898. */
  53899. enable(): void;
  53900. /**
  53901. * Disables the cortex.
  53902. */
  53903. disable(): void;
  53904. /**
  53905. * Disposes the sphere.
  53906. * @param force
  53907. */
  53908. dispose(force?: boolean): void;
  53909. private getImpostorHitData;
  53910. private _tick;
  53911. /*** Helpers ***/
  53912. private _prepareCylinder;
  53913. private _intersectsWithCylinder;
  53914. }
  53915. /**
  53916. * Options fot the radial explosion event
  53917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53918. */
  53919. export class PhysicsRadialExplosionEventOptions {
  53920. /**
  53921. * The radius of the sphere for the radial explosion.
  53922. */
  53923. radius: number;
  53924. /**
  53925. * The strenth of the explosion.
  53926. */
  53927. strength: number;
  53928. /**
  53929. * The strenght of the force in correspondence to the distance of the affected object
  53930. */
  53931. falloff: PhysicsRadialImpulseFalloff;
  53932. /**
  53933. * Sphere options for the radial explosion.
  53934. */
  53935. sphere: {
  53936. segments: number;
  53937. diameter: number;
  53938. };
  53939. /**
  53940. * Sphere options for the radial explosion.
  53941. */
  53942. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  53943. }
  53944. /**
  53945. * Options fot the updraft event
  53946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53947. */
  53948. export class PhysicsUpdraftEventOptions {
  53949. /**
  53950. * The radius of the cylinder for the vortex
  53951. */
  53952. radius: number;
  53953. /**
  53954. * The strenth of the updraft.
  53955. */
  53956. strength: number;
  53957. /**
  53958. * The height of the cylinder for the updraft.
  53959. */
  53960. height: number;
  53961. /**
  53962. * The mode for the the updraft.
  53963. */
  53964. updraftMode: PhysicsUpdraftMode;
  53965. }
  53966. /**
  53967. * Options fot the vortex event
  53968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53969. */
  53970. export class PhysicsVortexEventOptions {
  53971. /**
  53972. * The radius of the cylinder for the vortex
  53973. */
  53974. radius: number;
  53975. /**
  53976. * The strenth of the vortex.
  53977. */
  53978. strength: number;
  53979. /**
  53980. * The height of the cylinder for the vortex.
  53981. */
  53982. height: number;
  53983. /**
  53984. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  53985. */
  53986. centripetalForceThreshold: number;
  53987. /**
  53988. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  53989. */
  53990. centripetalForceMultiplier: number;
  53991. /**
  53992. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  53993. */
  53994. centrifugalForceMultiplier: number;
  53995. /**
  53996. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  53997. */
  53998. updraftForceMultiplier: number;
  53999. }
  54000. /**
  54001. * The strenght of the force in correspondence to the distance of the affected object
  54002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54003. */
  54004. export enum PhysicsRadialImpulseFalloff {
  54005. /** Defines that impulse is constant in strength across it's whole radius */
  54006. Constant = 0,
  54007. /** Defines that impulse gets weaker if it's further from the origin */
  54008. Linear = 1
  54009. }
  54010. /**
  54011. * The strength of the force in correspondence to the distance of the affected object
  54012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54013. */
  54014. export enum PhysicsUpdraftMode {
  54015. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54016. Center = 0,
  54017. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54018. Perpendicular = 1
  54019. }
  54020. /**
  54021. * Interface for a physics hit data
  54022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54023. */
  54024. export interface PhysicsHitData {
  54025. /**
  54026. * The force applied at the contact point
  54027. */
  54028. force: Vector3;
  54029. /**
  54030. * The contact point
  54031. */
  54032. contactPoint: Vector3;
  54033. /**
  54034. * The distance from the origin to the contact point
  54035. */
  54036. distanceFromOrigin: number;
  54037. }
  54038. /**
  54039. * Interface for radial explosion event data
  54040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54041. */
  54042. export interface PhysicsRadialExplosionEventData {
  54043. /**
  54044. * A sphere used for the radial explosion event
  54045. */
  54046. sphere: Mesh;
  54047. }
  54048. /**
  54049. * Interface for gravitational field event data
  54050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54051. */
  54052. export interface PhysicsGravitationalFieldEventData {
  54053. /**
  54054. * A sphere mesh used for the gravitational field event
  54055. */
  54056. sphere: Mesh;
  54057. }
  54058. /**
  54059. * Interface for updraft event data
  54060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54061. */
  54062. export interface PhysicsUpdraftEventData {
  54063. /**
  54064. * A cylinder used for the updraft event
  54065. */
  54066. cylinder: Mesh;
  54067. }
  54068. /**
  54069. * Interface for vortex event data
  54070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54071. */
  54072. export interface PhysicsVortexEventData {
  54073. /**
  54074. * A cylinder used for the vortex event
  54075. */
  54076. cylinder: Mesh;
  54077. }
  54078. /**
  54079. * Interface for an affected physics impostor
  54080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54081. */
  54082. export interface PhysicsAffectedImpostorWithData {
  54083. /**
  54084. * The impostor affected by the effect
  54085. */
  54086. impostor: PhysicsImpostor;
  54087. /**
  54088. * The data about the hit/horce from the explosion
  54089. */
  54090. hitData: PhysicsHitData;
  54091. }
  54092. }
  54093. declare module "babylonjs/Physics/Plugins/index" {
  54094. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54095. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54096. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54097. }
  54098. declare module "babylonjs/Physics/index" {
  54099. export * from "babylonjs/Physics/IPhysicsEngine";
  54100. export * from "babylonjs/Physics/physicsEngine";
  54101. export * from "babylonjs/Physics/physicsEngineComponent";
  54102. export * from "babylonjs/Physics/physicsHelper";
  54103. export * from "babylonjs/Physics/physicsImpostor";
  54104. export * from "babylonjs/Physics/physicsJoint";
  54105. export * from "babylonjs/Physics/Plugins/index";
  54106. }
  54107. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54108. /** @hidden */
  54109. export var blackAndWhitePixelShader: {
  54110. name: string;
  54111. shader: string;
  54112. };
  54113. }
  54114. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54115. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54116. import { Camera } from "babylonjs/Cameras/camera";
  54117. import { Engine } from "babylonjs/Engines/engine";
  54118. import "babylonjs/Shaders/blackAndWhite.fragment";
  54119. /**
  54120. * Post process used to render in black and white
  54121. */
  54122. export class BlackAndWhitePostProcess extends PostProcess {
  54123. /**
  54124. * Linear about to convert he result to black and white (default: 1)
  54125. */
  54126. degree: number;
  54127. /**
  54128. * Creates a black and white post process
  54129. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54130. * @param name The name of the effect.
  54131. * @param options The required width/height ratio to downsize to before computing the render pass.
  54132. * @param camera The camera to apply the render pass to.
  54133. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54134. * @param engine The engine which the post process will be applied. (default: current engine)
  54135. * @param reusable If the post process can be reused on the same frame. (default: false)
  54136. */
  54137. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54138. }
  54139. }
  54140. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54141. import { Nullable } from "babylonjs/types";
  54142. import { Camera } from "babylonjs/Cameras/camera";
  54143. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54144. import { Engine } from "babylonjs/Engines/engine";
  54145. /**
  54146. * This represents a set of one or more post processes in Babylon.
  54147. * A post process can be used to apply a shader to a texture after it is rendered.
  54148. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54149. */
  54150. export class PostProcessRenderEffect {
  54151. private _postProcesses;
  54152. private _getPostProcesses;
  54153. private _singleInstance;
  54154. private _cameras;
  54155. private _indicesForCamera;
  54156. /**
  54157. * Name of the effect
  54158. * @hidden
  54159. */
  54160. _name: string;
  54161. /**
  54162. * Instantiates a post process render effect.
  54163. * A post process can be used to apply a shader to a texture after it is rendered.
  54164. * @param engine The engine the effect is tied to
  54165. * @param name The name of the effect
  54166. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54167. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54168. */
  54169. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54170. /**
  54171. * Checks if all the post processes in the effect are supported.
  54172. */
  54173. readonly isSupported: boolean;
  54174. /**
  54175. * Updates the current state of the effect
  54176. * @hidden
  54177. */
  54178. _update(): void;
  54179. /**
  54180. * Attaches the effect on cameras
  54181. * @param cameras The camera to attach to.
  54182. * @hidden
  54183. */
  54184. _attachCameras(cameras: Camera): void;
  54185. /**
  54186. * Attaches the effect on cameras
  54187. * @param cameras The camera to attach to.
  54188. * @hidden
  54189. */
  54190. _attachCameras(cameras: Camera[]): void;
  54191. /**
  54192. * Detatches the effect on cameras
  54193. * @param cameras The camera to detatch from.
  54194. * @hidden
  54195. */
  54196. _detachCameras(cameras: Camera): void;
  54197. /**
  54198. * Detatches the effect on cameras
  54199. * @param cameras The camera to detatch from.
  54200. * @hidden
  54201. */
  54202. _detachCameras(cameras: Camera[]): void;
  54203. /**
  54204. * Enables the effect on given cameras
  54205. * @param cameras The camera to enable.
  54206. * @hidden
  54207. */
  54208. _enable(cameras: Camera): void;
  54209. /**
  54210. * Enables the effect on given cameras
  54211. * @param cameras The camera to enable.
  54212. * @hidden
  54213. */
  54214. _enable(cameras: Nullable<Camera[]>): void;
  54215. /**
  54216. * Disables the effect on the given cameras
  54217. * @param cameras The camera to disable.
  54218. * @hidden
  54219. */
  54220. _disable(cameras: Camera): void;
  54221. /**
  54222. * Disables the effect on the given cameras
  54223. * @param cameras The camera to disable.
  54224. * @hidden
  54225. */
  54226. _disable(cameras: Nullable<Camera[]>): void;
  54227. /**
  54228. * Gets a list of the post processes contained in the effect.
  54229. * @param camera The camera to get the post processes on.
  54230. * @returns The list of the post processes in the effect.
  54231. */
  54232. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54233. }
  54234. }
  54235. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54236. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54237. /** @hidden */
  54238. export var extractHighlightsPixelShader: {
  54239. name: string;
  54240. shader: string;
  54241. };
  54242. }
  54243. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54244. import { Nullable } from "babylonjs/types";
  54245. import { Camera } from "babylonjs/Cameras/camera";
  54246. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54247. import { Engine } from "babylonjs/Engines/engine";
  54248. import "babylonjs/Shaders/extractHighlights.fragment";
  54249. /**
  54250. * 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.
  54251. */
  54252. export class ExtractHighlightsPostProcess extends PostProcess {
  54253. /**
  54254. * The luminance threshold, pixels below this value will be set to black.
  54255. */
  54256. threshold: number;
  54257. /** @hidden */
  54258. _exposure: number;
  54259. /**
  54260. * Post process which has the input texture to be used when performing highlight extraction
  54261. * @hidden
  54262. */
  54263. _inputPostProcess: Nullable<PostProcess>;
  54264. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54265. }
  54266. }
  54267. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54268. /** @hidden */
  54269. export var bloomMergePixelShader: {
  54270. name: string;
  54271. shader: string;
  54272. };
  54273. }
  54274. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54275. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54276. import { Nullable } from "babylonjs/types";
  54277. import { Engine } from "babylonjs/Engines/engine";
  54278. import { Camera } from "babylonjs/Cameras/camera";
  54279. import "babylonjs/Shaders/bloomMerge.fragment";
  54280. /**
  54281. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54282. */
  54283. export class BloomMergePostProcess extends PostProcess {
  54284. /** Weight of the bloom to be added to the original input. */
  54285. weight: number;
  54286. /**
  54287. * Creates a new instance of @see BloomMergePostProcess
  54288. * @param name The name of the effect.
  54289. * @param originalFromInput Post process which's input will be used for the merge.
  54290. * @param blurred Blurred highlights post process which's output will be used.
  54291. * @param weight Weight of the bloom to be added to the original input.
  54292. * @param options The required width/height ratio to downsize to before computing the render pass.
  54293. * @param camera The camera to apply the render pass to.
  54294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54295. * @param engine The engine which the post process will be applied. (default: current engine)
  54296. * @param reusable If the post process can be reused on the same frame. (default: false)
  54297. * @param textureType Type of textures used when performing the post process. (default: 0)
  54298. * @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)
  54299. */
  54300. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54301. /** Weight of the bloom to be added to the original input. */
  54302. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54303. }
  54304. }
  54305. declare module "babylonjs/PostProcesses/bloomEffect" {
  54306. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54307. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54308. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54309. import { Camera } from "babylonjs/Cameras/camera";
  54310. import { Scene } from "babylonjs/scene";
  54311. /**
  54312. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54313. */
  54314. export class BloomEffect extends PostProcessRenderEffect {
  54315. private bloomScale;
  54316. /**
  54317. * @hidden Internal
  54318. */
  54319. _effects: Array<PostProcess>;
  54320. /**
  54321. * @hidden Internal
  54322. */
  54323. _downscale: ExtractHighlightsPostProcess;
  54324. private _blurX;
  54325. private _blurY;
  54326. private _merge;
  54327. /**
  54328. * The luminance threshold to find bright areas of the image to bloom.
  54329. */
  54330. threshold: number;
  54331. /**
  54332. * The strength of the bloom.
  54333. */
  54334. weight: number;
  54335. /**
  54336. * Specifies the size of the bloom blur kernel, relative to the final output size
  54337. */
  54338. kernel: number;
  54339. /**
  54340. * Creates a new instance of @see BloomEffect
  54341. * @param scene The scene the effect belongs to.
  54342. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54343. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54344. * @param bloomWeight The the strength of bloom.
  54345. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54346. * @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)
  54347. */
  54348. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54349. /**
  54350. * Disposes each of the internal effects for a given camera.
  54351. * @param camera The camera to dispose the effect on.
  54352. */
  54353. disposeEffects(camera: Camera): void;
  54354. /**
  54355. * @hidden Internal
  54356. */
  54357. _updateEffects(): void;
  54358. /**
  54359. * Internal
  54360. * @returns if all the contained post processes are ready.
  54361. * @hidden
  54362. */
  54363. _isReady(): boolean;
  54364. }
  54365. }
  54366. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54367. /** @hidden */
  54368. export var chromaticAberrationPixelShader: {
  54369. name: string;
  54370. shader: string;
  54371. };
  54372. }
  54373. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54374. import { Vector2 } from "babylonjs/Maths/math";
  54375. import { Nullable } from "babylonjs/types";
  54376. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54377. import { Camera } from "babylonjs/Cameras/camera";
  54378. import { Engine } from "babylonjs/Engines/engine";
  54379. import "babylonjs/Shaders/chromaticAberration.fragment";
  54380. /**
  54381. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54382. */
  54383. export class ChromaticAberrationPostProcess extends PostProcess {
  54384. /**
  54385. * The amount of seperation of rgb channels (default: 30)
  54386. */
  54387. aberrationAmount: number;
  54388. /**
  54389. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54390. */
  54391. radialIntensity: number;
  54392. /**
  54393. * 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))
  54394. */
  54395. direction: Vector2;
  54396. /**
  54397. * 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))
  54398. */
  54399. centerPosition: Vector2;
  54400. /**
  54401. * Creates a new instance ChromaticAberrationPostProcess
  54402. * @param name The name of the effect.
  54403. * @param screenWidth The width of the screen to apply the effect on.
  54404. * @param screenHeight The height of the screen to apply the effect on.
  54405. * @param options The required width/height ratio to downsize to before computing the render pass.
  54406. * @param camera The camera to apply the render pass to.
  54407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54408. * @param engine The engine which the post process will be applied. (default: current engine)
  54409. * @param reusable If the post process can be reused on the same frame. (default: false)
  54410. * @param textureType Type of textures used when performing the post process. (default: 0)
  54411. * @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)
  54412. */
  54413. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54414. }
  54415. }
  54416. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54417. /** @hidden */
  54418. export var circleOfConfusionPixelShader: {
  54419. name: string;
  54420. shader: string;
  54421. };
  54422. }
  54423. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54424. import { Nullable } from "babylonjs/types";
  54425. import { Engine } from "babylonjs/Engines/engine";
  54426. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54427. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54428. import { Camera } from "babylonjs/Cameras/camera";
  54429. import "babylonjs/Shaders/circleOfConfusion.fragment";
  54430. /**
  54431. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54432. */
  54433. export class CircleOfConfusionPostProcess extends PostProcess {
  54434. /**
  54435. * 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.
  54436. */
  54437. lensSize: number;
  54438. /**
  54439. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54440. */
  54441. fStop: number;
  54442. /**
  54443. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54444. */
  54445. focusDistance: number;
  54446. /**
  54447. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54448. */
  54449. focalLength: number;
  54450. private _depthTexture;
  54451. /**
  54452. * Creates a new instance CircleOfConfusionPostProcess
  54453. * @param name The name of the effect.
  54454. * @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.
  54455. * @param options The required width/height ratio to downsize to before computing the render pass.
  54456. * @param camera The camera to apply the render pass to.
  54457. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54458. * @param engine The engine which the post process will be applied. (default: current engine)
  54459. * @param reusable If the post process can be reused on the same frame. (default: false)
  54460. * @param textureType Type of textures used when performing the post process. (default: 0)
  54461. * @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)
  54462. */
  54463. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54464. /**
  54465. * 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.
  54466. */
  54467. depthTexture: RenderTargetTexture;
  54468. }
  54469. }
  54470. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  54471. /** @hidden */
  54472. export var colorCorrectionPixelShader: {
  54473. name: string;
  54474. shader: string;
  54475. };
  54476. }
  54477. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  54478. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54479. import { Engine } from "babylonjs/Engines/engine";
  54480. import { Camera } from "babylonjs/Cameras/camera";
  54481. import "babylonjs/Shaders/colorCorrection.fragment";
  54482. /**
  54483. *
  54484. * This post-process allows the modification of rendered colors by using
  54485. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54486. *
  54487. * The object needs to be provided an url to a texture containing the color
  54488. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54489. * Use an image editing software to tweak the LUT to match your needs.
  54490. *
  54491. * For an example of a color LUT, see here:
  54492. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54493. * For explanations on color grading, see here:
  54494. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54495. *
  54496. */
  54497. export class ColorCorrectionPostProcess extends PostProcess {
  54498. private _colorTableTexture;
  54499. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54500. }
  54501. }
  54502. declare module "babylonjs/Shaders/convolution.fragment" {
  54503. /** @hidden */
  54504. export var convolutionPixelShader: {
  54505. name: string;
  54506. shader: string;
  54507. };
  54508. }
  54509. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  54510. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54511. import { Nullable } from "babylonjs/types";
  54512. import { Camera } from "babylonjs/Cameras/camera";
  54513. import { Engine } from "babylonjs/Engines/engine";
  54514. import "babylonjs/Shaders/convolution.fragment";
  54515. /**
  54516. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54517. * input texture to perform effects such as edge detection or sharpening
  54518. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54519. */
  54520. export class ConvolutionPostProcess extends PostProcess {
  54521. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54522. kernel: number[];
  54523. /**
  54524. * Creates a new instance ConvolutionPostProcess
  54525. * @param name The name of the effect.
  54526. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54527. * @param options The required width/height ratio to downsize to before computing the render pass.
  54528. * @param camera The camera to apply the render pass to.
  54529. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54530. * @param engine The engine which the post process will be applied. (default: current engine)
  54531. * @param reusable If the post process can be reused on the same frame. (default: false)
  54532. * @param textureType Type of textures used when performing the post process. (default: 0)
  54533. */
  54534. constructor(name: string,
  54535. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54536. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54537. /**
  54538. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54539. */
  54540. static EdgeDetect0Kernel: number[];
  54541. /**
  54542. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54543. */
  54544. static EdgeDetect1Kernel: number[];
  54545. /**
  54546. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54547. */
  54548. static EdgeDetect2Kernel: number[];
  54549. /**
  54550. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54551. */
  54552. static SharpenKernel: number[];
  54553. /**
  54554. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54555. */
  54556. static EmbossKernel: number[];
  54557. /**
  54558. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54559. */
  54560. static GaussianKernel: number[];
  54561. }
  54562. }
  54563. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  54564. import { Nullable } from "babylonjs/types";
  54565. import { Vector2 } from "babylonjs/Maths/math";
  54566. import { Camera } from "babylonjs/Cameras/camera";
  54567. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54568. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54569. import { Engine } from "babylonjs/Engines/engine";
  54570. import { Scene } from "babylonjs/scene";
  54571. /**
  54572. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54573. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54574. * based on samples that have a large difference in distance than the center pixel.
  54575. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54576. */
  54577. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54578. direction: Vector2;
  54579. /**
  54580. * Creates a new instance CircleOfConfusionPostProcess
  54581. * @param name The name of the effect.
  54582. * @param scene The scene the effect belongs to.
  54583. * @param direction The direction the blur should be applied.
  54584. * @param kernel The size of the kernel used to blur.
  54585. * @param options The required width/height ratio to downsize to before computing the render pass.
  54586. * @param camera The camera to apply the render pass to.
  54587. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54588. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54590. * @param engine The engine which the post process will be applied. (default: current engine)
  54591. * @param reusable If the post process can be reused on the same frame. (default: false)
  54592. * @param textureType Type of textures used when performing the post process. (default: 0)
  54593. * @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)
  54594. */
  54595. 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);
  54596. }
  54597. }
  54598. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  54599. /** @hidden */
  54600. export var depthOfFieldMergePixelShader: {
  54601. name: string;
  54602. shader: string;
  54603. };
  54604. }
  54605. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  54606. import { Nullable } from "babylonjs/types";
  54607. import { Camera } from "babylonjs/Cameras/camera";
  54608. import { Effect } from "babylonjs/Materials/effect";
  54609. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54610. import { Engine } from "babylonjs/Engines/engine";
  54611. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  54612. /**
  54613. * Options to be set when merging outputs from the default pipeline.
  54614. */
  54615. export class DepthOfFieldMergePostProcessOptions {
  54616. /**
  54617. * The original image to merge on top of
  54618. */
  54619. originalFromInput: PostProcess;
  54620. /**
  54621. * Parameters to perform the merge of the depth of field effect
  54622. */
  54623. depthOfField?: {
  54624. circleOfConfusion: PostProcess;
  54625. blurSteps: Array<PostProcess>;
  54626. };
  54627. /**
  54628. * Parameters to perform the merge of bloom effect
  54629. */
  54630. bloom?: {
  54631. blurred: PostProcess;
  54632. weight: number;
  54633. };
  54634. }
  54635. /**
  54636. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54637. */
  54638. export class DepthOfFieldMergePostProcess extends PostProcess {
  54639. private blurSteps;
  54640. /**
  54641. * Creates a new instance of DepthOfFieldMergePostProcess
  54642. * @param name The name of the effect.
  54643. * @param originalFromInput Post process which's input will be used for the merge.
  54644. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54645. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54646. * @param options The required width/height ratio to downsize to before computing the render pass.
  54647. * @param camera The camera to apply the render pass to.
  54648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54649. * @param engine The engine which the post process will be applied. (default: current engine)
  54650. * @param reusable If the post process can be reused on the same frame. (default: false)
  54651. * @param textureType Type of textures used when performing the post process. (default: 0)
  54652. * @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)
  54653. */
  54654. 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);
  54655. /**
  54656. * Updates the effect with the current post process compile time values and recompiles the shader.
  54657. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54658. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54659. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54660. * @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
  54661. * @param onCompiled Called when the shader has been compiled.
  54662. * @param onError Called if there is an error when compiling a shader.
  54663. */
  54664. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54665. }
  54666. }
  54667. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  54668. import { Nullable } from "babylonjs/types";
  54669. import { Camera } from "babylonjs/Cameras/camera";
  54670. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54671. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54672. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54673. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54674. import { Scene } from "babylonjs/scene";
  54675. /**
  54676. * Specifies the level of max blur that should be applied when using the depth of field effect
  54677. */
  54678. export enum DepthOfFieldEffectBlurLevel {
  54679. /**
  54680. * Subtle blur
  54681. */
  54682. Low = 0,
  54683. /**
  54684. * Medium blur
  54685. */
  54686. Medium = 1,
  54687. /**
  54688. * Large blur
  54689. */
  54690. High = 2
  54691. }
  54692. /**
  54693. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54694. */
  54695. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54696. private _circleOfConfusion;
  54697. /**
  54698. * @hidden Internal, blurs from high to low
  54699. */
  54700. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54701. private _depthOfFieldBlurY;
  54702. private _dofMerge;
  54703. /**
  54704. * @hidden Internal post processes in depth of field effect
  54705. */
  54706. _effects: Array<PostProcess>;
  54707. /**
  54708. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54709. */
  54710. focalLength: number;
  54711. /**
  54712. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54713. */
  54714. fStop: number;
  54715. /**
  54716. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54717. */
  54718. focusDistance: number;
  54719. /**
  54720. * 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.
  54721. */
  54722. lensSize: number;
  54723. /**
  54724. * Creates a new instance DepthOfFieldEffect
  54725. * @param scene The scene the effect belongs to.
  54726. * @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.
  54727. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54728. * @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)
  54729. */
  54730. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54731. /**
  54732. * 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.
  54733. */
  54734. depthTexture: RenderTargetTexture;
  54735. /**
  54736. * Disposes each of the internal effects for a given camera.
  54737. * @param camera The camera to dispose the effect on.
  54738. */
  54739. disposeEffects(camera: Camera): void;
  54740. /**
  54741. * @hidden Internal
  54742. */
  54743. _updateEffects(): void;
  54744. /**
  54745. * Internal
  54746. * @returns if all the contained post processes are ready.
  54747. * @hidden
  54748. */
  54749. _isReady(): boolean;
  54750. }
  54751. }
  54752. declare module "babylonjs/Shaders/displayPass.fragment" {
  54753. /** @hidden */
  54754. export var displayPassPixelShader: {
  54755. name: string;
  54756. shader: string;
  54757. };
  54758. }
  54759. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  54760. import { Nullable } from "babylonjs/types";
  54761. import { Camera } from "babylonjs/Cameras/camera";
  54762. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54763. import { Engine } from "babylonjs/Engines/engine";
  54764. import "babylonjs/Shaders/displayPass.fragment";
  54765. /**
  54766. * DisplayPassPostProcess which produces an output the same as it's input
  54767. */
  54768. export class DisplayPassPostProcess extends PostProcess {
  54769. /**
  54770. * Creates the DisplayPassPostProcess
  54771. * @param name The name of the effect.
  54772. * @param options The required width/height ratio to downsize to before computing the render pass.
  54773. * @param camera The camera to apply the render pass to.
  54774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54775. * @param engine The engine which the post process will be applied. (default: current engine)
  54776. * @param reusable If the post process can be reused on the same frame. (default: false)
  54777. */
  54778. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54779. }
  54780. }
  54781. declare module "babylonjs/Shaders/filter.fragment" {
  54782. /** @hidden */
  54783. export var filterPixelShader: {
  54784. name: string;
  54785. shader: string;
  54786. };
  54787. }
  54788. declare module "babylonjs/PostProcesses/filterPostProcess" {
  54789. import { Nullable } from "babylonjs/types";
  54790. import { Matrix } from "babylonjs/Maths/math";
  54791. import { Camera } from "babylonjs/Cameras/camera";
  54792. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54793. import { Engine } from "babylonjs/Engines/engine";
  54794. import "babylonjs/Shaders/filter.fragment";
  54795. /**
  54796. * Applies a kernel filter to the image
  54797. */
  54798. export class FilterPostProcess extends PostProcess {
  54799. /** The matrix to be applied to the image */
  54800. kernelMatrix: Matrix;
  54801. /**
  54802. *
  54803. * @param name The name of the effect.
  54804. * @param kernelMatrix The matrix to be applied to the image
  54805. * @param options The required width/height ratio to downsize to before computing the render pass.
  54806. * @param camera The camera to apply the render pass to.
  54807. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54808. * @param engine The engine which the post process will be applied. (default: current engine)
  54809. * @param reusable If the post process can be reused on the same frame. (default: false)
  54810. */
  54811. constructor(name: string,
  54812. /** The matrix to be applied to the image */
  54813. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54814. }
  54815. }
  54816. declare module "babylonjs/Shaders/fxaa.fragment" {
  54817. /** @hidden */
  54818. export var fxaaPixelShader: {
  54819. name: string;
  54820. shader: string;
  54821. };
  54822. }
  54823. declare module "babylonjs/Shaders/fxaa.vertex" {
  54824. /** @hidden */
  54825. export var fxaaVertexShader: {
  54826. name: string;
  54827. shader: string;
  54828. };
  54829. }
  54830. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  54831. import { Nullable } from "babylonjs/types";
  54832. import { Camera } from "babylonjs/Cameras/camera";
  54833. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54834. import { Engine } from "babylonjs/Engines/engine";
  54835. import "babylonjs/Shaders/fxaa.fragment";
  54836. import "babylonjs/Shaders/fxaa.vertex";
  54837. /**
  54838. * Fxaa post process
  54839. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54840. */
  54841. export class FxaaPostProcess extends PostProcess {
  54842. /** @hidden */
  54843. texelWidth: number;
  54844. /** @hidden */
  54845. texelHeight: number;
  54846. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54847. private _getDefines;
  54848. }
  54849. }
  54850. declare module "babylonjs/Shaders/grain.fragment" {
  54851. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54852. /** @hidden */
  54853. export var grainPixelShader: {
  54854. name: string;
  54855. shader: string;
  54856. };
  54857. }
  54858. declare module "babylonjs/PostProcesses/grainPostProcess" {
  54859. import { Nullable } from "babylonjs/types";
  54860. import { Camera } from "babylonjs/Cameras/camera";
  54861. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54862. import { Engine } from "babylonjs/Engines/engine";
  54863. import "babylonjs/Shaders/grain.fragment";
  54864. /**
  54865. * The GrainPostProcess adds noise to the image at mid luminance levels
  54866. */
  54867. export class GrainPostProcess extends PostProcess {
  54868. /**
  54869. * The intensity of the grain added (default: 30)
  54870. */
  54871. intensity: number;
  54872. /**
  54873. * If the grain should be randomized on every frame
  54874. */
  54875. animated: boolean;
  54876. /**
  54877. * Creates a new instance of @see GrainPostProcess
  54878. * @param name The name of the effect.
  54879. * @param options The required width/height ratio to downsize to before computing the render pass.
  54880. * @param camera The camera to apply the render pass to.
  54881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54882. * @param engine The engine which the post process will be applied. (default: current engine)
  54883. * @param reusable If the post process can be reused on the same frame. (default: false)
  54884. * @param textureType Type of textures used when performing the post process. (default: 0)
  54885. * @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)
  54886. */
  54887. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54888. }
  54889. }
  54890. declare module "babylonjs/Shaders/highlights.fragment" {
  54891. /** @hidden */
  54892. export var highlightsPixelShader: {
  54893. name: string;
  54894. shader: string;
  54895. };
  54896. }
  54897. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54898. import { Nullable } from "babylonjs/types";
  54899. import { Camera } from "babylonjs/Cameras/camera";
  54900. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54901. import { Engine } from "babylonjs/Engines/engine";
  54902. import "babylonjs/Shaders/highlights.fragment";
  54903. /**
  54904. * Extracts highlights from the image
  54905. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54906. */
  54907. export class HighlightsPostProcess extends PostProcess {
  54908. /**
  54909. * Extracts highlights from the image
  54910. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54911. * @param name The name of the effect.
  54912. * @param options The required width/height ratio to downsize to before computing the render pass.
  54913. * @param camera The camera to apply the render pass to.
  54914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54915. * @param engine The engine which the post process will be applied. (default: current engine)
  54916. * @param reusable If the post process can be reused on the same frame. (default: false)
  54917. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54918. */
  54919. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54920. }
  54921. }
  54922. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54923. /** @hidden */
  54924. export var mrtFragmentDeclaration: {
  54925. name: string;
  54926. shader: string;
  54927. };
  54928. }
  54929. declare module "babylonjs/Shaders/geometry.fragment" {
  54930. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54931. /** @hidden */
  54932. export var geometryPixelShader: {
  54933. name: string;
  54934. shader: string;
  54935. };
  54936. }
  54937. declare module "babylonjs/Shaders/geometry.vertex" {
  54938. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54939. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54940. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54941. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54942. /** @hidden */
  54943. export var geometryVertexShader: {
  54944. name: string;
  54945. shader: string;
  54946. };
  54947. }
  54948. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  54949. import { Matrix } from "babylonjs/Maths/math";
  54950. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54951. import { Mesh } from "babylonjs/Meshes/mesh";
  54952. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  54953. import { Effect } from "babylonjs/Materials/effect";
  54954. import { Scene } from "babylonjs/scene";
  54955. import "babylonjs/Shaders/geometry.fragment";
  54956. import "babylonjs/Shaders/geometry.vertex";
  54957. /**
  54958. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54959. */
  54960. export class GeometryBufferRenderer {
  54961. /**
  54962. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54963. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54964. */
  54965. static readonly POSITION_TEXTURE_TYPE: number;
  54966. /**
  54967. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54968. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54969. */
  54970. static readonly VELOCITY_TEXTURE_TYPE: number;
  54971. /**
  54972. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54973. * in order to compute objects velocities when enableVelocity is set to "true"
  54974. * @hidden
  54975. */
  54976. _previousTransformationMatrices: {
  54977. [index: number]: Matrix;
  54978. };
  54979. private _scene;
  54980. private _multiRenderTarget;
  54981. private _ratio;
  54982. private _enablePosition;
  54983. private _enableVelocity;
  54984. private _positionIndex;
  54985. private _velocityIndex;
  54986. protected _effect: Effect;
  54987. protected _cachedDefines: string;
  54988. /**
  54989. * Set the render list (meshes to be rendered) used in the G buffer.
  54990. */
  54991. renderList: Mesh[];
  54992. /**
  54993. * Gets wether or not G buffer are supported by the running hardware.
  54994. * This requires draw buffer supports
  54995. */
  54996. readonly isSupported: boolean;
  54997. /**
  54998. * Returns the index of the given texture type in the G-Buffer textures array
  54999. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55000. * @returns the index of the given texture type in the G-Buffer textures array
  55001. */
  55002. getTextureIndex(textureType: number): number;
  55003. /**
  55004. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55005. */
  55006. /**
  55007. * Sets whether or not objects positions are enabled for the G buffer.
  55008. */
  55009. enablePosition: boolean;
  55010. /**
  55011. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55012. */
  55013. /**
  55014. * Sets wether or not objects velocities are enabled for the G buffer.
  55015. */
  55016. enableVelocity: boolean;
  55017. /**
  55018. * Gets the scene associated with the buffer.
  55019. */
  55020. readonly scene: Scene;
  55021. /**
  55022. * Gets the ratio used by the buffer during its creation.
  55023. * How big is the buffer related to the main canvas.
  55024. */
  55025. readonly ratio: number;
  55026. /** @hidden */
  55027. static _SceneComponentInitialization: (scene: Scene) => void;
  55028. /**
  55029. * Creates a new G Buffer for the scene
  55030. * @param scene The scene the buffer belongs to
  55031. * @param ratio How big is the buffer related to the main canvas.
  55032. */
  55033. constructor(scene: Scene, ratio?: number);
  55034. /**
  55035. * Checks wether everything is ready to render a submesh to the G buffer.
  55036. * @param subMesh the submesh to check readiness for
  55037. * @param useInstances is the mesh drawn using instance or not
  55038. * @returns true if ready otherwise false
  55039. */
  55040. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55041. /**
  55042. * Gets the current underlying G Buffer.
  55043. * @returns the buffer
  55044. */
  55045. getGBuffer(): MultiRenderTarget;
  55046. /**
  55047. * Gets the number of samples used to render the buffer (anti aliasing).
  55048. */
  55049. /**
  55050. * Sets the number of samples used to render the buffer (anti aliasing).
  55051. */
  55052. samples: number;
  55053. /**
  55054. * Disposes the renderer and frees up associated resources.
  55055. */
  55056. dispose(): void;
  55057. protected _createRenderTargets(): void;
  55058. }
  55059. }
  55060. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55061. import { Nullable } from "babylonjs/types";
  55062. import { Scene } from "babylonjs/scene";
  55063. import { ISceneComponent } from "babylonjs/sceneComponent";
  55064. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55065. module "babylonjs/scene" {
  55066. interface Scene {
  55067. /** @hidden (Backing field) */
  55068. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55069. /**
  55070. * Gets or Sets the current geometry buffer associated to the scene.
  55071. */
  55072. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55073. /**
  55074. * Enables a GeometryBufferRender and associates it with the scene
  55075. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55076. * @returns the GeometryBufferRenderer
  55077. */
  55078. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55079. /**
  55080. * Disables the GeometryBufferRender associated with the scene
  55081. */
  55082. disableGeometryBufferRenderer(): void;
  55083. }
  55084. }
  55085. /**
  55086. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55087. * in several rendering techniques.
  55088. */
  55089. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55090. /**
  55091. * The component name helpful to identify the component in the list of scene components.
  55092. */
  55093. readonly name: string;
  55094. /**
  55095. * The scene the component belongs to.
  55096. */
  55097. scene: Scene;
  55098. /**
  55099. * Creates a new instance of the component for the given scene
  55100. * @param scene Defines the scene to register the component in
  55101. */
  55102. constructor(scene: Scene);
  55103. /**
  55104. * Registers the component in a given scene
  55105. */
  55106. register(): void;
  55107. /**
  55108. * Rebuilds the elements related to this component in case of
  55109. * context lost for instance.
  55110. */
  55111. rebuild(): void;
  55112. /**
  55113. * Disposes the component and the associated ressources
  55114. */
  55115. dispose(): void;
  55116. private _gatherRenderTargets;
  55117. }
  55118. }
  55119. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55120. /** @hidden */
  55121. export var motionBlurPixelShader: {
  55122. name: string;
  55123. shader: string;
  55124. };
  55125. }
  55126. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55127. import { Nullable } from "babylonjs/types";
  55128. import { Camera } from "babylonjs/Cameras/camera";
  55129. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55130. import { Scene } from "babylonjs/scene";
  55131. import "babylonjs/Animations/animatable";
  55132. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55133. import "babylonjs/Shaders/motionBlur.fragment";
  55134. import { Engine } from "babylonjs/Engines/engine";
  55135. /**
  55136. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55137. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55138. * As an example, all you have to do is to create the post-process:
  55139. * var mb = new BABYLON.MotionBlurPostProcess(
  55140. * 'mb', // The name of the effect.
  55141. * scene, // The scene containing the objects to blur according to their velocity.
  55142. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55143. * camera // The camera to apply the render pass to.
  55144. * );
  55145. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55146. */
  55147. export class MotionBlurPostProcess extends PostProcess {
  55148. /**
  55149. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55150. */
  55151. motionStrength: number;
  55152. /**
  55153. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55154. */
  55155. /**
  55156. * Sets the number of iterations to be used for motion blur quality
  55157. */
  55158. motionBlurSamples: number;
  55159. private _motionBlurSamples;
  55160. private _geometryBufferRenderer;
  55161. /**
  55162. * Creates a new instance MotionBlurPostProcess
  55163. * @param name The name of the effect.
  55164. * @param scene The scene containing the objects to blur according to their velocity.
  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 samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55168. * @param engine The engine which the post process will be applied. (default: current engine)
  55169. * @param reusable If the post process can be reused on the same frame. (default: false)
  55170. * @param textureType Type of textures used when performing the post process. (default: 0)
  55171. * @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)
  55172. */
  55173. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55174. /**
  55175. * Disposes the post process.
  55176. * @param camera The camera to dispose the post process on.
  55177. */
  55178. dispose(camera?: Camera): void;
  55179. }
  55180. }
  55181. declare module "babylonjs/Shaders/refraction.fragment" {
  55182. /** @hidden */
  55183. export var refractionPixelShader: {
  55184. name: string;
  55185. shader: string;
  55186. };
  55187. }
  55188. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55189. import { Color3 } from "babylonjs/Maths/math";
  55190. import { Camera } from "babylonjs/Cameras/camera";
  55191. import { Texture } from "babylonjs/Materials/Textures/texture";
  55192. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55193. import { Engine } from "babylonjs/Engines/engine";
  55194. import "babylonjs/Shaders/refraction.fragment";
  55195. /**
  55196. * Post process which applies a refractin texture
  55197. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55198. */
  55199. export class RefractionPostProcess extends PostProcess {
  55200. /** the base color of the refraction (used to taint the rendering) */
  55201. color: Color3;
  55202. /** simulated refraction depth */
  55203. depth: number;
  55204. /** the coefficient of the base color (0 to remove base color tainting) */
  55205. colorLevel: number;
  55206. private _refTexture;
  55207. private _ownRefractionTexture;
  55208. /**
  55209. * Gets or sets the refraction texture
  55210. * Please note that you are responsible for disposing the texture if you set it manually
  55211. */
  55212. refractionTexture: Texture;
  55213. /**
  55214. * Initializes the RefractionPostProcess
  55215. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55216. * @param name The name of the effect.
  55217. * @param refractionTextureUrl Url of the refraction texture to use
  55218. * @param color the base color of the refraction (used to taint the rendering)
  55219. * @param depth simulated refraction depth
  55220. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55221. * @param camera The camera to apply the render pass to.
  55222. * @param options The required width/height ratio to downsize to before computing the render pass.
  55223. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55224. * @param engine The engine which the post process will be applied. (default: current engine)
  55225. * @param reusable If the post process can be reused on the same frame. (default: false)
  55226. */
  55227. constructor(name: string, refractionTextureUrl: string,
  55228. /** the base color of the refraction (used to taint the rendering) */
  55229. color: Color3,
  55230. /** simulated refraction depth */
  55231. depth: number,
  55232. /** the coefficient of the base color (0 to remove base color tainting) */
  55233. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55234. /**
  55235. * Disposes of the post process
  55236. * @param camera Camera to dispose post process on
  55237. */
  55238. dispose(camera: Camera): void;
  55239. }
  55240. }
  55241. declare module "babylonjs/Shaders/sharpen.fragment" {
  55242. /** @hidden */
  55243. export var sharpenPixelShader: {
  55244. name: string;
  55245. shader: string;
  55246. };
  55247. }
  55248. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55249. import { Nullable } from "babylonjs/types";
  55250. import { Camera } from "babylonjs/Cameras/camera";
  55251. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55252. import "babylonjs/Shaders/sharpen.fragment";
  55253. import { Engine } from "babylonjs/Engines/engine";
  55254. /**
  55255. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55256. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55257. */
  55258. export class SharpenPostProcess extends PostProcess {
  55259. /**
  55260. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55261. */
  55262. colorAmount: number;
  55263. /**
  55264. * How much sharpness should be applied (default: 0.3)
  55265. */
  55266. edgeAmount: number;
  55267. /**
  55268. * Creates a new instance ConvolutionPostProcess
  55269. * @param name The name of the effect.
  55270. * @param options The required width/height ratio to downsize to before computing the render pass.
  55271. * @param camera The camera to apply the render pass to.
  55272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55273. * @param engine The engine which the post process will be applied. (default: current engine)
  55274. * @param reusable If the post process can be reused on the same frame. (default: false)
  55275. * @param textureType Type of textures used when performing the post process. (default: 0)
  55276. * @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)
  55277. */
  55278. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55279. }
  55280. }
  55281. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55282. import { Nullable } from "babylonjs/types";
  55283. import { Camera } from "babylonjs/Cameras/camera";
  55284. import { Engine } from "babylonjs/Engines/engine";
  55285. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55286. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55287. /**
  55288. * PostProcessRenderPipeline
  55289. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55290. */
  55291. export class PostProcessRenderPipeline {
  55292. private engine;
  55293. private _renderEffects;
  55294. private _renderEffectsForIsolatedPass;
  55295. /**
  55296. * List of inspectable custom properties (used by the Inspector)
  55297. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55298. */
  55299. inspectableCustomProperties: IInspectable[];
  55300. /**
  55301. * @hidden
  55302. */
  55303. protected _cameras: Camera[];
  55304. /** @hidden */
  55305. _name: string;
  55306. /**
  55307. * Gets pipeline name
  55308. */
  55309. readonly name: string;
  55310. /**
  55311. * Initializes a PostProcessRenderPipeline
  55312. * @param engine engine to add the pipeline to
  55313. * @param name name of the pipeline
  55314. */
  55315. constructor(engine: Engine, name: string);
  55316. /**
  55317. * Gets the class name
  55318. * @returns "PostProcessRenderPipeline"
  55319. */
  55320. getClassName(): string;
  55321. /**
  55322. * If all the render effects in the pipeline are supported
  55323. */
  55324. readonly isSupported: boolean;
  55325. /**
  55326. * Adds an effect to the pipeline
  55327. * @param renderEffect the effect to add
  55328. */
  55329. addEffect(renderEffect: PostProcessRenderEffect): void;
  55330. /** @hidden */
  55331. _rebuild(): void;
  55332. /** @hidden */
  55333. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55334. /** @hidden */
  55335. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55336. /** @hidden */
  55337. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55338. /** @hidden */
  55339. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55340. /** @hidden */
  55341. _attachCameras(cameras: Camera, unique: boolean): void;
  55342. /** @hidden */
  55343. _attachCameras(cameras: Camera[], unique: boolean): void;
  55344. /** @hidden */
  55345. _detachCameras(cameras: Camera): void;
  55346. /** @hidden */
  55347. _detachCameras(cameras: Nullable<Camera[]>): void;
  55348. /** @hidden */
  55349. _update(): void;
  55350. /** @hidden */
  55351. _reset(): void;
  55352. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55353. /**
  55354. * Disposes of the pipeline
  55355. */
  55356. dispose(): void;
  55357. }
  55358. }
  55359. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55360. import { Camera } from "babylonjs/Cameras/camera";
  55361. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55362. /**
  55363. * PostProcessRenderPipelineManager class
  55364. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55365. */
  55366. export class PostProcessRenderPipelineManager {
  55367. private _renderPipelines;
  55368. /**
  55369. * Initializes a PostProcessRenderPipelineManager
  55370. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55371. */
  55372. constructor();
  55373. /**
  55374. * Gets the list of supported render pipelines
  55375. */
  55376. readonly supportedPipelines: PostProcessRenderPipeline[];
  55377. /**
  55378. * Adds a pipeline to the manager
  55379. * @param renderPipeline The pipeline to add
  55380. */
  55381. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55382. /**
  55383. * Attaches a camera to the pipeline
  55384. * @param renderPipelineName The name of the pipeline to attach to
  55385. * @param cameras the camera to attach
  55386. * @param unique if the camera can be attached multiple times to the pipeline
  55387. */
  55388. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55389. /**
  55390. * Detaches a camera from the pipeline
  55391. * @param renderPipelineName The name of the pipeline to detach from
  55392. * @param cameras the camera to detach
  55393. */
  55394. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55395. /**
  55396. * Enables an effect by name on a pipeline
  55397. * @param renderPipelineName the name of the pipeline to enable the effect in
  55398. * @param renderEffectName the name of the effect to enable
  55399. * @param cameras the cameras that the effect should be enabled on
  55400. */
  55401. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55402. /**
  55403. * Disables an effect by name on a pipeline
  55404. * @param renderPipelineName the name of the pipeline to disable the effect in
  55405. * @param renderEffectName the name of the effect to disable
  55406. * @param cameras the cameras that the effect should be disabled on
  55407. */
  55408. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55409. /**
  55410. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55411. */
  55412. update(): void;
  55413. /** @hidden */
  55414. _rebuild(): void;
  55415. /**
  55416. * Disposes of the manager and pipelines
  55417. */
  55418. dispose(): void;
  55419. }
  55420. }
  55421. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  55422. import { ISceneComponent } from "babylonjs/sceneComponent";
  55423. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55424. import { Scene } from "babylonjs/scene";
  55425. module "babylonjs/scene" {
  55426. interface Scene {
  55427. /** @hidden (Backing field) */
  55428. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55429. /**
  55430. * Gets the postprocess render pipeline manager
  55431. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55432. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55433. */
  55434. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55435. }
  55436. }
  55437. /**
  55438. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55439. */
  55440. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55441. /**
  55442. * The component name helpfull to identify the component in the list of scene components.
  55443. */
  55444. readonly name: string;
  55445. /**
  55446. * The scene the component belongs to.
  55447. */
  55448. scene: Scene;
  55449. /**
  55450. * Creates a new instance of the component for the given scene
  55451. * @param scene Defines the scene to register the component in
  55452. */
  55453. constructor(scene: Scene);
  55454. /**
  55455. * Registers the component in a given scene
  55456. */
  55457. register(): void;
  55458. /**
  55459. * Rebuilds the elements related to this component in case of
  55460. * context lost for instance.
  55461. */
  55462. rebuild(): void;
  55463. /**
  55464. * Disposes the component and the associated ressources
  55465. */
  55466. dispose(): void;
  55467. private _gatherRenderTargets;
  55468. }
  55469. }
  55470. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  55471. import { IAnimatable } from "babylonjs/Misc/tools";
  55472. import { Camera } from "babylonjs/Cameras/camera";
  55473. import { IDisposable } from "babylonjs/scene";
  55474. import { Scene } from "babylonjs/scene";
  55475. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  55476. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55477. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55478. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  55479. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55480. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55481. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  55482. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55483. import { Animation } from "babylonjs/Animations/animation";
  55484. /**
  55485. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55486. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55487. */
  55488. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55489. private _scene;
  55490. private _camerasToBeAttached;
  55491. /**
  55492. * ID of the sharpen post process,
  55493. */
  55494. private readonly SharpenPostProcessId;
  55495. /**
  55496. * @ignore
  55497. * ID of the image processing post process;
  55498. */
  55499. readonly ImageProcessingPostProcessId: string;
  55500. /**
  55501. * @ignore
  55502. * ID of the Fast Approximate Anti-Aliasing post process;
  55503. */
  55504. readonly FxaaPostProcessId: string;
  55505. /**
  55506. * ID of the chromatic aberration post process,
  55507. */
  55508. private readonly ChromaticAberrationPostProcessId;
  55509. /**
  55510. * ID of the grain post process
  55511. */
  55512. private readonly GrainPostProcessId;
  55513. /**
  55514. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55515. */
  55516. sharpen: SharpenPostProcess;
  55517. private _sharpenEffect;
  55518. private bloom;
  55519. /**
  55520. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55521. */
  55522. depthOfField: DepthOfFieldEffect;
  55523. /**
  55524. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55525. */
  55526. fxaa: FxaaPostProcess;
  55527. /**
  55528. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55529. */
  55530. imageProcessing: ImageProcessingPostProcess;
  55531. /**
  55532. * Chromatic aberration post process which will shift rgb colors in the image
  55533. */
  55534. chromaticAberration: ChromaticAberrationPostProcess;
  55535. private _chromaticAberrationEffect;
  55536. /**
  55537. * Grain post process which add noise to the image
  55538. */
  55539. grain: GrainPostProcess;
  55540. private _grainEffect;
  55541. /**
  55542. * Glow post process which adds a glow to emissive areas of the image
  55543. */
  55544. private _glowLayer;
  55545. /**
  55546. * Animations which can be used to tweak settings over a period of time
  55547. */
  55548. animations: Animation[];
  55549. private _imageProcessingConfigurationObserver;
  55550. private _sharpenEnabled;
  55551. private _bloomEnabled;
  55552. private _depthOfFieldEnabled;
  55553. private _depthOfFieldBlurLevel;
  55554. private _fxaaEnabled;
  55555. private _imageProcessingEnabled;
  55556. private _defaultPipelineTextureType;
  55557. private _bloomScale;
  55558. private _chromaticAberrationEnabled;
  55559. private _grainEnabled;
  55560. private _buildAllowed;
  55561. /**
  55562. * Gets active scene
  55563. */
  55564. readonly scene: Scene;
  55565. /**
  55566. * Enable or disable the sharpen process from the pipeline
  55567. */
  55568. sharpenEnabled: boolean;
  55569. private _resizeObserver;
  55570. private _hardwareScaleLevel;
  55571. private _bloomKernel;
  55572. /**
  55573. * Specifies the size of the bloom blur kernel, relative to the final output size
  55574. */
  55575. bloomKernel: number;
  55576. /**
  55577. * Specifies the weight of the bloom in the final rendering
  55578. */
  55579. private _bloomWeight;
  55580. /**
  55581. * Specifies the luma threshold for the area that will be blurred by the bloom
  55582. */
  55583. private _bloomThreshold;
  55584. private _hdr;
  55585. /**
  55586. * The strength of the bloom.
  55587. */
  55588. bloomWeight: number;
  55589. /**
  55590. * The strength of the bloom.
  55591. */
  55592. bloomThreshold: number;
  55593. /**
  55594. * The scale of the bloom, lower value will provide better performance.
  55595. */
  55596. bloomScale: number;
  55597. /**
  55598. * Enable or disable the bloom from the pipeline
  55599. */
  55600. bloomEnabled: boolean;
  55601. private _rebuildBloom;
  55602. /**
  55603. * If the depth of field is enabled.
  55604. */
  55605. depthOfFieldEnabled: boolean;
  55606. /**
  55607. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55608. */
  55609. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55610. /**
  55611. * If the anti aliasing is enabled.
  55612. */
  55613. fxaaEnabled: boolean;
  55614. private _samples;
  55615. /**
  55616. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55617. */
  55618. samples: number;
  55619. /**
  55620. * If image processing is enabled.
  55621. */
  55622. imageProcessingEnabled: boolean;
  55623. /**
  55624. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55625. */
  55626. glowLayerEnabled: boolean;
  55627. /**
  55628. * Enable or disable the chromaticAberration process from the pipeline
  55629. */
  55630. chromaticAberrationEnabled: boolean;
  55631. /**
  55632. * Enable or disable the grain process from the pipeline
  55633. */
  55634. grainEnabled: boolean;
  55635. /**
  55636. * @constructor
  55637. * @param name - The rendering pipeline name (default: "")
  55638. * @param hdr - If high dynamic range textures should be used (default: true)
  55639. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55640. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55641. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55642. */
  55643. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55644. /**
  55645. * Get the class name
  55646. * @returns "DefaultRenderingPipeline"
  55647. */
  55648. getClassName(): string;
  55649. /**
  55650. * Force the compilation of the entire pipeline.
  55651. */
  55652. prepare(): void;
  55653. private _hasCleared;
  55654. private _prevPostProcess;
  55655. private _prevPrevPostProcess;
  55656. private _setAutoClearAndTextureSharing;
  55657. private _depthOfFieldSceneObserver;
  55658. private _buildPipeline;
  55659. private _disposePostProcesses;
  55660. /**
  55661. * Adds a camera to the pipeline
  55662. * @param camera the camera to be added
  55663. */
  55664. addCamera(camera: Camera): void;
  55665. /**
  55666. * Removes a camera from the pipeline
  55667. * @param camera the camera to remove
  55668. */
  55669. removeCamera(camera: Camera): void;
  55670. /**
  55671. * Dispose of the pipeline and stop all post processes
  55672. */
  55673. dispose(): void;
  55674. /**
  55675. * Serialize the rendering pipeline (Used when exporting)
  55676. * @returns the serialized object
  55677. */
  55678. serialize(): any;
  55679. /**
  55680. * Parse the serialized pipeline
  55681. * @param source Source pipeline.
  55682. * @param scene The scene to load the pipeline to.
  55683. * @param rootUrl The URL of the serialized pipeline.
  55684. * @returns An instantiated pipeline from the serialized object.
  55685. */
  55686. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55687. }
  55688. }
  55689. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  55690. /** @hidden */
  55691. export var lensHighlightsPixelShader: {
  55692. name: string;
  55693. shader: string;
  55694. };
  55695. }
  55696. declare module "babylonjs/Shaders/depthOfField.fragment" {
  55697. /** @hidden */
  55698. export var depthOfFieldPixelShader: {
  55699. name: string;
  55700. shader: string;
  55701. };
  55702. }
  55703. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  55704. import { Camera } from "babylonjs/Cameras/camera";
  55705. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55706. import { Scene } from "babylonjs/scene";
  55707. import "babylonjs/Shaders/chromaticAberration.fragment";
  55708. import "babylonjs/Shaders/lensHighlights.fragment";
  55709. import "babylonjs/Shaders/depthOfField.fragment";
  55710. /**
  55711. * BABYLON.JS Chromatic Aberration GLSL Shader
  55712. * Author: Olivier Guyot
  55713. * Separates very slightly R, G and B colors on the edges of the screen
  55714. * Inspired by Francois Tarlier & Martins Upitis
  55715. */
  55716. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55717. /**
  55718. * @ignore
  55719. * The chromatic aberration PostProcess id in the pipeline
  55720. */
  55721. LensChromaticAberrationEffect: string;
  55722. /**
  55723. * @ignore
  55724. * The highlights enhancing PostProcess id in the pipeline
  55725. */
  55726. HighlightsEnhancingEffect: string;
  55727. /**
  55728. * @ignore
  55729. * The depth-of-field PostProcess id in the pipeline
  55730. */
  55731. LensDepthOfFieldEffect: string;
  55732. private _scene;
  55733. private _depthTexture;
  55734. private _grainTexture;
  55735. private _chromaticAberrationPostProcess;
  55736. private _highlightsPostProcess;
  55737. private _depthOfFieldPostProcess;
  55738. private _edgeBlur;
  55739. private _grainAmount;
  55740. private _chromaticAberration;
  55741. private _distortion;
  55742. private _highlightsGain;
  55743. private _highlightsThreshold;
  55744. private _dofDistance;
  55745. private _dofAperture;
  55746. private _dofDarken;
  55747. private _dofPentagon;
  55748. private _blurNoise;
  55749. /**
  55750. * @constructor
  55751. *
  55752. * Effect parameters are as follow:
  55753. * {
  55754. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55755. * edge_blur: number; // from 0 to x (1 for realism)
  55756. * distortion: number; // from 0 to x (1 for realism)
  55757. * grain_amount: number; // from 0 to 1
  55758. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55759. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55760. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55761. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55762. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55763. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55764. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55765. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55766. * }
  55767. * Note: if an effect parameter is unset, effect is disabled
  55768. *
  55769. * @param name The rendering pipeline name
  55770. * @param parameters - An object containing all parameters (see above)
  55771. * @param scene The scene linked to this pipeline
  55772. * @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)
  55773. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55774. */
  55775. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55776. /**
  55777. * Get the class name
  55778. * @returns "LensRenderingPipeline"
  55779. */
  55780. getClassName(): string;
  55781. /**
  55782. * Gets associated scene
  55783. */
  55784. readonly scene: Scene;
  55785. /**
  55786. * Gets or sets the edge blur
  55787. */
  55788. edgeBlur: number;
  55789. /**
  55790. * Gets or sets the grain amount
  55791. */
  55792. grainAmount: number;
  55793. /**
  55794. * Gets or sets the chromatic aberration amount
  55795. */
  55796. chromaticAberration: number;
  55797. /**
  55798. * Gets or sets the depth of field aperture
  55799. */
  55800. dofAperture: number;
  55801. /**
  55802. * Gets or sets the edge distortion
  55803. */
  55804. edgeDistortion: number;
  55805. /**
  55806. * Gets or sets the depth of field distortion
  55807. */
  55808. dofDistortion: number;
  55809. /**
  55810. * Gets or sets the darken out of focus amount
  55811. */
  55812. darkenOutOfFocus: number;
  55813. /**
  55814. * Gets or sets a boolean indicating if blur noise is enabled
  55815. */
  55816. blurNoise: boolean;
  55817. /**
  55818. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55819. */
  55820. pentagonBokeh: boolean;
  55821. /**
  55822. * Gets or sets the highlight grain amount
  55823. */
  55824. highlightsGain: number;
  55825. /**
  55826. * Gets or sets the highlight threshold
  55827. */
  55828. highlightsThreshold: number;
  55829. /**
  55830. * Sets the amount of blur at the edges
  55831. * @param amount blur amount
  55832. */
  55833. setEdgeBlur(amount: number): void;
  55834. /**
  55835. * Sets edge blur to 0
  55836. */
  55837. disableEdgeBlur(): void;
  55838. /**
  55839. * Sets the amout of grain
  55840. * @param amount Amount of grain
  55841. */
  55842. setGrainAmount(amount: number): void;
  55843. /**
  55844. * Set grain amount to 0
  55845. */
  55846. disableGrain(): void;
  55847. /**
  55848. * Sets the chromatic aberration amount
  55849. * @param amount amount of chromatic aberration
  55850. */
  55851. setChromaticAberration(amount: number): void;
  55852. /**
  55853. * Sets chromatic aberration amount to 0
  55854. */
  55855. disableChromaticAberration(): void;
  55856. /**
  55857. * Sets the EdgeDistortion amount
  55858. * @param amount amount of EdgeDistortion
  55859. */
  55860. setEdgeDistortion(amount: number): void;
  55861. /**
  55862. * Sets edge distortion to 0
  55863. */
  55864. disableEdgeDistortion(): void;
  55865. /**
  55866. * Sets the FocusDistance amount
  55867. * @param amount amount of FocusDistance
  55868. */
  55869. setFocusDistance(amount: number): void;
  55870. /**
  55871. * Disables depth of field
  55872. */
  55873. disableDepthOfField(): void;
  55874. /**
  55875. * Sets the Aperture amount
  55876. * @param amount amount of Aperture
  55877. */
  55878. setAperture(amount: number): void;
  55879. /**
  55880. * Sets the DarkenOutOfFocus amount
  55881. * @param amount amount of DarkenOutOfFocus
  55882. */
  55883. setDarkenOutOfFocus(amount: number): void;
  55884. private _pentagonBokehIsEnabled;
  55885. /**
  55886. * Creates a pentagon bokeh effect
  55887. */
  55888. enablePentagonBokeh(): void;
  55889. /**
  55890. * Disables the pentagon bokeh effect
  55891. */
  55892. disablePentagonBokeh(): void;
  55893. /**
  55894. * Enables noise blur
  55895. */
  55896. enableNoiseBlur(): void;
  55897. /**
  55898. * Disables noise blur
  55899. */
  55900. disableNoiseBlur(): void;
  55901. /**
  55902. * Sets the HighlightsGain amount
  55903. * @param amount amount of HighlightsGain
  55904. */
  55905. setHighlightsGain(amount: number): void;
  55906. /**
  55907. * Sets the HighlightsThreshold amount
  55908. * @param amount amount of HighlightsThreshold
  55909. */
  55910. setHighlightsThreshold(amount: number): void;
  55911. /**
  55912. * Disables highlights
  55913. */
  55914. disableHighlights(): void;
  55915. /**
  55916. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55917. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55918. */
  55919. dispose(disableDepthRender?: boolean): void;
  55920. private _createChromaticAberrationPostProcess;
  55921. private _createHighlightsPostProcess;
  55922. private _createDepthOfFieldPostProcess;
  55923. private _createGrainTexture;
  55924. }
  55925. }
  55926. declare module "babylonjs/Shaders/ssao2.fragment" {
  55927. /** @hidden */
  55928. export var ssao2PixelShader: {
  55929. name: string;
  55930. shader: string;
  55931. };
  55932. }
  55933. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55934. /** @hidden */
  55935. export var ssaoCombinePixelShader: {
  55936. name: string;
  55937. shader: string;
  55938. };
  55939. }
  55940. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  55941. import { Camera } from "babylonjs/Cameras/camera";
  55942. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55943. import { Scene } from "babylonjs/scene";
  55944. import "babylonjs/Shaders/ssao2.fragment";
  55945. import "babylonjs/Shaders/ssaoCombine.fragment";
  55946. /**
  55947. * Render pipeline to produce ssao effect
  55948. */
  55949. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55950. /**
  55951. * @ignore
  55952. * The PassPostProcess id in the pipeline that contains the original scene color
  55953. */
  55954. SSAOOriginalSceneColorEffect: string;
  55955. /**
  55956. * @ignore
  55957. * The SSAO PostProcess id in the pipeline
  55958. */
  55959. SSAORenderEffect: string;
  55960. /**
  55961. * @ignore
  55962. * The horizontal blur PostProcess id in the pipeline
  55963. */
  55964. SSAOBlurHRenderEffect: string;
  55965. /**
  55966. * @ignore
  55967. * The vertical blur PostProcess id in the pipeline
  55968. */
  55969. SSAOBlurVRenderEffect: string;
  55970. /**
  55971. * @ignore
  55972. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55973. */
  55974. SSAOCombineRenderEffect: string;
  55975. /**
  55976. * The output strength of the SSAO post-process. Default value is 1.0.
  55977. */
  55978. totalStrength: number;
  55979. /**
  55980. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55981. */
  55982. maxZ: number;
  55983. /**
  55984. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55985. */
  55986. minZAspect: number;
  55987. private _samples;
  55988. /**
  55989. * Number of samples used for the SSAO calculations. Default value is 8
  55990. */
  55991. samples: number;
  55992. private _textureSamples;
  55993. /**
  55994. * Number of samples to use for antialiasing
  55995. */
  55996. textureSamples: number;
  55997. /**
  55998. * Ratio object used for SSAO ratio and blur ratio
  55999. */
  56000. private _ratio;
  56001. /**
  56002. * Dynamically generated sphere sampler.
  56003. */
  56004. private _sampleSphere;
  56005. /**
  56006. * Blur filter offsets
  56007. */
  56008. private _samplerOffsets;
  56009. private _expensiveBlur;
  56010. /**
  56011. * If bilateral blur should be used
  56012. */
  56013. expensiveBlur: boolean;
  56014. /**
  56015. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56016. */
  56017. radius: number;
  56018. /**
  56019. * The base color of the SSAO post-process
  56020. * The final result is "base + ssao" between [0, 1]
  56021. */
  56022. base: number;
  56023. /**
  56024. * Support test.
  56025. */
  56026. static readonly IsSupported: boolean;
  56027. private _scene;
  56028. private _depthTexture;
  56029. private _normalTexture;
  56030. private _randomTexture;
  56031. private _originalColorPostProcess;
  56032. private _ssaoPostProcess;
  56033. private _blurHPostProcess;
  56034. private _blurVPostProcess;
  56035. private _ssaoCombinePostProcess;
  56036. private _firstUpdate;
  56037. /**
  56038. * Gets active scene
  56039. */
  56040. readonly scene: Scene;
  56041. /**
  56042. * @constructor
  56043. * @param name The rendering pipeline name
  56044. * @param scene The scene linked to this pipeline
  56045. * @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 }
  56046. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56047. */
  56048. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56049. /**
  56050. * Get the class name
  56051. * @returns "SSAO2RenderingPipeline"
  56052. */
  56053. getClassName(): string;
  56054. /**
  56055. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56056. */
  56057. dispose(disableGeometryBufferRenderer?: boolean): void;
  56058. private _createBlurPostProcess;
  56059. /** @hidden */
  56060. _rebuild(): void;
  56061. private _bits;
  56062. private _radicalInverse_VdC;
  56063. private _hammersley;
  56064. private _hemisphereSample_uniform;
  56065. private _generateHemisphere;
  56066. private _createSSAOPostProcess;
  56067. private _createSSAOCombinePostProcess;
  56068. private _createRandomTexture;
  56069. /**
  56070. * Serialize the rendering pipeline (Used when exporting)
  56071. * @returns the serialized object
  56072. */
  56073. serialize(): any;
  56074. /**
  56075. * Parse the serialized pipeline
  56076. * @param source Source pipeline.
  56077. * @param scene The scene to load the pipeline to.
  56078. * @param rootUrl The URL of the serialized pipeline.
  56079. * @returns An instantiated pipeline from the serialized object.
  56080. */
  56081. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56082. }
  56083. }
  56084. declare module "babylonjs/Shaders/ssao.fragment" {
  56085. /** @hidden */
  56086. export var ssaoPixelShader: {
  56087. name: string;
  56088. shader: string;
  56089. };
  56090. }
  56091. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56092. import { Camera } from "babylonjs/Cameras/camera";
  56093. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56094. import { Scene } from "babylonjs/scene";
  56095. import "babylonjs/Shaders/ssao.fragment";
  56096. import "babylonjs/Shaders/ssaoCombine.fragment";
  56097. /**
  56098. * Render pipeline to produce ssao effect
  56099. */
  56100. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56101. /**
  56102. * @ignore
  56103. * The PassPostProcess id in the pipeline that contains the original scene color
  56104. */
  56105. SSAOOriginalSceneColorEffect: string;
  56106. /**
  56107. * @ignore
  56108. * The SSAO PostProcess id in the pipeline
  56109. */
  56110. SSAORenderEffect: string;
  56111. /**
  56112. * @ignore
  56113. * The horizontal blur PostProcess id in the pipeline
  56114. */
  56115. SSAOBlurHRenderEffect: string;
  56116. /**
  56117. * @ignore
  56118. * The vertical blur PostProcess id in the pipeline
  56119. */
  56120. SSAOBlurVRenderEffect: string;
  56121. /**
  56122. * @ignore
  56123. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56124. */
  56125. SSAOCombineRenderEffect: string;
  56126. /**
  56127. * The output strength of the SSAO post-process. Default value is 1.0.
  56128. */
  56129. totalStrength: number;
  56130. /**
  56131. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56132. */
  56133. radius: number;
  56134. /**
  56135. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56136. * Must not be equal to fallOff and superior to fallOff.
  56137. * Default value is 0.0075
  56138. */
  56139. area: number;
  56140. /**
  56141. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56142. * Must not be equal to area and inferior to area.
  56143. * Default value is 0.000001
  56144. */
  56145. fallOff: number;
  56146. /**
  56147. * The base color of the SSAO post-process
  56148. * The final result is "base + ssao" between [0, 1]
  56149. */
  56150. base: number;
  56151. private _scene;
  56152. private _depthTexture;
  56153. private _randomTexture;
  56154. private _originalColorPostProcess;
  56155. private _ssaoPostProcess;
  56156. private _blurHPostProcess;
  56157. private _blurVPostProcess;
  56158. private _ssaoCombinePostProcess;
  56159. private _firstUpdate;
  56160. /**
  56161. * Gets active scene
  56162. */
  56163. readonly scene: Scene;
  56164. /**
  56165. * @constructor
  56166. * @param name - The rendering pipeline name
  56167. * @param scene - The scene linked to this pipeline
  56168. * @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 }
  56169. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56170. */
  56171. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56172. /**
  56173. * Get the class name
  56174. * @returns "SSAORenderingPipeline"
  56175. */
  56176. getClassName(): string;
  56177. /**
  56178. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56179. */
  56180. dispose(disableDepthRender?: boolean): void;
  56181. private _createBlurPostProcess;
  56182. /** @hidden */
  56183. _rebuild(): void;
  56184. private _createSSAOPostProcess;
  56185. private _createSSAOCombinePostProcess;
  56186. private _createRandomTexture;
  56187. }
  56188. }
  56189. declare module "babylonjs/Shaders/standard.fragment" {
  56190. /** @hidden */
  56191. export var standardPixelShader: {
  56192. name: string;
  56193. shader: string;
  56194. };
  56195. }
  56196. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56197. import { Nullable } from "babylonjs/types";
  56198. import { IAnimatable } from "babylonjs/Misc/tools";
  56199. import { Camera } from "babylonjs/Cameras/camera";
  56200. import { Texture } from "babylonjs/Materials/Textures/texture";
  56201. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56202. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56203. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56204. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56205. import { IDisposable } from "babylonjs/scene";
  56206. import { SpotLight } from "babylonjs/Lights/spotLight";
  56207. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56208. import { Scene } from "babylonjs/scene";
  56209. import { Animation } from "babylonjs/Animations/animation";
  56210. import "babylonjs/Shaders/standard.fragment";
  56211. /**
  56212. * Standard rendering pipeline
  56213. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56214. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56215. */
  56216. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56217. /**
  56218. * Public members
  56219. */
  56220. /**
  56221. * Post-process which contains the original scene color before the pipeline applies all the effects
  56222. */
  56223. originalPostProcess: Nullable<PostProcess>;
  56224. /**
  56225. * Post-process used to down scale an image x4
  56226. */
  56227. downSampleX4PostProcess: Nullable<PostProcess>;
  56228. /**
  56229. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56230. */
  56231. brightPassPostProcess: Nullable<PostProcess>;
  56232. /**
  56233. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56234. */
  56235. blurHPostProcesses: PostProcess[];
  56236. /**
  56237. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56238. */
  56239. blurVPostProcesses: PostProcess[];
  56240. /**
  56241. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56242. */
  56243. textureAdderPostProcess: Nullable<PostProcess>;
  56244. /**
  56245. * Post-process used to create volumetric lighting effect
  56246. */
  56247. volumetricLightPostProcess: Nullable<PostProcess>;
  56248. /**
  56249. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56250. */
  56251. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56252. /**
  56253. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56254. */
  56255. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56256. /**
  56257. * Post-process used to merge the volumetric light effect and the real scene color
  56258. */
  56259. volumetricLightMergePostProces: Nullable<PostProcess>;
  56260. /**
  56261. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56262. */
  56263. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56264. /**
  56265. * Base post-process used to calculate the average luminance of the final image for HDR
  56266. */
  56267. luminancePostProcess: Nullable<PostProcess>;
  56268. /**
  56269. * Post-processes used to create down sample post-processes in order to get
  56270. * the average luminance of the final image for HDR
  56271. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56272. */
  56273. luminanceDownSamplePostProcesses: PostProcess[];
  56274. /**
  56275. * Post-process used to create a HDR effect (light adaptation)
  56276. */
  56277. hdrPostProcess: Nullable<PostProcess>;
  56278. /**
  56279. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56280. */
  56281. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56282. /**
  56283. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56284. */
  56285. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56286. /**
  56287. * Post-process used to merge the final HDR post-process and the real scene color
  56288. */
  56289. hdrFinalPostProcess: Nullable<PostProcess>;
  56290. /**
  56291. * Post-process used to create a lens flare effect
  56292. */
  56293. lensFlarePostProcess: Nullable<PostProcess>;
  56294. /**
  56295. * Post-process that merges the result of the lens flare post-process and the real scene color
  56296. */
  56297. lensFlareComposePostProcess: Nullable<PostProcess>;
  56298. /**
  56299. * Post-process used to create a motion blur effect
  56300. */
  56301. motionBlurPostProcess: Nullable<PostProcess>;
  56302. /**
  56303. * Post-process used to create a depth of field effect
  56304. */
  56305. depthOfFieldPostProcess: Nullable<PostProcess>;
  56306. /**
  56307. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56308. */
  56309. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56310. /**
  56311. * Represents the brightness threshold in order to configure the illuminated surfaces
  56312. */
  56313. brightThreshold: number;
  56314. /**
  56315. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56316. */
  56317. blurWidth: number;
  56318. /**
  56319. * Sets if the blur for highlighted surfaces must be only horizontal
  56320. */
  56321. horizontalBlur: boolean;
  56322. /**
  56323. * Gets the overall exposure used by the pipeline
  56324. */
  56325. /**
  56326. * Sets the overall exposure used by the pipeline
  56327. */
  56328. exposure: number;
  56329. /**
  56330. * Texture used typically to simulate "dirty" on camera lens
  56331. */
  56332. lensTexture: Nullable<Texture>;
  56333. /**
  56334. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56335. */
  56336. volumetricLightCoefficient: number;
  56337. /**
  56338. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56339. */
  56340. volumetricLightPower: number;
  56341. /**
  56342. * Used the set the blur intensity to smooth the volumetric lights
  56343. */
  56344. volumetricLightBlurScale: number;
  56345. /**
  56346. * Light (spot or directional) used to generate the volumetric lights rays
  56347. * The source light must have a shadow generate so the pipeline can get its
  56348. * depth map
  56349. */
  56350. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56351. /**
  56352. * For eye adaptation, represents the minimum luminance the eye can see
  56353. */
  56354. hdrMinimumLuminance: number;
  56355. /**
  56356. * For eye adaptation, represents the decrease luminance speed
  56357. */
  56358. hdrDecreaseRate: number;
  56359. /**
  56360. * For eye adaptation, represents the increase luminance speed
  56361. */
  56362. hdrIncreaseRate: number;
  56363. /**
  56364. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56365. */
  56366. /**
  56367. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56368. */
  56369. hdrAutoExposure: boolean;
  56370. /**
  56371. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56372. */
  56373. lensColorTexture: Nullable<Texture>;
  56374. /**
  56375. * The overall strengh for the lens flare effect
  56376. */
  56377. lensFlareStrength: number;
  56378. /**
  56379. * Dispersion coefficient for lens flare ghosts
  56380. */
  56381. lensFlareGhostDispersal: number;
  56382. /**
  56383. * Main lens flare halo width
  56384. */
  56385. lensFlareHaloWidth: number;
  56386. /**
  56387. * Based on the lens distortion effect, defines how much the lens flare result
  56388. * is distorted
  56389. */
  56390. lensFlareDistortionStrength: number;
  56391. /**
  56392. * Lens star texture must be used to simulate rays on the flares and is available
  56393. * in the documentation
  56394. */
  56395. lensStarTexture: Nullable<Texture>;
  56396. /**
  56397. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56398. * flare effect by taking account of the dirt texture
  56399. */
  56400. lensFlareDirtTexture: Nullable<Texture>;
  56401. /**
  56402. * Represents the focal length for the depth of field effect
  56403. */
  56404. depthOfFieldDistance: number;
  56405. /**
  56406. * Represents the blur intensity for the blurred part of the depth of field effect
  56407. */
  56408. depthOfFieldBlurWidth: number;
  56409. /**
  56410. * For motion blur, defines how much the image is blurred by the movement
  56411. */
  56412. motionStrength: number;
  56413. /**
  56414. * List of animations for the pipeline (IAnimatable implementation)
  56415. */
  56416. animations: Animation[];
  56417. /**
  56418. * Private members
  56419. */
  56420. private _scene;
  56421. private _currentDepthOfFieldSource;
  56422. private _basePostProcess;
  56423. private _fixedExposure;
  56424. private _currentExposure;
  56425. private _hdrAutoExposure;
  56426. private _hdrCurrentLuminance;
  56427. private _floatTextureType;
  56428. private _ratio;
  56429. private _bloomEnabled;
  56430. private _depthOfFieldEnabled;
  56431. private _vlsEnabled;
  56432. private _lensFlareEnabled;
  56433. private _hdrEnabled;
  56434. private _motionBlurEnabled;
  56435. private _fxaaEnabled;
  56436. private _motionBlurSamples;
  56437. private _volumetricLightStepsCount;
  56438. private _samples;
  56439. /**
  56440. * @ignore
  56441. * Specifies if the bloom pipeline is enabled
  56442. */
  56443. BloomEnabled: boolean;
  56444. /**
  56445. * @ignore
  56446. * Specifies if the depth of field pipeline is enabed
  56447. */
  56448. DepthOfFieldEnabled: boolean;
  56449. /**
  56450. * @ignore
  56451. * Specifies if the lens flare pipeline is enabed
  56452. */
  56453. LensFlareEnabled: boolean;
  56454. /**
  56455. * @ignore
  56456. * Specifies if the HDR pipeline is enabled
  56457. */
  56458. HDREnabled: boolean;
  56459. /**
  56460. * @ignore
  56461. * Specifies if the volumetric lights scattering effect is enabled
  56462. */
  56463. VLSEnabled: boolean;
  56464. /**
  56465. * @ignore
  56466. * Specifies if the motion blur effect is enabled
  56467. */
  56468. MotionBlurEnabled: boolean;
  56469. /**
  56470. * Specifies if anti-aliasing is enabled
  56471. */
  56472. fxaaEnabled: boolean;
  56473. /**
  56474. * Specifies the number of steps used to calculate the volumetric lights
  56475. * Typically in interval [50, 200]
  56476. */
  56477. volumetricLightStepsCount: number;
  56478. /**
  56479. * Specifies the number of samples used for the motion blur effect
  56480. * Typically in interval [16, 64]
  56481. */
  56482. motionBlurSamples: number;
  56483. /**
  56484. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56485. */
  56486. samples: number;
  56487. /**
  56488. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56489. * @constructor
  56490. * @param name The rendering pipeline name
  56491. * @param scene The scene linked to this pipeline
  56492. * @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)
  56493. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56494. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56495. */
  56496. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56497. private _buildPipeline;
  56498. private _createDownSampleX4PostProcess;
  56499. private _createBrightPassPostProcess;
  56500. private _createBlurPostProcesses;
  56501. private _createTextureAdderPostProcess;
  56502. private _createVolumetricLightPostProcess;
  56503. private _createLuminancePostProcesses;
  56504. private _createHdrPostProcess;
  56505. private _createLensFlarePostProcess;
  56506. private _createDepthOfFieldPostProcess;
  56507. private _createMotionBlurPostProcess;
  56508. private _getDepthTexture;
  56509. private _disposePostProcesses;
  56510. /**
  56511. * Dispose of the pipeline and stop all post processes
  56512. */
  56513. dispose(): void;
  56514. /**
  56515. * Serialize the rendering pipeline (Used when exporting)
  56516. * @returns the serialized object
  56517. */
  56518. serialize(): any;
  56519. /**
  56520. * Parse the serialized pipeline
  56521. * @param source Source pipeline.
  56522. * @param scene The scene to load the pipeline to.
  56523. * @param rootUrl The URL of the serialized pipeline.
  56524. * @returns An instantiated pipeline from the serialized object.
  56525. */
  56526. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56527. /**
  56528. * Luminance steps
  56529. */
  56530. static LuminanceSteps: number;
  56531. }
  56532. }
  56533. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  56534. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  56535. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  56536. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  56537. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  56538. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  56539. }
  56540. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  56541. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  56542. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  56543. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56544. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56545. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56546. }
  56547. declare module "babylonjs/Shaders/tonemap.fragment" {
  56548. /** @hidden */
  56549. export var tonemapPixelShader: {
  56550. name: string;
  56551. shader: string;
  56552. };
  56553. }
  56554. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  56555. import { Camera } from "babylonjs/Cameras/camera";
  56556. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56557. import "babylonjs/Shaders/tonemap.fragment";
  56558. import { Engine } from "babylonjs/Engines/engine";
  56559. /** Defines operator used for tonemapping */
  56560. export enum TonemappingOperator {
  56561. /** Hable */
  56562. Hable = 0,
  56563. /** Reinhard */
  56564. Reinhard = 1,
  56565. /** HejiDawson */
  56566. HejiDawson = 2,
  56567. /** Photographic */
  56568. Photographic = 3
  56569. }
  56570. /**
  56571. * Defines a post process to apply tone mapping
  56572. */
  56573. export class TonemapPostProcess extends PostProcess {
  56574. private _operator;
  56575. /** Defines the required exposure adjustement */
  56576. exposureAdjustment: number;
  56577. /**
  56578. * Creates a new TonemapPostProcess
  56579. * @param name defines the name of the postprocess
  56580. * @param _operator defines the operator to use
  56581. * @param exposureAdjustment defines the required exposure adjustement
  56582. * @param camera defines the camera to use (can be null)
  56583. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56584. * @param engine defines the hosting engine (can be ignore if camera is set)
  56585. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56586. */
  56587. constructor(name: string, _operator: TonemappingOperator,
  56588. /** Defines the required exposure adjustement */
  56589. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56590. }
  56591. }
  56592. declare module "babylonjs/Shaders/depth.vertex" {
  56593. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56594. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56595. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56596. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56597. /** @hidden */
  56598. export var depthVertexShader: {
  56599. name: string;
  56600. shader: string;
  56601. };
  56602. }
  56603. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  56604. /** @hidden */
  56605. export var volumetricLightScatteringPixelShader: {
  56606. name: string;
  56607. shader: string;
  56608. };
  56609. }
  56610. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  56611. /** @hidden */
  56612. export var volumetricLightScatteringPassPixelShader: {
  56613. name: string;
  56614. shader: string;
  56615. };
  56616. }
  56617. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  56618. import { Vector3 } from "babylonjs/Maths/math";
  56619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56620. import { Mesh } from "babylonjs/Meshes/mesh";
  56621. import { Camera } from "babylonjs/Cameras/camera";
  56622. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56623. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56624. import { Scene } from "babylonjs/scene";
  56625. import "babylonjs/Meshes/Builders/planeBuilder";
  56626. import "babylonjs/Shaders/depth.vertex";
  56627. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  56628. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  56629. import { Engine } from "babylonjs/Engines/engine";
  56630. /**
  56631. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56632. */
  56633. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56634. private _volumetricLightScatteringPass;
  56635. private _volumetricLightScatteringRTT;
  56636. private _viewPort;
  56637. private _screenCoordinates;
  56638. private _cachedDefines;
  56639. /**
  56640. * If not undefined, the mesh position is computed from the attached node position
  56641. */
  56642. attachedNode: {
  56643. position: Vector3;
  56644. };
  56645. /**
  56646. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56647. */
  56648. customMeshPosition: Vector3;
  56649. /**
  56650. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56651. */
  56652. useCustomMeshPosition: boolean;
  56653. /**
  56654. * If the post-process should inverse the light scattering direction
  56655. */
  56656. invert: boolean;
  56657. /**
  56658. * The internal mesh used by the post-process
  56659. */
  56660. mesh: Mesh;
  56661. /**
  56662. * @hidden
  56663. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56664. */
  56665. useDiffuseColor: boolean;
  56666. /**
  56667. * Array containing the excluded meshes not rendered in the internal pass
  56668. */
  56669. excludedMeshes: AbstractMesh[];
  56670. /**
  56671. * Controls the overall intensity of the post-process
  56672. */
  56673. exposure: number;
  56674. /**
  56675. * Dissipates each sample's contribution in range [0, 1]
  56676. */
  56677. decay: number;
  56678. /**
  56679. * Controls the overall intensity of each sample
  56680. */
  56681. weight: number;
  56682. /**
  56683. * Controls the density of each sample
  56684. */
  56685. density: number;
  56686. /**
  56687. * @constructor
  56688. * @param name The post-process name
  56689. * @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)
  56690. * @param camera The camera that the post-process will be attached to
  56691. * @param mesh The mesh used to create the light scattering
  56692. * @param samples The post-process quality, default 100
  56693. * @param samplingModeThe post-process filtering mode
  56694. * @param engine The babylon engine
  56695. * @param reusable If the post-process is reusable
  56696. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56697. */
  56698. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56699. /**
  56700. * Returns the string "VolumetricLightScatteringPostProcess"
  56701. * @returns "VolumetricLightScatteringPostProcess"
  56702. */
  56703. getClassName(): string;
  56704. private _isReady;
  56705. /**
  56706. * Sets the new light position for light scattering effect
  56707. * @param position The new custom light position
  56708. */
  56709. setCustomMeshPosition(position: Vector3): void;
  56710. /**
  56711. * Returns the light position for light scattering effect
  56712. * @return Vector3 The custom light position
  56713. */
  56714. getCustomMeshPosition(): Vector3;
  56715. /**
  56716. * Disposes the internal assets and detaches the post-process from the camera
  56717. */
  56718. dispose(camera: Camera): void;
  56719. /**
  56720. * Returns the render target texture used by the post-process
  56721. * @return the render target texture used by the post-process
  56722. */
  56723. getPass(): RenderTargetTexture;
  56724. private _meshExcluded;
  56725. private _createPass;
  56726. private _updateMeshScreenCoordinates;
  56727. /**
  56728. * Creates a default mesh for the Volumeric Light Scattering post-process
  56729. * @param name The mesh name
  56730. * @param scene The scene where to create the mesh
  56731. * @return the default mesh
  56732. */
  56733. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56734. }
  56735. }
  56736. declare module "babylonjs/PostProcesses/index" {
  56737. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  56738. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  56739. export * from "babylonjs/PostProcesses/bloomEffect";
  56740. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  56741. export * from "babylonjs/PostProcesses/blurPostProcess";
  56742. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56743. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  56744. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  56745. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  56746. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  56747. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  56748. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  56749. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  56750. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  56751. export * from "babylonjs/PostProcesses/filterPostProcess";
  56752. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  56753. export * from "babylonjs/PostProcesses/grainPostProcess";
  56754. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  56755. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56756. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  56757. export * from "babylonjs/PostProcesses/passPostProcess";
  56758. export * from "babylonjs/PostProcesses/postProcess";
  56759. export * from "babylonjs/PostProcesses/postProcessManager";
  56760. export * from "babylonjs/PostProcesses/refractionPostProcess";
  56761. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  56762. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  56763. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  56764. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  56765. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  56766. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  56767. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  56768. }
  56769. declare module "babylonjs/Probes/index" {
  56770. export * from "babylonjs/Probes/reflectionProbe";
  56771. }
  56772. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  56773. import { Scene } from "babylonjs/scene";
  56774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56775. import { Color3 } from "babylonjs/Maths/math";
  56776. import { SmartArray } from "babylonjs/Misc/smartArray";
  56777. import { ISceneComponent } from "babylonjs/sceneComponent";
  56778. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  56779. import "babylonjs/Meshes/Builders/boxBuilder";
  56780. import "babylonjs/Shaders/color.fragment";
  56781. import "babylonjs/Shaders/color.vertex";
  56782. module "babylonjs/scene" {
  56783. interface Scene {
  56784. /** @hidden (Backing field) */
  56785. _boundingBoxRenderer: BoundingBoxRenderer;
  56786. /** @hidden (Backing field) */
  56787. _forceShowBoundingBoxes: boolean;
  56788. /**
  56789. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56790. */
  56791. forceShowBoundingBoxes: boolean;
  56792. /**
  56793. * Gets the bounding box renderer associated with the scene
  56794. * @returns a BoundingBoxRenderer
  56795. */
  56796. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56797. }
  56798. }
  56799. module "babylonjs/Meshes/abstractMesh" {
  56800. interface AbstractMesh {
  56801. /** @hidden (Backing field) */
  56802. _showBoundingBox: boolean;
  56803. /**
  56804. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56805. */
  56806. showBoundingBox: boolean;
  56807. }
  56808. }
  56809. /**
  56810. * Component responsible of rendering the bounding box of the meshes in a scene.
  56811. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56812. */
  56813. export class BoundingBoxRenderer implements ISceneComponent {
  56814. /**
  56815. * The component name helpfull to identify the component in the list of scene components.
  56816. */
  56817. readonly name: string;
  56818. /**
  56819. * The scene the component belongs to.
  56820. */
  56821. scene: Scene;
  56822. /**
  56823. * Color of the bounding box lines placed in front of an object
  56824. */
  56825. frontColor: Color3;
  56826. /**
  56827. * Color of the bounding box lines placed behind an object
  56828. */
  56829. backColor: Color3;
  56830. /**
  56831. * Defines if the renderer should show the back lines or not
  56832. */
  56833. showBackLines: boolean;
  56834. /**
  56835. * @hidden
  56836. */
  56837. renderList: SmartArray<BoundingBox>;
  56838. private _colorShader;
  56839. private _vertexBuffers;
  56840. private _indexBuffer;
  56841. /**
  56842. * Instantiates a new bounding box renderer in a scene.
  56843. * @param scene the scene the renderer renders in
  56844. */
  56845. constructor(scene: Scene);
  56846. /**
  56847. * Registers the component in a given scene
  56848. */
  56849. register(): void;
  56850. private _evaluateSubMesh;
  56851. private _activeMesh;
  56852. private _prepareRessources;
  56853. private _createIndexBuffer;
  56854. /**
  56855. * Rebuilds the elements related to this component in case of
  56856. * context lost for instance.
  56857. */
  56858. rebuild(): void;
  56859. /**
  56860. * @hidden
  56861. */
  56862. reset(): void;
  56863. /**
  56864. * Render the bounding boxes of a specific rendering group
  56865. * @param renderingGroupId defines the rendering group to render
  56866. */
  56867. render(renderingGroupId: number): void;
  56868. /**
  56869. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56870. * @param mesh Define the mesh to render the occlusion bounding box for
  56871. */
  56872. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56873. /**
  56874. * Dispose and release the resources attached to this renderer.
  56875. */
  56876. dispose(): void;
  56877. }
  56878. }
  56879. declare module "babylonjs/Shaders/depth.fragment" {
  56880. /** @hidden */
  56881. export var depthPixelShader: {
  56882. name: string;
  56883. shader: string;
  56884. };
  56885. }
  56886. declare module "babylonjs/Rendering/depthRenderer" {
  56887. import { Nullable } from "babylonjs/types";
  56888. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56889. import { Scene } from "babylonjs/scene";
  56890. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56891. import { Camera } from "babylonjs/Cameras/camera";
  56892. import "babylonjs/Shaders/depth.fragment";
  56893. import "babylonjs/Shaders/depth.vertex";
  56894. /**
  56895. * This represents a depth renderer in Babylon.
  56896. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56897. */
  56898. export class DepthRenderer {
  56899. private _scene;
  56900. private _depthMap;
  56901. private _effect;
  56902. private _cachedDefines;
  56903. private _camera;
  56904. /**
  56905. * Specifiess that the depth renderer will only be used within
  56906. * the camera it is created for.
  56907. * This can help forcing its rendering during the camera processing.
  56908. */
  56909. useOnlyInActiveCamera: boolean;
  56910. /** @hidden */
  56911. static _SceneComponentInitialization: (scene: Scene) => void;
  56912. /**
  56913. * Instantiates a depth renderer
  56914. * @param scene The scene the renderer belongs to
  56915. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56916. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56917. */
  56918. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56919. /**
  56920. * Creates the depth rendering effect and checks if the effect is ready.
  56921. * @param subMesh The submesh to be used to render the depth map of
  56922. * @param useInstances If multiple world instances should be used
  56923. * @returns if the depth renderer is ready to render the depth map
  56924. */
  56925. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56926. /**
  56927. * Gets the texture which the depth map will be written to.
  56928. * @returns The depth map texture
  56929. */
  56930. getDepthMap(): RenderTargetTexture;
  56931. /**
  56932. * Disposes of the depth renderer.
  56933. */
  56934. dispose(): void;
  56935. }
  56936. }
  56937. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  56938. import { Nullable } from "babylonjs/types";
  56939. import { Scene } from "babylonjs/scene";
  56940. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56941. import { Camera } from "babylonjs/Cameras/camera";
  56942. import { ISceneComponent } from "babylonjs/sceneComponent";
  56943. module "babylonjs/scene" {
  56944. interface Scene {
  56945. /** @hidden (Backing field) */
  56946. _depthRenderer: {
  56947. [id: string]: DepthRenderer;
  56948. };
  56949. /**
  56950. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56951. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56952. * @returns the created depth renderer
  56953. */
  56954. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56955. /**
  56956. * Disables a depth renderer for a given camera
  56957. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56958. */
  56959. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56960. }
  56961. }
  56962. /**
  56963. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56964. * in several rendering techniques.
  56965. */
  56966. export class DepthRendererSceneComponent implements ISceneComponent {
  56967. /**
  56968. * The component name helpfull to identify the component in the list of scene components.
  56969. */
  56970. readonly name: string;
  56971. /**
  56972. * The scene the component belongs to.
  56973. */
  56974. scene: Scene;
  56975. /**
  56976. * Creates a new instance of the component for the given scene
  56977. * @param scene Defines the scene to register the component in
  56978. */
  56979. constructor(scene: Scene);
  56980. /**
  56981. * Registers the component in a given scene
  56982. */
  56983. register(): void;
  56984. /**
  56985. * Rebuilds the elements related to this component in case of
  56986. * context lost for instance.
  56987. */
  56988. rebuild(): void;
  56989. /**
  56990. * Disposes the component and the associated ressources
  56991. */
  56992. dispose(): void;
  56993. private _gatherRenderTargets;
  56994. private _gatherActiveCameraRenderTargets;
  56995. }
  56996. }
  56997. declare module "babylonjs/Shaders/outline.fragment" {
  56998. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56999. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57000. /** @hidden */
  57001. export var outlinePixelShader: {
  57002. name: string;
  57003. shader: string;
  57004. };
  57005. }
  57006. declare module "babylonjs/Shaders/outline.vertex" {
  57007. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57008. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57009. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57010. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57011. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57012. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57013. /** @hidden */
  57014. export var outlineVertexShader: {
  57015. name: string;
  57016. shader: string;
  57017. };
  57018. }
  57019. declare module "babylonjs/Rendering/outlineRenderer" {
  57020. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57021. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57022. import { Scene } from "babylonjs/scene";
  57023. import { ISceneComponent } from "babylonjs/sceneComponent";
  57024. import "babylonjs/Shaders/outline.fragment";
  57025. import "babylonjs/Shaders/outline.vertex";
  57026. module "babylonjs/scene" {
  57027. interface Scene {
  57028. /** @hidden */
  57029. _outlineRenderer: OutlineRenderer;
  57030. /**
  57031. * Gets the outline renderer associated with the scene
  57032. * @returns a OutlineRenderer
  57033. */
  57034. getOutlineRenderer(): OutlineRenderer;
  57035. }
  57036. }
  57037. module "babylonjs/Meshes/abstractMesh" {
  57038. interface AbstractMesh {
  57039. /** @hidden (Backing field) */
  57040. _renderOutline: boolean;
  57041. /**
  57042. * Gets or sets a boolean indicating if the outline must be rendered as well
  57043. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57044. */
  57045. renderOutline: boolean;
  57046. /** @hidden (Backing field) */
  57047. _renderOverlay: boolean;
  57048. /**
  57049. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57050. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57051. */
  57052. renderOverlay: boolean;
  57053. }
  57054. }
  57055. /**
  57056. * This class is responsible to draw bothe outline/overlay of meshes.
  57057. * It should not be used directly but through the available method on mesh.
  57058. */
  57059. export class OutlineRenderer implements ISceneComponent {
  57060. /**
  57061. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57062. */
  57063. private static _StencilReference;
  57064. /**
  57065. * The name of the component. Each component must have a unique name.
  57066. */
  57067. name: string;
  57068. /**
  57069. * The scene the component belongs to.
  57070. */
  57071. scene: Scene;
  57072. /**
  57073. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57074. */
  57075. zOffset: number;
  57076. private _engine;
  57077. private _effect;
  57078. private _cachedDefines;
  57079. private _savedDepthWrite;
  57080. /**
  57081. * Instantiates a new outline renderer. (There could be only one per scene).
  57082. * @param scene Defines the scene it belongs to
  57083. */
  57084. constructor(scene: Scene);
  57085. /**
  57086. * Register the component to one instance of a scene.
  57087. */
  57088. register(): void;
  57089. /**
  57090. * Rebuilds the elements related to this component in case of
  57091. * context lost for instance.
  57092. */
  57093. rebuild(): void;
  57094. /**
  57095. * Disposes the component and the associated ressources.
  57096. */
  57097. dispose(): void;
  57098. /**
  57099. * Renders the outline in the canvas.
  57100. * @param subMesh Defines the sumesh to render
  57101. * @param batch Defines the batch of meshes in case of instances
  57102. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57103. */
  57104. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57105. /**
  57106. * Returns whether or not the outline renderer is ready for a given submesh.
  57107. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57108. * @param subMesh Defines the submesh to check readyness for
  57109. * @param useInstances Defines wheter wee are trying to render instances or not
  57110. * @returns true if ready otherwise false
  57111. */
  57112. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57113. private _beforeRenderingMesh;
  57114. private _afterRenderingMesh;
  57115. }
  57116. }
  57117. declare module "babylonjs/Rendering/index" {
  57118. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57119. export * from "babylonjs/Rendering/depthRenderer";
  57120. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57121. export * from "babylonjs/Rendering/edgesRenderer";
  57122. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57123. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57124. export * from "babylonjs/Rendering/outlineRenderer";
  57125. export * from "babylonjs/Rendering/renderingGroup";
  57126. export * from "babylonjs/Rendering/renderingManager";
  57127. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57128. }
  57129. declare module "babylonjs/Sprites/index" {
  57130. export * from "babylonjs/Sprites/sprite";
  57131. export * from "babylonjs/Sprites/spriteManager";
  57132. export * from "babylonjs/Sprites/spriteSceneComponent";
  57133. }
  57134. declare module "babylonjs/Misc/assetsManager" {
  57135. import { Scene } from "babylonjs/scene";
  57136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57137. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57138. import { Skeleton } from "babylonjs/Bones/skeleton";
  57139. import { Observable } from "babylonjs/Misc/observable";
  57140. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57141. import { Texture } from "babylonjs/Materials/Textures/texture";
  57142. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57143. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57144. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57145. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57146. /**
  57147. * Defines the list of states available for a task inside a AssetsManager
  57148. */
  57149. export enum AssetTaskState {
  57150. /**
  57151. * Initialization
  57152. */
  57153. INIT = 0,
  57154. /**
  57155. * Running
  57156. */
  57157. RUNNING = 1,
  57158. /**
  57159. * Done
  57160. */
  57161. DONE = 2,
  57162. /**
  57163. * Error
  57164. */
  57165. ERROR = 3
  57166. }
  57167. /**
  57168. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57169. */
  57170. export abstract class AbstractAssetTask {
  57171. /**
  57172. * Task name
  57173. */ name: string;
  57174. /**
  57175. * Callback called when the task is successful
  57176. */
  57177. onSuccess: (task: any) => void;
  57178. /**
  57179. * Callback called when the task is not successful
  57180. */
  57181. onError: (task: any, message?: string, exception?: any) => void;
  57182. /**
  57183. * Creates a new AssetsManager
  57184. * @param name defines the name of the task
  57185. */
  57186. constructor(
  57187. /**
  57188. * Task name
  57189. */ name: string);
  57190. private _isCompleted;
  57191. private _taskState;
  57192. private _errorObject;
  57193. /**
  57194. * Get if the task is completed
  57195. */
  57196. readonly isCompleted: boolean;
  57197. /**
  57198. * Gets the current state of the task
  57199. */
  57200. readonly taskState: AssetTaskState;
  57201. /**
  57202. * Gets the current error object (if task is in error)
  57203. */
  57204. readonly errorObject: {
  57205. message?: string;
  57206. exception?: any;
  57207. };
  57208. /**
  57209. * Internal only
  57210. * @hidden
  57211. */
  57212. _setErrorObject(message?: string, exception?: any): void;
  57213. /**
  57214. * Execute the current task
  57215. * @param scene defines the scene where you want your assets to be loaded
  57216. * @param onSuccess is a callback called when the task is successfully executed
  57217. * @param onError is a callback called if an error occurs
  57218. */
  57219. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57220. /**
  57221. * Execute the current task
  57222. * @param scene defines the scene where you want your assets to be loaded
  57223. * @param onSuccess is a callback called when the task is successfully executed
  57224. * @param onError is a callback called if an error occurs
  57225. */
  57226. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57227. /**
  57228. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57229. * This can be used with failed tasks that have the reason for failure fixed.
  57230. */
  57231. reset(): void;
  57232. private onErrorCallback;
  57233. private onDoneCallback;
  57234. }
  57235. /**
  57236. * Define the interface used by progress events raised during assets loading
  57237. */
  57238. export interface IAssetsProgressEvent {
  57239. /**
  57240. * Defines the number of remaining tasks to process
  57241. */
  57242. remainingCount: number;
  57243. /**
  57244. * Defines the total number of tasks
  57245. */
  57246. totalCount: number;
  57247. /**
  57248. * Defines the task that was just processed
  57249. */
  57250. task: AbstractAssetTask;
  57251. }
  57252. /**
  57253. * Class used to share progress information about assets loading
  57254. */
  57255. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57256. /**
  57257. * Defines the number of remaining tasks to process
  57258. */
  57259. remainingCount: number;
  57260. /**
  57261. * Defines the total number of tasks
  57262. */
  57263. totalCount: number;
  57264. /**
  57265. * Defines the task that was just processed
  57266. */
  57267. task: AbstractAssetTask;
  57268. /**
  57269. * Creates a AssetsProgressEvent
  57270. * @param remainingCount defines the number of remaining tasks to process
  57271. * @param totalCount defines the total number of tasks
  57272. * @param task defines the task that was just processed
  57273. */
  57274. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57275. }
  57276. /**
  57277. * Define a task used by AssetsManager to load meshes
  57278. */
  57279. export class MeshAssetTask extends AbstractAssetTask {
  57280. /**
  57281. * Defines the name of the task
  57282. */
  57283. name: string;
  57284. /**
  57285. * Defines the list of mesh's names you want to load
  57286. */
  57287. meshesNames: any;
  57288. /**
  57289. * Defines the root url to use as a base to load your meshes and associated resources
  57290. */
  57291. rootUrl: string;
  57292. /**
  57293. * Defines the filename of the scene to load from
  57294. */
  57295. sceneFilename: string;
  57296. /**
  57297. * Gets the list of loaded meshes
  57298. */
  57299. loadedMeshes: Array<AbstractMesh>;
  57300. /**
  57301. * Gets the list of loaded particle systems
  57302. */
  57303. loadedParticleSystems: Array<IParticleSystem>;
  57304. /**
  57305. * Gets the list of loaded skeletons
  57306. */
  57307. loadedSkeletons: Array<Skeleton>;
  57308. /**
  57309. * Gets the list of loaded animation groups
  57310. */
  57311. loadedAnimationGroups: Array<AnimationGroup>;
  57312. /**
  57313. * Callback called when the task is successful
  57314. */
  57315. onSuccess: (task: MeshAssetTask) => void;
  57316. /**
  57317. * Callback called when the task is successful
  57318. */
  57319. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57320. /**
  57321. * Creates a new MeshAssetTask
  57322. * @param name defines the name of the task
  57323. * @param meshesNames defines the list of mesh's names you want to load
  57324. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57325. * @param sceneFilename defines the filename of the scene to load from
  57326. */
  57327. constructor(
  57328. /**
  57329. * Defines the name of the task
  57330. */
  57331. name: string,
  57332. /**
  57333. * Defines the list of mesh's names you want to load
  57334. */
  57335. meshesNames: any,
  57336. /**
  57337. * Defines the root url to use as a base to load your meshes and associated resources
  57338. */
  57339. rootUrl: string,
  57340. /**
  57341. * Defines the filename of the scene to load from
  57342. */
  57343. sceneFilename: string);
  57344. /**
  57345. * Execute the current task
  57346. * @param scene defines the scene where you want your assets to be loaded
  57347. * @param onSuccess is a callback called when the task is successfully executed
  57348. * @param onError is a callback called if an error occurs
  57349. */
  57350. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57351. }
  57352. /**
  57353. * Define a task used by AssetsManager to load text content
  57354. */
  57355. export class TextFileAssetTask extends AbstractAssetTask {
  57356. /**
  57357. * Defines the name of the task
  57358. */
  57359. name: string;
  57360. /**
  57361. * Defines the location of the file to load
  57362. */
  57363. url: string;
  57364. /**
  57365. * Gets the loaded text string
  57366. */
  57367. text: string;
  57368. /**
  57369. * Callback called when the task is successful
  57370. */
  57371. onSuccess: (task: TextFileAssetTask) => void;
  57372. /**
  57373. * Callback called when the task is successful
  57374. */
  57375. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57376. /**
  57377. * Creates a new TextFileAssetTask object
  57378. * @param name defines the name of the task
  57379. * @param url defines the location of the file to load
  57380. */
  57381. constructor(
  57382. /**
  57383. * Defines the name of the task
  57384. */
  57385. name: string,
  57386. /**
  57387. * Defines the location of the file to load
  57388. */
  57389. url: string);
  57390. /**
  57391. * Execute the current task
  57392. * @param scene defines the scene where you want your assets to be loaded
  57393. * @param onSuccess is a callback called when the task is successfully executed
  57394. * @param onError is a callback called if an error occurs
  57395. */
  57396. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57397. }
  57398. /**
  57399. * Define a task used by AssetsManager to load binary data
  57400. */
  57401. export class BinaryFileAssetTask extends AbstractAssetTask {
  57402. /**
  57403. * Defines the name of the task
  57404. */
  57405. name: string;
  57406. /**
  57407. * Defines the location of the file to load
  57408. */
  57409. url: string;
  57410. /**
  57411. * Gets the lodaded data (as an array buffer)
  57412. */
  57413. data: ArrayBuffer;
  57414. /**
  57415. * Callback called when the task is successful
  57416. */
  57417. onSuccess: (task: BinaryFileAssetTask) => void;
  57418. /**
  57419. * Callback called when the task is successful
  57420. */
  57421. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57422. /**
  57423. * Creates a new BinaryFileAssetTask object
  57424. * @param name defines the name of the new task
  57425. * @param url defines the location of the file to load
  57426. */
  57427. constructor(
  57428. /**
  57429. * Defines the name of the task
  57430. */
  57431. name: string,
  57432. /**
  57433. * Defines the location of the file to load
  57434. */
  57435. url: string);
  57436. /**
  57437. * Execute the current task
  57438. * @param scene defines the scene where you want your assets to be loaded
  57439. * @param onSuccess is a callback called when the task is successfully executed
  57440. * @param onError is a callback called if an error occurs
  57441. */
  57442. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57443. }
  57444. /**
  57445. * Define a task used by AssetsManager to load images
  57446. */
  57447. export class ImageAssetTask extends AbstractAssetTask {
  57448. /**
  57449. * Defines the name of the task
  57450. */
  57451. name: string;
  57452. /**
  57453. * Defines the location of the image to load
  57454. */
  57455. url: string;
  57456. /**
  57457. * Gets the loaded images
  57458. */
  57459. image: HTMLImageElement;
  57460. /**
  57461. * Callback called when the task is successful
  57462. */
  57463. onSuccess: (task: ImageAssetTask) => void;
  57464. /**
  57465. * Callback called when the task is successful
  57466. */
  57467. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57468. /**
  57469. * Creates a new ImageAssetTask
  57470. * @param name defines the name of the task
  57471. * @param url defines the location of the image to load
  57472. */
  57473. constructor(
  57474. /**
  57475. * Defines the name of the task
  57476. */
  57477. name: string,
  57478. /**
  57479. * Defines the location of the image to load
  57480. */
  57481. url: string);
  57482. /**
  57483. * Execute the current task
  57484. * @param scene defines the scene where you want your assets to be loaded
  57485. * @param onSuccess is a callback called when the task is successfully executed
  57486. * @param onError is a callback called if an error occurs
  57487. */
  57488. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57489. }
  57490. /**
  57491. * Defines the interface used by texture loading tasks
  57492. */
  57493. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57494. /**
  57495. * Gets the loaded texture
  57496. */
  57497. texture: TEX;
  57498. }
  57499. /**
  57500. * Define a task used by AssetsManager to load 2D textures
  57501. */
  57502. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57503. /**
  57504. * Defines the name of the task
  57505. */
  57506. name: string;
  57507. /**
  57508. * Defines the location of the file to load
  57509. */
  57510. url: string;
  57511. /**
  57512. * Defines if mipmap should not be generated (default is false)
  57513. */
  57514. noMipmap?: boolean | undefined;
  57515. /**
  57516. * Defines if texture must be inverted on Y axis (default is false)
  57517. */
  57518. invertY?: boolean | undefined;
  57519. /**
  57520. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57521. */
  57522. samplingMode: number;
  57523. /**
  57524. * Gets the loaded texture
  57525. */
  57526. texture: Texture;
  57527. /**
  57528. * Callback called when the task is successful
  57529. */
  57530. onSuccess: (task: TextureAssetTask) => void;
  57531. /**
  57532. * Callback called when the task is successful
  57533. */
  57534. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57535. /**
  57536. * Creates a new TextureAssetTask object
  57537. * @param name defines the name of the task
  57538. * @param url defines the location of the file to load
  57539. * @param noMipmap defines if mipmap should not be generated (default is false)
  57540. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57541. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57542. */
  57543. constructor(
  57544. /**
  57545. * Defines the name of the task
  57546. */
  57547. name: string,
  57548. /**
  57549. * Defines the location of the file to load
  57550. */
  57551. url: string,
  57552. /**
  57553. * Defines if mipmap should not be generated (default is false)
  57554. */
  57555. noMipmap?: boolean | undefined,
  57556. /**
  57557. * Defines if texture must be inverted on Y axis (default is false)
  57558. */
  57559. invertY?: boolean | undefined,
  57560. /**
  57561. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57562. */
  57563. samplingMode?: number);
  57564. /**
  57565. * Execute the current task
  57566. * @param scene defines the scene where you want your assets to be loaded
  57567. * @param onSuccess is a callback called when the task is successfully executed
  57568. * @param onError is a callback called if an error occurs
  57569. */
  57570. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57571. }
  57572. /**
  57573. * Define a task used by AssetsManager to load cube textures
  57574. */
  57575. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57576. /**
  57577. * Defines the name of the task
  57578. */
  57579. name: string;
  57580. /**
  57581. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57582. */
  57583. url: string;
  57584. /**
  57585. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57586. */
  57587. extensions?: string[] | undefined;
  57588. /**
  57589. * Defines if mipmaps should not be generated (default is false)
  57590. */
  57591. noMipmap?: boolean | undefined;
  57592. /**
  57593. * Defines the explicit list of files (undefined by default)
  57594. */
  57595. files?: string[] | undefined;
  57596. /**
  57597. * Gets the loaded texture
  57598. */
  57599. texture: CubeTexture;
  57600. /**
  57601. * Callback called when the task is successful
  57602. */
  57603. onSuccess: (task: CubeTextureAssetTask) => void;
  57604. /**
  57605. * Callback called when the task is successful
  57606. */
  57607. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57608. /**
  57609. * Creates a new CubeTextureAssetTask
  57610. * @param name defines the name of the task
  57611. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57612. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57613. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57614. * @param files defines the explicit list of files (undefined by default)
  57615. */
  57616. constructor(
  57617. /**
  57618. * Defines the name of the task
  57619. */
  57620. name: string,
  57621. /**
  57622. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57623. */
  57624. url: string,
  57625. /**
  57626. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57627. */
  57628. extensions?: string[] | undefined,
  57629. /**
  57630. * Defines if mipmaps should not be generated (default is false)
  57631. */
  57632. noMipmap?: boolean | undefined,
  57633. /**
  57634. * Defines the explicit list of files (undefined by default)
  57635. */
  57636. files?: string[] | undefined);
  57637. /**
  57638. * Execute the current task
  57639. * @param scene defines the scene where you want your assets to be loaded
  57640. * @param onSuccess is a callback called when the task is successfully executed
  57641. * @param onError is a callback called if an error occurs
  57642. */
  57643. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57644. }
  57645. /**
  57646. * Define a task used by AssetsManager to load HDR cube textures
  57647. */
  57648. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57649. /**
  57650. * Defines the name of the task
  57651. */
  57652. name: string;
  57653. /**
  57654. * Defines the location of the file to load
  57655. */
  57656. url: string;
  57657. /**
  57658. * Defines the desired size (the more it increases the longer the generation will be)
  57659. */
  57660. size: number;
  57661. /**
  57662. * Defines if mipmaps should not be generated (default is false)
  57663. */
  57664. noMipmap: boolean;
  57665. /**
  57666. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57667. */
  57668. generateHarmonics: boolean;
  57669. /**
  57670. * 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)
  57671. */
  57672. gammaSpace: boolean;
  57673. /**
  57674. * Internal Use Only
  57675. */
  57676. reserved: boolean;
  57677. /**
  57678. * Gets the loaded texture
  57679. */
  57680. texture: HDRCubeTexture;
  57681. /**
  57682. * Callback called when the task is successful
  57683. */
  57684. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57685. /**
  57686. * Callback called when the task is successful
  57687. */
  57688. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57689. /**
  57690. * Creates a new HDRCubeTextureAssetTask object
  57691. * @param name defines the name of the task
  57692. * @param url defines the location of the file to load
  57693. * @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.
  57694. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57695. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57696. * @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)
  57697. * @param reserved Internal use only
  57698. */
  57699. constructor(
  57700. /**
  57701. * Defines the name of the task
  57702. */
  57703. name: string,
  57704. /**
  57705. * Defines the location of the file to load
  57706. */
  57707. url: string,
  57708. /**
  57709. * Defines the desired size (the more it increases the longer the generation will be)
  57710. */
  57711. size: number,
  57712. /**
  57713. * Defines if mipmaps should not be generated (default is false)
  57714. */
  57715. noMipmap?: boolean,
  57716. /**
  57717. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57718. */
  57719. generateHarmonics?: boolean,
  57720. /**
  57721. * 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)
  57722. */
  57723. gammaSpace?: boolean,
  57724. /**
  57725. * Internal Use Only
  57726. */
  57727. reserved?: boolean);
  57728. /**
  57729. * Execute the current task
  57730. * @param scene defines the scene where you want your assets to be loaded
  57731. * @param onSuccess is a callback called when the task is successfully executed
  57732. * @param onError is a callback called if an error occurs
  57733. */
  57734. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57735. }
  57736. /**
  57737. * Define a task used by AssetsManager to load Equirectangular cube textures
  57738. */
  57739. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57740. /**
  57741. * Defines the name of the task
  57742. */
  57743. name: string;
  57744. /**
  57745. * Defines the location of the file to load
  57746. */
  57747. url: string;
  57748. /**
  57749. * Defines the desired size (the more it increases the longer the generation will be)
  57750. */
  57751. size: number;
  57752. /**
  57753. * Defines if mipmaps should not be generated (default is false)
  57754. */
  57755. noMipmap: boolean;
  57756. /**
  57757. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57758. * but the standard material would require them in Gamma space) (default is true)
  57759. */
  57760. gammaSpace: boolean;
  57761. /**
  57762. * Gets the loaded texture
  57763. */
  57764. texture: EquiRectangularCubeTexture;
  57765. /**
  57766. * Callback called when the task is successful
  57767. */
  57768. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57769. /**
  57770. * Callback called when the task is successful
  57771. */
  57772. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57773. /**
  57774. * Creates a new EquiRectangularCubeTextureAssetTask object
  57775. * @param name defines the name of the task
  57776. * @param url defines the location of the file to load
  57777. * @param size defines the desired size (the more it increases the longer the generation will be)
  57778. * If the size is omitted this implies you are using a preprocessed cubemap.
  57779. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57780. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57781. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57782. * (default is true)
  57783. */
  57784. constructor(
  57785. /**
  57786. * Defines the name of the task
  57787. */
  57788. name: string,
  57789. /**
  57790. * Defines the location of the file to load
  57791. */
  57792. url: string,
  57793. /**
  57794. * Defines the desired size (the more it increases the longer the generation will be)
  57795. */
  57796. size: number,
  57797. /**
  57798. * Defines if mipmaps should not be generated (default is false)
  57799. */
  57800. noMipmap?: boolean,
  57801. /**
  57802. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57803. * but the standard material would require them in Gamma space) (default is true)
  57804. */
  57805. gammaSpace?: boolean);
  57806. /**
  57807. * Execute the current task
  57808. * @param scene defines the scene where you want your assets to be loaded
  57809. * @param onSuccess is a callback called when the task is successfully executed
  57810. * @param onError is a callback called if an error occurs
  57811. */
  57812. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57813. }
  57814. /**
  57815. * This class can be used to easily import assets into a scene
  57816. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57817. */
  57818. export class AssetsManager {
  57819. private _scene;
  57820. private _isLoading;
  57821. protected _tasks: AbstractAssetTask[];
  57822. protected _waitingTasksCount: number;
  57823. protected _totalTasksCount: number;
  57824. /**
  57825. * Callback called when all tasks are processed
  57826. */
  57827. onFinish: (tasks: AbstractAssetTask[]) => void;
  57828. /**
  57829. * Callback called when a task is successful
  57830. */
  57831. onTaskSuccess: (task: AbstractAssetTask) => void;
  57832. /**
  57833. * Callback called when a task had an error
  57834. */
  57835. onTaskError: (task: AbstractAssetTask) => void;
  57836. /**
  57837. * Callback called when a task is done (whatever the result is)
  57838. */
  57839. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57840. /**
  57841. * Observable called when all tasks are processed
  57842. */
  57843. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57844. /**
  57845. * Observable called when a task had an error
  57846. */
  57847. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57848. /**
  57849. * Observable called when all tasks were executed
  57850. */
  57851. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57852. /**
  57853. * Observable called when a task is done (whatever the result is)
  57854. */
  57855. onProgressObservable: Observable<IAssetsProgressEvent>;
  57856. /**
  57857. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57858. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57859. */
  57860. useDefaultLoadingScreen: boolean;
  57861. /**
  57862. * Creates a new AssetsManager
  57863. * @param scene defines the scene to work on
  57864. */
  57865. constructor(scene: Scene);
  57866. /**
  57867. * Add a MeshAssetTask to the list of active tasks
  57868. * @param taskName defines the name of the new task
  57869. * @param meshesNames defines the name of meshes to load
  57870. * @param rootUrl defines the root url to use to locate files
  57871. * @param sceneFilename defines the filename of the scene file
  57872. * @returns a new MeshAssetTask object
  57873. */
  57874. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57875. /**
  57876. * Add a TextFileAssetTask to the list of active tasks
  57877. * @param taskName defines the name of the new task
  57878. * @param url defines the url of the file to load
  57879. * @returns a new TextFileAssetTask object
  57880. */
  57881. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57882. /**
  57883. * Add a BinaryFileAssetTask to the list of active tasks
  57884. * @param taskName defines the name of the new task
  57885. * @param url defines the url of the file to load
  57886. * @returns a new BinaryFileAssetTask object
  57887. */
  57888. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57889. /**
  57890. * Add a ImageAssetTask to the list of active tasks
  57891. * @param taskName defines the name of the new task
  57892. * @param url defines the url of the file to load
  57893. * @returns a new ImageAssetTask object
  57894. */
  57895. addImageTask(taskName: string, url: string): ImageAssetTask;
  57896. /**
  57897. * Add a TextureAssetTask to the list of active tasks
  57898. * @param taskName defines the name of the new task
  57899. * @param url defines the url of the file to load
  57900. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57901. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57902. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57903. * @returns a new TextureAssetTask object
  57904. */
  57905. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57906. /**
  57907. * Add a CubeTextureAssetTask to the list of active tasks
  57908. * @param taskName defines the name of the new task
  57909. * @param url defines the url of the file to load
  57910. * @param extensions defines the extension to use to load the cube map (can be null)
  57911. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57912. * @param files defines the list of files to load (can be null)
  57913. * @returns a new CubeTextureAssetTask object
  57914. */
  57915. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57916. /**
  57917. *
  57918. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57919. * @param taskName defines the name of the new task
  57920. * @param url defines the url of the file to load
  57921. * @param size defines the size you want for the cubemap (can be null)
  57922. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57923. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57924. * @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)
  57925. * @param reserved Internal use only
  57926. * @returns a new HDRCubeTextureAssetTask object
  57927. */
  57928. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57929. /**
  57930. *
  57931. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57932. * @param taskName defines the name of the new task
  57933. * @param url defines the url of the file to load
  57934. * @param size defines the size you want for the cubemap (can be null)
  57935. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57936. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57937. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57938. * @returns a new EquiRectangularCubeTextureAssetTask object
  57939. */
  57940. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  57941. /**
  57942. * Remove a task from the assets manager.
  57943. * @param task the task to remove
  57944. */
  57945. removeTask(task: AbstractAssetTask): void;
  57946. private _decreaseWaitingTasksCount;
  57947. private _runTask;
  57948. /**
  57949. * Reset the AssetsManager and remove all tasks
  57950. * @return the current instance of the AssetsManager
  57951. */
  57952. reset(): AssetsManager;
  57953. /**
  57954. * Start the loading process
  57955. * @return the current instance of the AssetsManager
  57956. */
  57957. load(): AssetsManager;
  57958. /**
  57959. * Start the loading process as an async operation
  57960. * @return a promise returning the list of failed tasks
  57961. */
  57962. loadAsync(): Promise<void>;
  57963. }
  57964. }
  57965. declare module "babylonjs/Misc/deferred" {
  57966. /**
  57967. * Wrapper class for promise with external resolve and reject.
  57968. */
  57969. export class Deferred<T> {
  57970. /**
  57971. * The promise associated with this deferred object.
  57972. */
  57973. readonly promise: Promise<T>;
  57974. private _resolve;
  57975. private _reject;
  57976. /**
  57977. * The resolve method of the promise associated with this deferred object.
  57978. */
  57979. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57980. /**
  57981. * The reject method of the promise associated with this deferred object.
  57982. */
  57983. readonly reject: (reason?: any) => void;
  57984. /**
  57985. * Constructor for this deferred object.
  57986. */
  57987. constructor();
  57988. }
  57989. }
  57990. declare module "babylonjs/Misc/meshExploder" {
  57991. import { Mesh } from "babylonjs/Meshes/mesh";
  57992. /**
  57993. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57994. */
  57995. export class MeshExploder {
  57996. private _centerMesh;
  57997. private _meshes;
  57998. private _meshesOrigins;
  57999. private _toCenterVectors;
  58000. private _scaledDirection;
  58001. private _newPosition;
  58002. private _centerPosition;
  58003. /**
  58004. * Explodes meshes from a center mesh.
  58005. * @param meshes The meshes to explode.
  58006. * @param centerMesh The mesh to be center of explosion.
  58007. */
  58008. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58009. private _setCenterMesh;
  58010. /**
  58011. * Get class name
  58012. * @returns "MeshExploder"
  58013. */
  58014. getClassName(): string;
  58015. /**
  58016. * "Exploded meshes"
  58017. * @returns Array of meshes with the centerMesh at index 0.
  58018. */
  58019. getMeshes(): Array<Mesh>;
  58020. /**
  58021. * Explodes meshes giving a specific direction
  58022. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58023. */
  58024. explode(direction?: number): void;
  58025. }
  58026. }
  58027. declare module "babylonjs/Misc/filesInput" {
  58028. import { Engine } from "babylonjs/Engines/engine";
  58029. import { Scene } from "babylonjs/scene";
  58030. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58031. /**
  58032. * Class used to help managing file picking and drag'n'drop
  58033. */
  58034. export class FilesInput {
  58035. /**
  58036. * List of files ready to be loaded
  58037. */
  58038. static readonly FilesToLoad: {
  58039. [key: string]: File;
  58040. };
  58041. /**
  58042. * Callback called when a file is processed
  58043. */
  58044. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58045. private _engine;
  58046. private _currentScene;
  58047. private _sceneLoadedCallback;
  58048. private _progressCallback;
  58049. private _additionalRenderLoopLogicCallback;
  58050. private _textureLoadingCallback;
  58051. private _startingProcessingFilesCallback;
  58052. private _onReloadCallback;
  58053. private _errorCallback;
  58054. private _elementToMonitor;
  58055. private _sceneFileToLoad;
  58056. private _filesToLoad;
  58057. /**
  58058. * Creates a new FilesInput
  58059. * @param engine defines the rendering engine
  58060. * @param scene defines the hosting scene
  58061. * @param sceneLoadedCallback callback called when scene is loaded
  58062. * @param progressCallback callback called to track progress
  58063. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58064. * @param textureLoadingCallback callback called when a texture is loading
  58065. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58066. * @param onReloadCallback callback called when a reload is requested
  58067. * @param errorCallback callback call if an error occurs
  58068. */
  58069. 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);
  58070. private _dragEnterHandler;
  58071. private _dragOverHandler;
  58072. private _dropHandler;
  58073. /**
  58074. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58075. * @param elementToMonitor defines the DOM element to track
  58076. */
  58077. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58078. /**
  58079. * Release all associated resources
  58080. */
  58081. dispose(): void;
  58082. private renderFunction;
  58083. private drag;
  58084. private drop;
  58085. private _traverseFolder;
  58086. private _processFiles;
  58087. /**
  58088. * Load files from a drop event
  58089. * @param event defines the drop event to use as source
  58090. */
  58091. loadFiles(event: any): void;
  58092. private _processReload;
  58093. /**
  58094. * Reload the current scene from the loaded files
  58095. */
  58096. reload(): void;
  58097. }
  58098. }
  58099. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58100. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58101. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58102. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58103. }
  58104. declare module "babylonjs/Misc/sceneOptimizer" {
  58105. import { Scene, IDisposable } from "babylonjs/scene";
  58106. import { Observable } from "babylonjs/Misc/observable";
  58107. /**
  58108. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58109. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58110. */
  58111. export class SceneOptimization {
  58112. /**
  58113. * Defines the priority of this optimization (0 by default which means first in the list)
  58114. */
  58115. priority: number;
  58116. /**
  58117. * Gets a string describing the action executed by the current optimization
  58118. * @returns description string
  58119. */
  58120. getDescription(): string;
  58121. /**
  58122. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58123. * @param scene defines the current scene where to apply this optimization
  58124. * @param optimizer defines the current optimizer
  58125. * @returns true if everything that can be done was applied
  58126. */
  58127. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58128. /**
  58129. * Creates the SceneOptimization object
  58130. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58131. * @param desc defines the description associated with the optimization
  58132. */
  58133. constructor(
  58134. /**
  58135. * Defines the priority of this optimization (0 by default which means first in the list)
  58136. */
  58137. priority?: number);
  58138. }
  58139. /**
  58140. * Defines an optimization used to reduce the size of render target textures
  58141. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58142. */
  58143. export class TextureOptimization extends SceneOptimization {
  58144. /**
  58145. * Defines the priority of this optimization (0 by default which means first in the list)
  58146. */
  58147. priority: number;
  58148. /**
  58149. * 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
  58150. */
  58151. maximumSize: number;
  58152. /**
  58153. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58154. */
  58155. step: number;
  58156. /**
  58157. * Gets a string describing the action executed by the current optimization
  58158. * @returns description string
  58159. */
  58160. getDescription(): string;
  58161. /**
  58162. * Creates the TextureOptimization object
  58163. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58164. * @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
  58165. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58166. */
  58167. constructor(
  58168. /**
  58169. * Defines the priority of this optimization (0 by default which means first in the list)
  58170. */
  58171. priority?: number,
  58172. /**
  58173. * 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
  58174. */
  58175. maximumSize?: number,
  58176. /**
  58177. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58178. */
  58179. step?: number);
  58180. /**
  58181. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58182. * @param scene defines the current scene where to apply this optimization
  58183. * @param optimizer defines the current optimizer
  58184. * @returns true if everything that can be done was applied
  58185. */
  58186. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58187. }
  58188. /**
  58189. * Defines an optimization used to increase or decrease the rendering resolution
  58190. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58191. */
  58192. export class HardwareScalingOptimization extends SceneOptimization {
  58193. /**
  58194. * Defines the priority of this optimization (0 by default which means first in the list)
  58195. */
  58196. priority: number;
  58197. /**
  58198. * Defines the maximum scale to use (2 by default)
  58199. */
  58200. maximumScale: number;
  58201. /**
  58202. * Defines the step to use between two passes (0.5 by default)
  58203. */
  58204. step: number;
  58205. private _currentScale;
  58206. private _directionOffset;
  58207. /**
  58208. * Gets a string describing the action executed by the current optimization
  58209. * @return description string
  58210. */
  58211. getDescription(): string;
  58212. /**
  58213. * Creates the HardwareScalingOptimization object
  58214. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58215. * @param maximumScale defines the maximum scale to use (2 by default)
  58216. * @param step defines the step to use between two passes (0.5 by default)
  58217. */
  58218. constructor(
  58219. /**
  58220. * Defines the priority of this optimization (0 by default which means first in the list)
  58221. */
  58222. priority?: number,
  58223. /**
  58224. * Defines the maximum scale to use (2 by default)
  58225. */
  58226. maximumScale?: number,
  58227. /**
  58228. * Defines the step to use between two passes (0.5 by default)
  58229. */
  58230. step?: number);
  58231. /**
  58232. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58233. * @param scene defines the current scene where to apply this optimization
  58234. * @param optimizer defines the current optimizer
  58235. * @returns true if everything that can be done was applied
  58236. */
  58237. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58238. }
  58239. /**
  58240. * Defines an optimization used to remove shadows
  58241. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58242. */
  58243. export class ShadowsOptimization extends SceneOptimization {
  58244. /**
  58245. * Gets a string describing the action executed by the current optimization
  58246. * @return description string
  58247. */
  58248. getDescription(): string;
  58249. /**
  58250. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58251. * @param scene defines the current scene where to apply this optimization
  58252. * @param optimizer defines the current optimizer
  58253. * @returns true if everything that can be done was applied
  58254. */
  58255. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58256. }
  58257. /**
  58258. * Defines an optimization used to turn post-processes off
  58259. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58260. */
  58261. export class PostProcessesOptimization extends SceneOptimization {
  58262. /**
  58263. * Gets a string describing the action executed by the current optimization
  58264. * @return description string
  58265. */
  58266. getDescription(): string;
  58267. /**
  58268. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58269. * @param scene defines the current scene where to apply this optimization
  58270. * @param optimizer defines the current optimizer
  58271. * @returns true if everything that can be done was applied
  58272. */
  58273. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58274. }
  58275. /**
  58276. * Defines an optimization used to turn lens flares off
  58277. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58278. */
  58279. export class LensFlaresOptimization extends SceneOptimization {
  58280. /**
  58281. * Gets a string describing the action executed by the current optimization
  58282. * @return description string
  58283. */
  58284. getDescription(): string;
  58285. /**
  58286. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58287. * @param scene defines the current scene where to apply this optimization
  58288. * @param optimizer defines the current optimizer
  58289. * @returns true if everything that can be done was applied
  58290. */
  58291. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58292. }
  58293. /**
  58294. * Defines an optimization based on user defined callback.
  58295. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58296. */
  58297. export class CustomOptimization extends SceneOptimization {
  58298. /**
  58299. * Callback called to apply the custom optimization.
  58300. */
  58301. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58302. /**
  58303. * Callback called to get custom description
  58304. */
  58305. onGetDescription: () => string;
  58306. /**
  58307. * Gets a string describing the action executed by the current optimization
  58308. * @returns description string
  58309. */
  58310. getDescription(): string;
  58311. /**
  58312. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58313. * @param scene defines the current scene where to apply this optimization
  58314. * @param optimizer defines the current optimizer
  58315. * @returns true if everything that can be done was applied
  58316. */
  58317. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58318. }
  58319. /**
  58320. * Defines an optimization used to turn particles off
  58321. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58322. */
  58323. export class ParticlesOptimization extends SceneOptimization {
  58324. /**
  58325. * Gets a string describing the action executed by the current optimization
  58326. * @return description string
  58327. */
  58328. getDescription(): string;
  58329. /**
  58330. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58331. * @param scene defines the current scene where to apply this optimization
  58332. * @param optimizer defines the current optimizer
  58333. * @returns true if everything that can be done was applied
  58334. */
  58335. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58336. }
  58337. /**
  58338. * Defines an optimization used to turn render targets off
  58339. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58340. */
  58341. export class RenderTargetsOptimization extends SceneOptimization {
  58342. /**
  58343. * Gets a string describing the action executed by the current optimization
  58344. * @return description string
  58345. */
  58346. getDescription(): string;
  58347. /**
  58348. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58349. * @param scene defines the current scene where to apply this optimization
  58350. * @param optimizer defines the current optimizer
  58351. * @returns true if everything that can be done was applied
  58352. */
  58353. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58354. }
  58355. /**
  58356. * Defines an optimization used to merge meshes with compatible materials
  58357. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58358. */
  58359. export class MergeMeshesOptimization extends SceneOptimization {
  58360. private static _UpdateSelectionTree;
  58361. /**
  58362. * Gets or sets a boolean which defines if optimization octree has to be updated
  58363. */
  58364. /**
  58365. * Gets or sets a boolean which defines if optimization octree has to be updated
  58366. */
  58367. static UpdateSelectionTree: boolean;
  58368. /**
  58369. * Gets a string describing the action executed by the current optimization
  58370. * @return description string
  58371. */
  58372. getDescription(): string;
  58373. private _canBeMerged;
  58374. /**
  58375. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58376. * @param scene defines the current scene where to apply this optimization
  58377. * @param optimizer defines the current optimizer
  58378. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58379. * @returns true if everything that can be done was applied
  58380. */
  58381. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58382. }
  58383. /**
  58384. * Defines a list of options used by SceneOptimizer
  58385. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58386. */
  58387. export class SceneOptimizerOptions {
  58388. /**
  58389. * Defines the target frame rate to reach (60 by default)
  58390. */
  58391. targetFrameRate: number;
  58392. /**
  58393. * Defines the interval between two checkes (2000ms by default)
  58394. */
  58395. trackerDuration: number;
  58396. /**
  58397. * Gets the list of optimizations to apply
  58398. */
  58399. optimizations: SceneOptimization[];
  58400. /**
  58401. * Creates a new list of options used by SceneOptimizer
  58402. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58403. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58404. */
  58405. constructor(
  58406. /**
  58407. * Defines the target frame rate to reach (60 by default)
  58408. */
  58409. targetFrameRate?: number,
  58410. /**
  58411. * Defines the interval between two checkes (2000ms by default)
  58412. */
  58413. trackerDuration?: number);
  58414. /**
  58415. * Add a new optimization
  58416. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58417. * @returns the current SceneOptimizerOptions
  58418. */
  58419. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58420. /**
  58421. * Add a new custom optimization
  58422. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58423. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58424. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58425. * @returns the current SceneOptimizerOptions
  58426. */
  58427. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58428. /**
  58429. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58430. * @param targetFrameRate defines the target frame rate (60 by default)
  58431. * @returns a SceneOptimizerOptions object
  58432. */
  58433. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58434. /**
  58435. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58436. * @param targetFrameRate defines the target frame rate (60 by default)
  58437. * @returns a SceneOptimizerOptions object
  58438. */
  58439. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58440. /**
  58441. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58442. * @param targetFrameRate defines the target frame rate (60 by default)
  58443. * @returns a SceneOptimizerOptions object
  58444. */
  58445. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58446. }
  58447. /**
  58448. * Class used to run optimizations in order to reach a target frame rate
  58449. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58450. */
  58451. export class SceneOptimizer implements IDisposable {
  58452. private _isRunning;
  58453. private _options;
  58454. private _scene;
  58455. private _currentPriorityLevel;
  58456. private _targetFrameRate;
  58457. private _trackerDuration;
  58458. private _currentFrameRate;
  58459. private _sceneDisposeObserver;
  58460. private _improvementMode;
  58461. /**
  58462. * Defines an observable called when the optimizer reaches the target frame rate
  58463. */
  58464. onSuccessObservable: Observable<SceneOptimizer>;
  58465. /**
  58466. * Defines an observable called when the optimizer enables an optimization
  58467. */
  58468. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58469. /**
  58470. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58471. */
  58472. onFailureObservable: Observable<SceneOptimizer>;
  58473. /**
  58474. * Gets a boolean indicating if the optimizer is in improvement mode
  58475. */
  58476. readonly isInImprovementMode: boolean;
  58477. /**
  58478. * Gets the current priority level (0 at start)
  58479. */
  58480. readonly currentPriorityLevel: number;
  58481. /**
  58482. * Gets the current frame rate checked by the SceneOptimizer
  58483. */
  58484. readonly currentFrameRate: number;
  58485. /**
  58486. * Gets or sets the current target frame rate (60 by default)
  58487. */
  58488. /**
  58489. * Gets or sets the current target frame rate (60 by default)
  58490. */
  58491. targetFrameRate: number;
  58492. /**
  58493. * Gets or sets the current interval between two checks (every 2000ms by default)
  58494. */
  58495. /**
  58496. * Gets or sets the current interval between two checks (every 2000ms by default)
  58497. */
  58498. trackerDuration: number;
  58499. /**
  58500. * Gets the list of active optimizations
  58501. */
  58502. readonly optimizations: SceneOptimization[];
  58503. /**
  58504. * Creates a new SceneOptimizer
  58505. * @param scene defines the scene to work on
  58506. * @param options defines the options to use with the SceneOptimizer
  58507. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58508. * @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)
  58509. */
  58510. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58511. /**
  58512. * Stops the current optimizer
  58513. */
  58514. stop(): void;
  58515. /**
  58516. * Reset the optimizer to initial step (current priority level = 0)
  58517. */
  58518. reset(): void;
  58519. /**
  58520. * Start the optimizer. By default it will try to reach a specific framerate
  58521. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58522. */
  58523. start(): void;
  58524. private _checkCurrentState;
  58525. /**
  58526. * Release all resources
  58527. */
  58528. dispose(): void;
  58529. /**
  58530. * Helper function to create a SceneOptimizer with one single line of code
  58531. * @param scene defines the scene to work on
  58532. * @param options defines the options to use with the SceneOptimizer
  58533. * @param onSuccess defines a callback to call on success
  58534. * @param onFailure defines a callback to call on failure
  58535. * @returns the new SceneOptimizer object
  58536. */
  58537. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58538. }
  58539. }
  58540. declare module "babylonjs/Misc/sceneSerializer" {
  58541. import { Scene } from "babylonjs/scene";
  58542. /**
  58543. * Class used to serialize a scene into a string
  58544. */
  58545. export class SceneSerializer {
  58546. /**
  58547. * Clear cache used by a previous serialization
  58548. */
  58549. static ClearCache(): void;
  58550. /**
  58551. * Serialize a scene into a JSON compatible object
  58552. * @param scene defines the scene to serialize
  58553. * @returns a JSON compatible object
  58554. */
  58555. static Serialize(scene: Scene): any;
  58556. /**
  58557. * Serialize a mesh into a JSON compatible object
  58558. * @param toSerialize defines the mesh to serialize
  58559. * @param withParents defines if parents must be serialized as well
  58560. * @param withChildren defines if children must be serialized as well
  58561. * @returns a JSON compatible object
  58562. */
  58563. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58564. }
  58565. }
  58566. declare module "babylonjs/Misc/textureTools" {
  58567. import { Texture } from "babylonjs/Materials/Textures/texture";
  58568. /**
  58569. * Class used to host texture specific utilities
  58570. */
  58571. export class TextureTools {
  58572. /**
  58573. * Uses the GPU to create a copy texture rescaled at a given size
  58574. * @param texture Texture to copy from
  58575. * @param width defines the desired width
  58576. * @param height defines the desired height
  58577. * @param useBilinearMode defines if bilinear mode has to be used
  58578. * @return the generated texture
  58579. */
  58580. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58581. }
  58582. }
  58583. declare module "babylonjs/Misc/videoRecorder" {
  58584. import { Nullable } from "babylonjs/types";
  58585. import { Engine } from "babylonjs/Engines/engine";
  58586. /**
  58587. * This represents the different options avilable for the video capture.
  58588. */
  58589. export interface VideoRecorderOptions {
  58590. /** Defines the mime type of the video */
  58591. mimeType: string;
  58592. /** Defines the video the video should be recorded at */
  58593. fps: number;
  58594. /** Defines the chunk size for the recording data */
  58595. recordChunckSize: number;
  58596. /** The audio tracks to attach to the record */
  58597. audioTracks?: MediaStreamTrack[];
  58598. }
  58599. /**
  58600. * This can helps recording videos from BabylonJS.
  58601. * This is based on the available WebRTC functionalities of the browser.
  58602. *
  58603. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58604. */
  58605. export class VideoRecorder {
  58606. private static readonly _defaultOptions;
  58607. /**
  58608. * Returns wehther or not the VideoRecorder is available in your browser.
  58609. * @param engine Defines the Babylon Engine to check the support for
  58610. * @returns true if supported otherwise false
  58611. */
  58612. static IsSupported(engine: Engine): boolean;
  58613. private readonly _options;
  58614. private _canvas;
  58615. private _mediaRecorder;
  58616. private _recordedChunks;
  58617. private _fileName;
  58618. private _resolve;
  58619. private _reject;
  58620. /**
  58621. * True wether a recording is already in progress.
  58622. */
  58623. readonly isRecording: boolean;
  58624. /**
  58625. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58626. * a video file.
  58627. * @param engine Defines the BabylonJS Engine you wish to record
  58628. * @param options Defines options that can be used to customized the capture
  58629. */
  58630. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58631. /**
  58632. * Stops the current recording before the default capture timeout passed in the startRecording
  58633. * functions.
  58634. */
  58635. stopRecording(): void;
  58636. /**
  58637. * Starts recording the canvas for a max duration specified in parameters.
  58638. * @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.
  58639. * @param maxDuration Defines the maximum recording time in seconds.
  58640. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58641. * @return a promise callback at the end of the recording with the video data in Blob.
  58642. */
  58643. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58644. /**
  58645. * Releases internal resources used during the recording.
  58646. */
  58647. dispose(): void;
  58648. private _handleDataAvailable;
  58649. private _handleError;
  58650. private _handleStop;
  58651. }
  58652. }
  58653. declare module "babylonjs/Misc/screenshotTools" {
  58654. import { Camera } from "babylonjs/Cameras/camera";
  58655. import { Engine } from "babylonjs/Engines/engine";
  58656. /**
  58657. * Class containing a set of static utilities functions for screenshots
  58658. */
  58659. export class ScreenshotTools {
  58660. /**
  58661. * Captures a screenshot of the current rendering
  58662. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58663. * @param engine defines the rendering engine
  58664. * @param camera defines the source camera
  58665. * @param size This parameter can be set to a single number or to an object with the
  58666. * following (optional) properties: precision, width, height. If a single number is passed,
  58667. * it will be used for both width and height. If an object is passed, the screenshot size
  58668. * will be derived from the parameters. The precision property is a multiplier allowing
  58669. * rendering at a higher or lower resolution
  58670. * @param successCallback defines the callback receives a single parameter which contains the
  58671. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58672. * src parameter of an <img> to display it
  58673. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58674. * Check your browser for supported MIME types
  58675. */
  58676. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58677. /**
  58678. * Generates an image screenshot from the specified camera.
  58679. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58680. * @param engine The engine to use for rendering
  58681. * @param camera The camera to use for rendering
  58682. * @param size This parameter can be set to a single number or to an object with the
  58683. * following (optional) properties: precision, width, height. If a single number is passed,
  58684. * it will be used for both width and height. If an object is passed, the screenshot size
  58685. * will be derived from the parameters. The precision property is a multiplier allowing
  58686. * rendering at a higher or lower resolution
  58687. * @param successCallback The callback receives a single parameter which contains the
  58688. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58689. * src parameter of an <img> to display it
  58690. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58691. * Check your browser for supported MIME types
  58692. * @param samples Texture samples (default: 1)
  58693. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58694. * @param fileName A name for for the downloaded file.
  58695. */
  58696. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58697. }
  58698. }
  58699. declare module "babylonjs/Misc/index" {
  58700. export * from "babylonjs/Misc/andOrNotEvaluator";
  58701. export * from "babylonjs/Misc/assetsManager";
  58702. export * from "babylonjs/Misc/dds";
  58703. export * from "babylonjs/Misc/decorators";
  58704. export * from "babylonjs/Misc/deferred";
  58705. export * from "babylonjs/Misc/environmentTextureTools";
  58706. export * from "babylonjs/Misc/meshExploder";
  58707. export * from "babylonjs/Misc/filesInput";
  58708. export * from "babylonjs/Misc/HighDynamicRange/index";
  58709. export * from "babylonjs/Misc/khronosTextureContainer";
  58710. export * from "babylonjs/Misc/observable";
  58711. export * from "babylonjs/Misc/performanceMonitor";
  58712. export * from "babylonjs/Misc/promise";
  58713. export * from "babylonjs/Misc/sceneOptimizer";
  58714. export * from "babylonjs/Misc/sceneSerializer";
  58715. export * from "babylonjs/Misc/smartArray";
  58716. export * from "babylonjs/Misc/stringDictionary";
  58717. export * from "babylonjs/Misc/tags";
  58718. export * from "babylonjs/Misc/textureTools";
  58719. export * from "babylonjs/Misc/tga";
  58720. export * from "babylonjs/Misc/tools";
  58721. export * from "babylonjs/Misc/videoRecorder";
  58722. export * from "babylonjs/Misc/virtualJoystick";
  58723. export * from "babylonjs/Misc/workerPool";
  58724. export * from "babylonjs/Misc/logger";
  58725. export * from "babylonjs/Misc/typeStore";
  58726. export * from "babylonjs/Misc/filesInputStore";
  58727. export * from "babylonjs/Misc/deepCopier";
  58728. export * from "babylonjs/Misc/pivotTools";
  58729. export * from "babylonjs/Misc/precisionDate";
  58730. export * from "babylonjs/Misc/screenshotTools";
  58731. export * from "babylonjs/Misc/typeStore";
  58732. export * from "babylonjs/Misc/webRequest";
  58733. export * from "babylonjs/Misc/iInspectable";
  58734. }
  58735. declare module "babylonjs/index" {
  58736. export * from "babylonjs/abstractScene";
  58737. export * from "babylonjs/Actions/index";
  58738. export * from "babylonjs/Animations/index";
  58739. export * from "babylonjs/assetContainer";
  58740. export * from "babylonjs/Audio/index";
  58741. export * from "babylonjs/Behaviors/index";
  58742. export * from "babylonjs/Bones/index";
  58743. export * from "babylonjs/Cameras/index";
  58744. export * from "babylonjs/Collisions/index";
  58745. export * from "babylonjs/Culling/index";
  58746. export * from "babylonjs/Debug/index";
  58747. export * from "babylonjs/Engines/index";
  58748. export * from "babylonjs/Events/index";
  58749. export * from "babylonjs/Gamepads/index";
  58750. export * from "babylonjs/Gizmos/index";
  58751. export * from "babylonjs/Helpers/index";
  58752. export * from "babylonjs/Instrumentation/index";
  58753. export * from "babylonjs/Layers/index";
  58754. export * from "babylonjs/LensFlares/index";
  58755. export * from "babylonjs/Lights/index";
  58756. export * from "babylonjs/Loading/index";
  58757. export * from "babylonjs/Materials/index";
  58758. export * from "babylonjs/Maths/index";
  58759. export * from "babylonjs/Meshes/index";
  58760. export * from "babylonjs/Morph/index";
  58761. export * from "babylonjs/node";
  58762. export * from "babylonjs/Offline/index";
  58763. export * from "babylonjs/Particles/index";
  58764. export * from "babylonjs/Physics/index";
  58765. export * from "babylonjs/PostProcesses/index";
  58766. export * from "babylonjs/Probes/index";
  58767. export * from "babylonjs/Rendering/index";
  58768. export * from "babylonjs/scene";
  58769. export * from "babylonjs/sceneComponent";
  58770. export * from "babylonjs/Sprites/index";
  58771. export * from "babylonjs/States/index";
  58772. export * from "babylonjs/Misc/index";
  58773. export * from "babylonjs/types";
  58774. }
  58775. declare module "babylonjs/Animations/pathCursor" {
  58776. import { Path2, Vector3 } from "babylonjs/Maths/math";
  58777. /**
  58778. * A cursor which tracks a point on a path
  58779. */
  58780. export class PathCursor {
  58781. private path;
  58782. /**
  58783. * Stores path cursor callbacks for when an onchange event is triggered
  58784. */
  58785. private _onchange;
  58786. /**
  58787. * The value of the path cursor
  58788. */
  58789. value: number;
  58790. /**
  58791. * The animation array of the path cursor
  58792. */
  58793. animations: Animation[];
  58794. /**
  58795. * Initializes the path cursor
  58796. * @param path The path to track
  58797. */
  58798. constructor(path: Path2);
  58799. /**
  58800. * Gets the cursor point on the path
  58801. * @returns A point on the path cursor at the cursor location
  58802. */
  58803. getPoint(): Vector3;
  58804. /**
  58805. * Moves the cursor ahead by the step amount
  58806. * @param step The amount to move the cursor forward
  58807. * @returns This path cursor
  58808. */
  58809. moveAhead(step?: number): PathCursor;
  58810. /**
  58811. * Moves the cursor behind by the step amount
  58812. * @param step The amount to move the cursor back
  58813. * @returns This path cursor
  58814. */
  58815. moveBack(step?: number): PathCursor;
  58816. /**
  58817. * Moves the cursor by the step amount
  58818. * If the step amount is greater than one, an exception is thrown
  58819. * @param step The amount to move the cursor
  58820. * @returns This path cursor
  58821. */
  58822. move(step: number): PathCursor;
  58823. /**
  58824. * Ensures that the value is limited between zero and one
  58825. * @returns This path cursor
  58826. */
  58827. private ensureLimits;
  58828. /**
  58829. * Runs onchange callbacks on change (used by the animation engine)
  58830. * @returns This path cursor
  58831. */
  58832. private raiseOnChange;
  58833. /**
  58834. * Executes a function on change
  58835. * @param f A path cursor onchange callback
  58836. * @returns This path cursor
  58837. */
  58838. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58839. }
  58840. }
  58841. declare module "babylonjs/Legacy/legacy" {
  58842. import * as Babylon from "babylonjs/index";
  58843. export * from "babylonjs/index";
  58844. }
  58845. declare module "babylonjs/Shaders/blur.fragment" {
  58846. /** @hidden */
  58847. export var blurPixelShader: {
  58848. name: string;
  58849. shader: string;
  58850. };
  58851. }
  58852. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  58853. /** @hidden */
  58854. export var bones300Declaration: {
  58855. name: string;
  58856. shader: string;
  58857. };
  58858. }
  58859. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  58860. /** @hidden */
  58861. export var instances300Declaration: {
  58862. name: string;
  58863. shader: string;
  58864. };
  58865. }
  58866. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  58867. /** @hidden */
  58868. export var pointCloudVertexDeclaration: {
  58869. name: string;
  58870. shader: string;
  58871. };
  58872. }
  58873. // Mixins
  58874. interface Window {
  58875. mozIndexedDB: IDBFactory;
  58876. webkitIndexedDB: IDBFactory;
  58877. msIndexedDB: IDBFactory;
  58878. webkitURL: typeof URL;
  58879. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58880. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58881. WebGLRenderingContext: WebGLRenderingContext;
  58882. MSGesture: MSGesture;
  58883. CANNON: any;
  58884. AudioContext: AudioContext;
  58885. webkitAudioContext: AudioContext;
  58886. PointerEvent: any;
  58887. Math: Math;
  58888. Uint8Array: Uint8ArrayConstructor;
  58889. Float32Array: Float32ArrayConstructor;
  58890. mozURL: typeof URL;
  58891. msURL: typeof URL;
  58892. VRFrameData: any; // WebVR, from specs 1.1
  58893. DracoDecoderModule: any;
  58894. setImmediate(handler: (...args: any[]) => void): number;
  58895. }
  58896. interface HTMLCanvasElement {
  58897. requestPointerLock(): void;
  58898. msRequestPointerLock?(): void;
  58899. mozRequestPointerLock?(): void;
  58900. webkitRequestPointerLock?(): void;
  58901. /** Track wether a record is in progress */
  58902. isRecording: boolean;
  58903. /** Capture Stream method defined by some browsers */
  58904. captureStream(fps?: number): MediaStream;
  58905. }
  58906. interface CanvasRenderingContext2D {
  58907. msImageSmoothingEnabled: boolean;
  58908. }
  58909. interface MouseEvent {
  58910. mozMovementX: number;
  58911. mozMovementY: number;
  58912. webkitMovementX: number;
  58913. webkitMovementY: number;
  58914. msMovementX: number;
  58915. msMovementY: number;
  58916. }
  58917. interface Navigator {
  58918. mozGetVRDevices: (any: any) => any;
  58919. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58920. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58921. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58922. webkitGetGamepads(): Gamepad[];
  58923. msGetGamepads(): Gamepad[];
  58924. webkitGamepads(): Gamepad[];
  58925. }
  58926. interface HTMLVideoElement {
  58927. mozSrcObject: any;
  58928. }
  58929. interface Math {
  58930. fround(x: number): number;
  58931. imul(a: number, b: number): number;
  58932. }
  58933. interface WebGLProgram {
  58934. context?: WebGLRenderingContext;
  58935. vertexShader?: WebGLShader;
  58936. fragmentShader?: WebGLShader;
  58937. isParallelCompiled: boolean;
  58938. onCompiled?: () => void;
  58939. }
  58940. interface WebGLRenderingContext {
  58941. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58942. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58943. vertexAttribDivisor(index: number, divisor: number): void;
  58944. createVertexArray(): any;
  58945. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58946. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58947. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58948. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58949. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58950. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58951. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58952. // Queries
  58953. createQuery(): WebGLQuery;
  58954. deleteQuery(query: WebGLQuery): void;
  58955. beginQuery(target: number, query: WebGLQuery): void;
  58956. endQuery(target: number): void;
  58957. getQueryParameter(query: WebGLQuery, pname: number): any;
  58958. getQuery(target: number, pname: number): any;
  58959. MAX_SAMPLES: number;
  58960. RGBA8: number;
  58961. READ_FRAMEBUFFER: number;
  58962. DRAW_FRAMEBUFFER: number;
  58963. UNIFORM_BUFFER: number;
  58964. HALF_FLOAT_OES: number;
  58965. RGBA16F: number;
  58966. RGBA32F: number;
  58967. R32F: number;
  58968. RG32F: number;
  58969. RGB32F: number;
  58970. R16F: number;
  58971. RG16F: number;
  58972. RGB16F: number;
  58973. RED: number;
  58974. RG: number;
  58975. R8: number;
  58976. RG8: number;
  58977. UNSIGNED_INT_24_8: number;
  58978. DEPTH24_STENCIL8: number;
  58979. /* Multiple Render Targets */
  58980. drawBuffers(buffers: number[]): void;
  58981. readBuffer(src: number): void;
  58982. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58983. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58984. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58985. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58986. // Occlusion Query
  58987. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58988. ANY_SAMPLES_PASSED: number;
  58989. QUERY_RESULT_AVAILABLE: number;
  58990. QUERY_RESULT: number;
  58991. }
  58992. interface WebGLBuffer {
  58993. references: number;
  58994. capacity: number;
  58995. is32Bits: boolean;
  58996. }
  58997. interface WebGLProgram {
  58998. transformFeedback?: WebGLTransformFeedback | null;
  58999. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59000. }
  59001. interface EXT_disjoint_timer_query {
  59002. QUERY_COUNTER_BITS_EXT: number;
  59003. TIME_ELAPSED_EXT: number;
  59004. TIMESTAMP_EXT: number;
  59005. GPU_DISJOINT_EXT: number;
  59006. QUERY_RESULT_EXT: number;
  59007. QUERY_RESULT_AVAILABLE_EXT: number;
  59008. queryCounterEXT(query: WebGLQuery, target: number): void;
  59009. createQueryEXT(): WebGLQuery;
  59010. beginQueryEXT(target: number, query: WebGLQuery): void;
  59011. endQueryEXT(target: number): void;
  59012. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59013. deleteQueryEXT(query: WebGLQuery): void;
  59014. }
  59015. interface WebGLUniformLocation {
  59016. _currentState: any;
  59017. }
  59018. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59019. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59020. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59021. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59022. interface WebGLRenderingContext {
  59023. readonly RASTERIZER_DISCARD: number;
  59024. readonly DEPTH_COMPONENT24: number;
  59025. readonly TEXTURE_3D: number;
  59026. readonly TEXTURE_2D_ARRAY: number;
  59027. readonly TEXTURE_COMPARE_FUNC: number;
  59028. readonly TEXTURE_COMPARE_MODE: number;
  59029. readonly COMPARE_REF_TO_TEXTURE: number;
  59030. readonly TEXTURE_WRAP_R: number;
  59031. readonly HALF_FLOAT: number;
  59032. readonly RGB8: number;
  59033. readonly RED_INTEGER: number;
  59034. readonly RG_INTEGER: number;
  59035. readonly RGB_INTEGER: number;
  59036. readonly RGBA_INTEGER: number;
  59037. readonly R8_SNORM: number;
  59038. readonly RG8_SNORM: number;
  59039. readonly RGB8_SNORM: number;
  59040. readonly RGBA8_SNORM: number;
  59041. readonly R8I: number;
  59042. readonly RG8I: number;
  59043. readonly RGB8I: number;
  59044. readonly RGBA8I: number;
  59045. readonly R8UI: number;
  59046. readonly RG8UI: number;
  59047. readonly RGB8UI: number;
  59048. readonly RGBA8UI: number;
  59049. readonly R16I: number;
  59050. readonly RG16I: number;
  59051. readonly RGB16I: number;
  59052. readonly RGBA16I: number;
  59053. readonly R16UI: number;
  59054. readonly RG16UI: number;
  59055. readonly RGB16UI: number;
  59056. readonly RGBA16UI: number;
  59057. readonly R32I: number;
  59058. readonly RG32I: number;
  59059. readonly RGB32I: number;
  59060. readonly RGBA32I: number;
  59061. readonly R32UI: number;
  59062. readonly RG32UI: number;
  59063. readonly RGB32UI: number;
  59064. readonly RGBA32UI: number;
  59065. readonly RGB10_A2UI: number;
  59066. readonly R11F_G11F_B10F: number;
  59067. readonly RGB9_E5: number;
  59068. readonly RGB10_A2: number;
  59069. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59070. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59071. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59072. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59073. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59074. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59075. 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;
  59076. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59077. readonly TRANSFORM_FEEDBACK: number;
  59078. readonly INTERLEAVED_ATTRIBS: number;
  59079. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59080. createTransformFeedback(): WebGLTransformFeedback;
  59081. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59082. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59083. beginTransformFeedback(primitiveMode: number): void;
  59084. endTransformFeedback(): void;
  59085. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59086. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59087. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59088. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59089. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59090. }
  59091. interface ImageBitmap {
  59092. readonly width: number;
  59093. readonly height: number;
  59094. close(): void;
  59095. }
  59096. interface WebGLQuery extends WebGLObject {
  59097. }
  59098. declare var WebGLQuery: {
  59099. prototype: WebGLQuery;
  59100. new(): WebGLQuery;
  59101. };
  59102. interface WebGLSampler extends WebGLObject {
  59103. }
  59104. declare var WebGLSampler: {
  59105. prototype: WebGLSampler;
  59106. new(): WebGLSampler;
  59107. };
  59108. interface WebGLSync extends WebGLObject {
  59109. }
  59110. declare var WebGLSync: {
  59111. prototype: WebGLSync;
  59112. new(): WebGLSync;
  59113. };
  59114. interface WebGLTransformFeedback extends WebGLObject {
  59115. }
  59116. declare var WebGLTransformFeedback: {
  59117. prototype: WebGLTransformFeedback;
  59118. new(): WebGLTransformFeedback;
  59119. };
  59120. interface WebGLVertexArrayObject extends WebGLObject {
  59121. }
  59122. declare var WebGLVertexArrayObject: {
  59123. prototype: WebGLVertexArrayObject;
  59124. new(): WebGLVertexArrayObject;
  59125. };
  59126. // Type definitions for WebVR API
  59127. // Project: https://w3c.github.io/webvr/
  59128. // Definitions by: six a <https://github.com/lostfictions>
  59129. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59130. interface VRDisplay extends EventTarget {
  59131. /**
  59132. * Dictionary of capabilities describing the VRDisplay.
  59133. */
  59134. readonly capabilities: VRDisplayCapabilities;
  59135. /**
  59136. * z-depth defining the far plane of the eye view frustum
  59137. * enables mapping of values in the render target depth
  59138. * attachment to scene coordinates. Initially set to 10000.0.
  59139. */
  59140. depthFar: number;
  59141. /**
  59142. * z-depth defining the near plane of the eye view frustum
  59143. * enables mapping of values in the render target depth
  59144. * attachment to scene coordinates. Initially set to 0.01.
  59145. */
  59146. depthNear: number;
  59147. /**
  59148. * An identifier for this distinct VRDisplay. Used as an
  59149. * association point in the Gamepad API.
  59150. */
  59151. readonly displayId: number;
  59152. /**
  59153. * A display name, a user-readable name identifying it.
  59154. */
  59155. readonly displayName: string;
  59156. readonly isConnected: boolean;
  59157. readonly isPresenting: boolean;
  59158. /**
  59159. * If this VRDisplay supports room-scale experiences, the optional
  59160. * stage attribute contains details on the room-scale parameters.
  59161. */
  59162. readonly stageParameters: VRStageParameters | null;
  59163. /**
  59164. * Passing the value returned by `requestAnimationFrame` to
  59165. * `cancelAnimationFrame` will unregister the callback.
  59166. * @param handle Define the hanle of the request to cancel
  59167. */
  59168. cancelAnimationFrame(handle: number): void;
  59169. /**
  59170. * Stops presenting to the VRDisplay.
  59171. * @returns a promise to know when it stopped
  59172. */
  59173. exitPresent(): Promise<void>;
  59174. /**
  59175. * Return the current VREyeParameters for the given eye.
  59176. * @param whichEye Define the eye we want the parameter for
  59177. * @returns the eye parameters
  59178. */
  59179. getEyeParameters(whichEye: string): VREyeParameters;
  59180. /**
  59181. * Populates the passed VRFrameData with the information required to render
  59182. * the current frame.
  59183. * @param frameData Define the data structure to populate
  59184. * @returns true if ok otherwise false
  59185. */
  59186. getFrameData(frameData: VRFrameData): boolean;
  59187. /**
  59188. * Get the layers currently being presented.
  59189. * @returns the list of VR layers
  59190. */
  59191. getLayers(): VRLayer[];
  59192. /**
  59193. * Return a VRPose containing the future predicted pose of the VRDisplay
  59194. * when the current frame will be presented. The value returned will not
  59195. * change until JavaScript has returned control to the browser.
  59196. *
  59197. * The VRPose will contain the position, orientation, velocity,
  59198. * and acceleration of each of these properties.
  59199. * @returns the pose object
  59200. */
  59201. getPose(): VRPose;
  59202. /**
  59203. * Return the current instantaneous pose of the VRDisplay, with no
  59204. * prediction applied.
  59205. * @returns the current instantaneous pose
  59206. */
  59207. getImmediatePose(): VRPose;
  59208. /**
  59209. * The callback passed to `requestAnimationFrame` will be called
  59210. * any time a new frame should be rendered. When the VRDisplay is
  59211. * presenting the callback will be called at the native refresh
  59212. * rate of the HMD. When not presenting this function acts
  59213. * identically to how window.requestAnimationFrame acts. Content should
  59214. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59215. * asynchronously from other displays and at differing refresh rates.
  59216. * @param callback Define the eaction to run next frame
  59217. * @returns the request handle it
  59218. */
  59219. requestAnimationFrame(callback: FrameRequestCallback): number;
  59220. /**
  59221. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59222. * Repeat calls while already presenting will update the VRLayers being displayed.
  59223. * @param layers Define the list of layer to present
  59224. * @returns a promise to know when the request has been fulfilled
  59225. */
  59226. requestPresent(layers: VRLayer[]): Promise<void>;
  59227. /**
  59228. * Reset the pose for this display, treating its current position and
  59229. * orientation as the "origin/zero" values. VRPose.position,
  59230. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59231. * updated when calling resetPose(). This should be called in only
  59232. * sitting-space experiences.
  59233. */
  59234. resetPose(): void;
  59235. /**
  59236. * The VRLayer provided to the VRDisplay will be captured and presented
  59237. * in the HMD. Calling this function has the same effect on the source
  59238. * canvas as any other operation that uses its source image, and canvases
  59239. * created without preserveDrawingBuffer set to true will be cleared.
  59240. * @param pose Define the pose to submit
  59241. */
  59242. submitFrame(pose?: VRPose): void;
  59243. }
  59244. declare var VRDisplay: {
  59245. prototype: VRDisplay;
  59246. new(): VRDisplay;
  59247. };
  59248. interface VRLayer {
  59249. leftBounds?: number[] | Float32Array | null;
  59250. rightBounds?: number[] | Float32Array | null;
  59251. source?: HTMLCanvasElement | null;
  59252. }
  59253. interface VRDisplayCapabilities {
  59254. readonly canPresent: boolean;
  59255. readonly hasExternalDisplay: boolean;
  59256. readonly hasOrientation: boolean;
  59257. readonly hasPosition: boolean;
  59258. readonly maxLayers: number;
  59259. }
  59260. interface VREyeParameters {
  59261. /** @deprecated */
  59262. readonly fieldOfView: VRFieldOfView;
  59263. readonly offset: Float32Array;
  59264. readonly renderHeight: number;
  59265. readonly renderWidth: number;
  59266. }
  59267. interface VRFieldOfView {
  59268. readonly downDegrees: number;
  59269. readonly leftDegrees: number;
  59270. readonly rightDegrees: number;
  59271. readonly upDegrees: number;
  59272. }
  59273. interface VRFrameData {
  59274. readonly leftProjectionMatrix: Float32Array;
  59275. readonly leftViewMatrix: Float32Array;
  59276. readonly pose: VRPose;
  59277. readonly rightProjectionMatrix: Float32Array;
  59278. readonly rightViewMatrix: Float32Array;
  59279. readonly timestamp: number;
  59280. }
  59281. interface VRPose {
  59282. readonly angularAcceleration: Float32Array | null;
  59283. readonly angularVelocity: Float32Array | null;
  59284. readonly linearAcceleration: Float32Array | null;
  59285. readonly linearVelocity: Float32Array | null;
  59286. readonly orientation: Float32Array | null;
  59287. readonly position: Float32Array | null;
  59288. readonly timestamp: number;
  59289. }
  59290. interface VRStageParameters {
  59291. sittingToStandingTransform?: Float32Array;
  59292. sizeX?: number;
  59293. sizeY?: number;
  59294. }
  59295. interface Navigator {
  59296. getVRDisplays(): Promise<VRDisplay[]>;
  59297. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59298. }
  59299. interface Window {
  59300. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59301. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59302. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59303. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59304. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59305. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59306. }
  59307. interface Gamepad {
  59308. readonly displayId: number;
  59309. }
  59310. interface XRDevice {
  59311. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59312. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59313. }
  59314. interface XRSession {
  59315. getInputSources(): Array<any>;
  59316. baseLayer: XRWebGLLayer;
  59317. requestFrameOfReference(type: string): Promise<void>;
  59318. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59319. end(): Promise<void>;
  59320. requestAnimationFrame: Function;
  59321. addEventListener: Function;
  59322. }
  59323. interface XRSessionCreationOptions {
  59324. outputContext?: WebGLRenderingContext | null;
  59325. immersive?: boolean;
  59326. environmentIntegration?: boolean;
  59327. }
  59328. interface XRLayer {
  59329. getViewport: Function;
  59330. framebufferWidth: number;
  59331. framebufferHeight: number;
  59332. }
  59333. interface XRView {
  59334. projectionMatrix: Float32Array;
  59335. }
  59336. interface XRFrame {
  59337. getDevicePose: Function;
  59338. getInputPose: Function;
  59339. views: Array<XRView>;
  59340. baseLayer: XRLayer;
  59341. }
  59342. interface XRFrameOfReference {
  59343. }
  59344. interface XRWebGLLayer extends XRLayer {
  59345. framebuffer: WebGLFramebuffer;
  59346. }
  59347. declare var XRWebGLLayer: {
  59348. prototype: XRWebGLLayer;
  59349. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59350. };
  59351. declare module "babylonjs" {
  59352. export * from "babylonjs/Legacy/legacy";
  59353. }
  59354. declare module BABYLON {
  59355. /** Alias type for value that can be null */
  59356. export type Nullable<T> = T | null;
  59357. /**
  59358. * Alias type for number that are floats
  59359. * @ignorenaming
  59360. */
  59361. export type float = number;
  59362. /**
  59363. * Alias type for number that are doubles.
  59364. * @ignorenaming
  59365. */
  59366. export type double = number;
  59367. /**
  59368. * Alias type for number that are integer
  59369. * @ignorenaming
  59370. */
  59371. export type int = number;
  59372. /** Alias type for number array or Float32Array */
  59373. export type FloatArray = number[] | Float32Array;
  59374. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59375. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59376. /**
  59377. * Alias for types that can be used by a Buffer or VertexBuffer.
  59378. */
  59379. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59380. /**
  59381. * Alias type for primitive types
  59382. * @ignorenaming
  59383. */
  59384. type Primitive = undefined | null | boolean | string | number | Function;
  59385. /**
  59386. * Type modifier to make all the properties of an object Readonly
  59387. */
  59388. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59389. /**
  59390. * Type modifier to make all the properties of an object Readonly recursively
  59391. */
  59392. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59393. /** @hidden */
  59394. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59395. }
  59396. /** @hidden */
  59397. /** @hidden */
  59398. type DeepImmutableObject<T> = {
  59399. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59400. };
  59401. }
  59402. declare module BABYLON {
  59403. /**
  59404. * Class containing a set of static utilities functions for arrays.
  59405. */
  59406. export class ArrayTools {
  59407. /**
  59408. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59409. * @param size the number of element to construct and put in the array
  59410. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59411. * @returns a new array filled with new objects
  59412. */
  59413. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59414. }
  59415. }
  59416. declare module BABYLON {
  59417. /**
  59418. * Scalar computation library
  59419. */
  59420. export class Scalar {
  59421. /**
  59422. * Two pi constants convenient for computation.
  59423. */
  59424. static TwoPi: number;
  59425. /**
  59426. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59427. * @param a number
  59428. * @param b number
  59429. * @param epsilon (default = 1.401298E-45)
  59430. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59431. */
  59432. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  59433. /**
  59434. * Returns a string : the upper case translation of the number i to hexadecimal.
  59435. * @param i number
  59436. * @returns the upper case translation of the number i to hexadecimal.
  59437. */
  59438. static ToHex(i: number): string;
  59439. /**
  59440. * Returns -1 if value is negative and +1 is value is positive.
  59441. * @param value the value
  59442. * @returns the value itself if it's equal to zero.
  59443. */
  59444. static Sign(value: number): number;
  59445. /**
  59446. * Returns the value itself if it's between min and max.
  59447. * Returns min if the value is lower than min.
  59448. * Returns max if the value is greater than max.
  59449. * @param value the value to clmap
  59450. * @param min the min value to clamp to (default: 0)
  59451. * @param max the max value to clamp to (default: 1)
  59452. * @returns the clamped value
  59453. */
  59454. static Clamp(value: number, min?: number, max?: number): number;
  59455. /**
  59456. * the log2 of value.
  59457. * @param value the value to compute log2 of
  59458. * @returns the log2 of value.
  59459. */
  59460. static Log2(value: number): number;
  59461. /**
  59462. * Loops the value, so that it is never larger than length and never smaller than 0.
  59463. *
  59464. * This is similar to the modulo operator but it works with floating point numbers.
  59465. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  59466. * With t = 5 and length = 2.5, the result would be 0.0.
  59467. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  59468. * @param value the value
  59469. * @param length the length
  59470. * @returns the looped value
  59471. */
  59472. static Repeat(value: number, length: number): number;
  59473. /**
  59474. * Normalize the value between 0.0 and 1.0 using min and max values
  59475. * @param value value to normalize
  59476. * @param min max to normalize between
  59477. * @param max min to normalize between
  59478. * @returns the normalized value
  59479. */
  59480. static Normalize(value: number, min: number, max: number): number;
  59481. /**
  59482. * Denormalize the value from 0.0 and 1.0 using min and max values
  59483. * @param normalized value to denormalize
  59484. * @param min max to denormalize between
  59485. * @param max min to denormalize between
  59486. * @returns the denormalized value
  59487. */
  59488. static Denormalize(normalized: number, min: number, max: number): number;
  59489. /**
  59490. * Calculates the shortest difference between two given angles given in degrees.
  59491. * @param current current angle in degrees
  59492. * @param target target angle in degrees
  59493. * @returns the delta
  59494. */
  59495. static DeltaAngle(current: number, target: number): number;
  59496. /**
  59497. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  59498. * @param tx value
  59499. * @param length length
  59500. * @returns The returned value will move back and forth between 0 and length
  59501. */
  59502. static PingPong(tx: number, length: number): number;
  59503. /**
  59504. * Interpolates between min and max with smoothing at the limits.
  59505. *
  59506. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  59507. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  59508. * @param from from
  59509. * @param to to
  59510. * @param tx value
  59511. * @returns the smooth stepped value
  59512. */
  59513. static SmoothStep(from: number, to: number, tx: number): number;
  59514. /**
  59515. * Moves a value current towards target.
  59516. *
  59517. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  59518. * Negative values of maxDelta pushes the value away from target.
  59519. * @param current current value
  59520. * @param target target value
  59521. * @param maxDelta max distance to move
  59522. * @returns resulting value
  59523. */
  59524. static MoveTowards(current: number, target: number, maxDelta: number): number;
  59525. /**
  59526. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59527. *
  59528. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  59529. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  59530. * @param current current value
  59531. * @param target target value
  59532. * @param maxDelta max distance to move
  59533. * @returns resulting angle
  59534. */
  59535. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  59536. /**
  59537. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  59538. * @param start start value
  59539. * @param end target value
  59540. * @param amount amount to lerp between
  59541. * @returns the lerped value
  59542. */
  59543. static Lerp(start: number, end: number, amount: number): number;
  59544. /**
  59545. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59546. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  59547. * @param start start value
  59548. * @param end target value
  59549. * @param amount amount to lerp between
  59550. * @returns the lerped value
  59551. */
  59552. static LerpAngle(start: number, end: number, amount: number): number;
  59553. /**
  59554. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  59555. * @param a start value
  59556. * @param b target value
  59557. * @param value value between a and b
  59558. * @returns the inverseLerp value
  59559. */
  59560. static InverseLerp(a: number, b: number, value: number): number;
  59561. /**
  59562. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  59563. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  59564. * @param value1 spline value
  59565. * @param tangent1 spline value
  59566. * @param value2 spline value
  59567. * @param tangent2 spline value
  59568. * @param amount input value
  59569. * @returns hermite result
  59570. */
  59571. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  59572. /**
  59573. * Returns a random float number between and min and max values
  59574. * @param min min value of random
  59575. * @param max max value of random
  59576. * @returns random value
  59577. */
  59578. static RandomRange(min: number, max: number): number;
  59579. /**
  59580. * This function returns percentage of a number in a given range.
  59581. *
  59582. * RangeToPercent(40,20,60) will return 0.5 (50%)
  59583. * RangeToPercent(34,0,100) will return 0.34 (34%)
  59584. * @param number to convert to percentage
  59585. * @param min min range
  59586. * @param max max range
  59587. * @returns the percentage
  59588. */
  59589. static RangeToPercent(number: number, min: number, max: number): number;
  59590. /**
  59591. * This function returns number that corresponds to the percentage in a given range.
  59592. *
  59593. * PercentToRange(0.34,0,100) will return 34.
  59594. * @param percent to convert to number
  59595. * @param min min range
  59596. * @param max max range
  59597. * @returns the number
  59598. */
  59599. static PercentToRange(percent: number, min: number, max: number): number;
  59600. /**
  59601. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  59602. * @param angle The angle to normalize in radian.
  59603. * @return The converted angle.
  59604. */
  59605. static NormalizeRadians(angle: number): number;
  59606. }
  59607. }
  59608. declare module BABYLON {
  59609. /**
  59610. * Constant used to convert a value to gamma space
  59611. * @ignorenaming
  59612. */
  59613. export const ToGammaSpace: number;
  59614. /**
  59615. * Constant used to convert a value to linear space
  59616. * @ignorenaming
  59617. */
  59618. export const ToLinearSpace = 2.2;
  59619. /**
  59620. * Constant used to define the minimal number value in Babylon.js
  59621. * @ignorenaming
  59622. */
  59623. export const Epsilon = 0.001;
  59624. /**
  59625. * Class used to hold a RBG color
  59626. */
  59627. export class Color3 {
  59628. /**
  59629. * Defines the red component (between 0 and 1, default is 0)
  59630. */
  59631. r: number;
  59632. /**
  59633. * Defines the green component (between 0 and 1, default is 0)
  59634. */
  59635. g: number;
  59636. /**
  59637. * Defines the blue component (between 0 and 1, default is 0)
  59638. */
  59639. b: number;
  59640. /**
  59641. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  59642. * @param r defines the red component (between 0 and 1, default is 0)
  59643. * @param g defines the green component (between 0 and 1, default is 0)
  59644. * @param b defines the blue component (between 0 and 1, default is 0)
  59645. */
  59646. constructor(
  59647. /**
  59648. * Defines the red component (between 0 and 1, default is 0)
  59649. */
  59650. r?: number,
  59651. /**
  59652. * Defines the green component (between 0 and 1, default is 0)
  59653. */
  59654. g?: number,
  59655. /**
  59656. * Defines the blue component (between 0 and 1, default is 0)
  59657. */
  59658. b?: number);
  59659. /**
  59660. * Creates a string with the Color3 current values
  59661. * @returns the string representation of the Color3 object
  59662. */
  59663. toString(): string;
  59664. /**
  59665. * Returns the string "Color3"
  59666. * @returns "Color3"
  59667. */
  59668. getClassName(): string;
  59669. /**
  59670. * Compute the Color3 hash code
  59671. * @returns an unique number that can be used to hash Color3 objects
  59672. */
  59673. getHashCode(): number;
  59674. /**
  59675. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  59676. * @param array defines the array where to store the r,g,b components
  59677. * @param index defines an optional index in the target array to define where to start storing values
  59678. * @returns the current Color3 object
  59679. */
  59680. toArray(array: FloatArray, index?: number): Color3;
  59681. /**
  59682. * Returns a new Color4 object from the current Color3 and the given alpha
  59683. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  59684. * @returns a new Color4 object
  59685. */
  59686. toColor4(alpha?: number): Color4;
  59687. /**
  59688. * Returns a new array populated with 3 numeric elements : red, green and blue values
  59689. * @returns the new array
  59690. */
  59691. asArray(): number[];
  59692. /**
  59693. * Returns the luminance value
  59694. * @returns a float value
  59695. */
  59696. toLuminance(): number;
  59697. /**
  59698. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  59699. * @param otherColor defines the second operand
  59700. * @returns the new Color3 object
  59701. */
  59702. multiply(otherColor: DeepImmutable<Color3>): Color3;
  59703. /**
  59704. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  59705. * @param otherColor defines the second operand
  59706. * @param result defines the Color3 object where to store the result
  59707. * @returns the current Color3
  59708. */
  59709. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59710. /**
  59711. * Determines equality between Color3 objects
  59712. * @param otherColor defines the second operand
  59713. * @returns true if the rgb values are equal to the given ones
  59714. */
  59715. equals(otherColor: DeepImmutable<Color3>): boolean;
  59716. /**
  59717. * Determines equality between the current Color3 object and a set of r,b,g values
  59718. * @param r defines the red component to check
  59719. * @param g defines the green component to check
  59720. * @param b defines the blue component to check
  59721. * @returns true if the rgb values are equal to the given ones
  59722. */
  59723. equalsFloats(r: number, g: number, b: number): boolean;
  59724. /**
  59725. * Multiplies in place each rgb value by scale
  59726. * @param scale defines the scaling factor
  59727. * @returns the updated Color3
  59728. */
  59729. scale(scale: number): Color3;
  59730. /**
  59731. * Multiplies the rgb values by scale and stores the result into "result"
  59732. * @param scale defines the scaling factor
  59733. * @param result defines the Color3 object where to store the result
  59734. * @returns the unmodified current Color3
  59735. */
  59736. scaleToRef(scale: number, result: Color3): Color3;
  59737. /**
  59738. * Scale the current Color3 values by a factor and add the result to a given Color3
  59739. * @param scale defines the scale factor
  59740. * @param result defines color to store the result into
  59741. * @returns the unmodified current Color3
  59742. */
  59743. scaleAndAddToRef(scale: number, result: Color3): Color3;
  59744. /**
  59745. * Clamps the rgb values by the min and max values and stores the result into "result"
  59746. * @param min defines minimum clamping value (default is 0)
  59747. * @param max defines maximum clamping value (default is 1)
  59748. * @param result defines color to store the result into
  59749. * @returns the original Color3
  59750. */
  59751. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  59752. /**
  59753. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  59754. * @param otherColor defines the second operand
  59755. * @returns the new Color3
  59756. */
  59757. add(otherColor: DeepImmutable<Color3>): Color3;
  59758. /**
  59759. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  59760. * @param otherColor defines the second operand
  59761. * @param result defines Color3 object to store the result into
  59762. * @returns the unmodified current Color3
  59763. */
  59764. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59765. /**
  59766. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  59767. * @param otherColor defines the second operand
  59768. * @returns the new Color3
  59769. */
  59770. subtract(otherColor: DeepImmutable<Color3>): Color3;
  59771. /**
  59772. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  59773. * @param otherColor defines the second operand
  59774. * @param result defines Color3 object to store the result into
  59775. * @returns the unmodified current Color3
  59776. */
  59777. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59778. /**
  59779. * Copy the current object
  59780. * @returns a new Color3 copied the current one
  59781. */
  59782. clone(): Color3;
  59783. /**
  59784. * Copies the rgb values from the source in the current Color3
  59785. * @param source defines the source Color3 object
  59786. * @returns the updated Color3 object
  59787. */
  59788. copyFrom(source: DeepImmutable<Color3>): Color3;
  59789. /**
  59790. * Updates the Color3 rgb values from the given floats
  59791. * @param r defines the red component to read from
  59792. * @param g defines the green component to read from
  59793. * @param b defines the blue component to read from
  59794. * @returns the current Color3 object
  59795. */
  59796. copyFromFloats(r: number, g: number, b: number): Color3;
  59797. /**
  59798. * Updates the Color3 rgb values from the given floats
  59799. * @param r defines the red component to read from
  59800. * @param g defines the green component to read from
  59801. * @param b defines the blue component to read from
  59802. * @returns the current Color3 object
  59803. */
  59804. set(r: number, g: number, b: number): Color3;
  59805. /**
  59806. * Compute the Color3 hexadecimal code as a string
  59807. * @returns a string containing the hexadecimal representation of the Color3 object
  59808. */
  59809. toHexString(): string;
  59810. /**
  59811. * Computes a new Color3 converted from the current one to linear space
  59812. * @returns a new Color3 object
  59813. */
  59814. toLinearSpace(): Color3;
  59815. /**
  59816. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  59817. * @param convertedColor defines the Color3 object where to store the linear space version
  59818. * @returns the unmodified Color3
  59819. */
  59820. toLinearSpaceToRef(convertedColor: Color3): Color3;
  59821. /**
  59822. * Computes a new Color3 converted from the current one to gamma space
  59823. * @returns a new Color3 object
  59824. */
  59825. toGammaSpace(): Color3;
  59826. /**
  59827. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  59828. * @param convertedColor defines the Color3 object where to store the gamma space version
  59829. * @returns the unmodified Color3
  59830. */
  59831. toGammaSpaceToRef(convertedColor: Color3): Color3;
  59832. private static _BlackReadOnly;
  59833. /**
  59834. * Creates a new Color3 from the string containing valid hexadecimal values
  59835. * @param hex defines a string containing valid hexadecimal values
  59836. * @returns a new Color3 object
  59837. */
  59838. static FromHexString(hex: string): Color3;
  59839. /**
  59840. * Creates a new Vector3 from the starting index of the given array
  59841. * @param array defines the source array
  59842. * @param offset defines an offset in the source array
  59843. * @returns a new Color3 object
  59844. */
  59845. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  59846. /**
  59847. * Creates a new Color3 from integer values (< 256)
  59848. * @param r defines the red component to read from (value between 0 and 255)
  59849. * @param g defines the green component to read from (value between 0 and 255)
  59850. * @param b defines the blue component to read from (value between 0 and 255)
  59851. * @returns a new Color3 object
  59852. */
  59853. static FromInts(r: number, g: number, b: number): Color3;
  59854. /**
  59855. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59856. * @param start defines the start Color3 value
  59857. * @param end defines the end Color3 value
  59858. * @param amount defines the gradient value between start and end
  59859. * @returns a new Color3 object
  59860. */
  59861. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  59862. /**
  59863. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59864. * @param left defines the start value
  59865. * @param right defines the end value
  59866. * @param amount defines the gradient factor
  59867. * @param result defines the Color3 object where to store the result
  59868. */
  59869. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  59870. /**
  59871. * Returns a Color3 value containing a red color
  59872. * @returns a new Color3 object
  59873. */
  59874. static Red(): Color3;
  59875. /**
  59876. * Returns a Color3 value containing a green color
  59877. * @returns a new Color3 object
  59878. */
  59879. static Green(): Color3;
  59880. /**
  59881. * Returns a Color3 value containing a blue color
  59882. * @returns a new Color3 object
  59883. */
  59884. static Blue(): Color3;
  59885. /**
  59886. * Returns a Color3 value containing a black color
  59887. * @returns a new Color3 object
  59888. */
  59889. static Black(): Color3;
  59890. /**
  59891. * Gets a Color3 value containing a black color that must not be updated
  59892. */
  59893. static readonly BlackReadOnly: DeepImmutable<Color3>;
  59894. /**
  59895. * Returns a Color3 value containing a white color
  59896. * @returns a new Color3 object
  59897. */
  59898. static White(): Color3;
  59899. /**
  59900. * Returns a Color3 value containing a purple color
  59901. * @returns a new Color3 object
  59902. */
  59903. static Purple(): Color3;
  59904. /**
  59905. * Returns a Color3 value containing a magenta color
  59906. * @returns a new Color3 object
  59907. */
  59908. static Magenta(): Color3;
  59909. /**
  59910. * Returns a Color3 value containing a yellow color
  59911. * @returns a new Color3 object
  59912. */
  59913. static Yellow(): Color3;
  59914. /**
  59915. * Returns a Color3 value containing a gray color
  59916. * @returns a new Color3 object
  59917. */
  59918. static Gray(): Color3;
  59919. /**
  59920. * Returns a Color3 value containing a teal color
  59921. * @returns a new Color3 object
  59922. */
  59923. static Teal(): Color3;
  59924. /**
  59925. * Returns a Color3 value containing a random color
  59926. * @returns a new Color3 object
  59927. */
  59928. static Random(): Color3;
  59929. }
  59930. /**
  59931. * Class used to hold a RBGA color
  59932. */
  59933. export class Color4 {
  59934. /**
  59935. * Defines the red component (between 0 and 1, default is 0)
  59936. */
  59937. r: number;
  59938. /**
  59939. * Defines the green component (between 0 and 1, default is 0)
  59940. */
  59941. g: number;
  59942. /**
  59943. * Defines the blue component (between 0 and 1, default is 0)
  59944. */
  59945. b: number;
  59946. /**
  59947. * Defines the alpha component (between 0 and 1, default is 1)
  59948. */
  59949. a: number;
  59950. /**
  59951. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  59952. * @param r defines the red component (between 0 and 1, default is 0)
  59953. * @param g defines the green component (between 0 and 1, default is 0)
  59954. * @param b defines the blue component (between 0 and 1, default is 0)
  59955. * @param a defines the alpha component (between 0 and 1, default is 1)
  59956. */
  59957. constructor(
  59958. /**
  59959. * Defines the red component (between 0 and 1, default is 0)
  59960. */
  59961. r?: number,
  59962. /**
  59963. * Defines the green component (between 0 and 1, default is 0)
  59964. */
  59965. g?: number,
  59966. /**
  59967. * Defines the blue component (between 0 and 1, default is 0)
  59968. */
  59969. b?: number,
  59970. /**
  59971. * Defines the alpha component (between 0 and 1, default is 1)
  59972. */
  59973. a?: number);
  59974. /**
  59975. * Adds in place the given Color4 values to the current Color4 object
  59976. * @param right defines the second operand
  59977. * @returns the current updated Color4 object
  59978. */
  59979. addInPlace(right: DeepImmutable<Color4>): Color4;
  59980. /**
  59981. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  59982. * @returns the new array
  59983. */
  59984. asArray(): number[];
  59985. /**
  59986. * Stores from the starting index in the given array the Color4 successive values
  59987. * @param array defines the array where to store the r,g,b components
  59988. * @param index defines an optional index in the target array to define where to start storing values
  59989. * @returns the current Color4 object
  59990. */
  59991. toArray(array: number[], index?: number): Color4;
  59992. /**
  59993. * Determines equality between Color4 objects
  59994. * @param otherColor defines the second operand
  59995. * @returns true if the rgba values are equal to the given ones
  59996. */
  59997. equals(otherColor: DeepImmutable<Color4>): boolean;
  59998. /**
  59999. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60000. * @param right defines the second operand
  60001. * @returns a new Color4 object
  60002. */
  60003. add(right: DeepImmutable<Color4>): Color4;
  60004. /**
  60005. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60006. * @param right defines the second operand
  60007. * @returns a new Color4 object
  60008. */
  60009. subtract(right: DeepImmutable<Color4>): Color4;
  60010. /**
  60011. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60012. * @param right defines the second operand
  60013. * @param result defines the Color4 object where to store the result
  60014. * @returns the current Color4 object
  60015. */
  60016. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60017. /**
  60018. * Creates a new Color4 with the current Color4 values multiplied by scale
  60019. * @param scale defines the scaling factor to apply
  60020. * @returns a new Color4 object
  60021. */
  60022. scale(scale: number): Color4;
  60023. /**
  60024. * Multiplies the current Color4 values by scale and stores the result in "result"
  60025. * @param scale defines the scaling factor to apply
  60026. * @param result defines the Color4 object where to store the result
  60027. * @returns the current unmodified Color4
  60028. */
  60029. scaleToRef(scale: number, result: Color4): Color4;
  60030. /**
  60031. * Scale the current Color4 values by a factor and add the result to a given Color4
  60032. * @param scale defines the scale factor
  60033. * @param result defines the Color4 object where to store the result
  60034. * @returns the unmodified current Color4
  60035. */
  60036. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60037. /**
  60038. * Clamps the rgb values by the min and max values and stores the result into "result"
  60039. * @param min defines minimum clamping value (default is 0)
  60040. * @param max defines maximum clamping value (default is 1)
  60041. * @param result defines color to store the result into.
  60042. * @returns the cuurent Color4
  60043. */
  60044. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60045. /**
  60046. * Multipy an Color4 value by another and return a new Color4 object
  60047. * @param color defines the Color4 value to multiply by
  60048. * @returns a new Color4 object
  60049. */
  60050. multiply(color: Color4): Color4;
  60051. /**
  60052. * Multipy a Color4 value by another and push the result in a reference value
  60053. * @param color defines the Color4 value to multiply by
  60054. * @param result defines the Color4 to fill the result in
  60055. * @returns the result Color4
  60056. */
  60057. multiplyToRef(color: Color4, result: Color4): Color4;
  60058. /**
  60059. * Creates a string with the Color4 current values
  60060. * @returns the string representation of the Color4 object
  60061. */
  60062. toString(): string;
  60063. /**
  60064. * Returns the string "Color4"
  60065. * @returns "Color4"
  60066. */
  60067. getClassName(): string;
  60068. /**
  60069. * Compute the Color4 hash code
  60070. * @returns an unique number that can be used to hash Color4 objects
  60071. */
  60072. getHashCode(): number;
  60073. /**
  60074. * Creates a new Color4 copied from the current one
  60075. * @returns a new Color4 object
  60076. */
  60077. clone(): Color4;
  60078. /**
  60079. * Copies the given Color4 values into the current one
  60080. * @param source defines the source Color4 object
  60081. * @returns the current updated Color4 object
  60082. */
  60083. copyFrom(source: Color4): Color4;
  60084. /**
  60085. * Copies the given float values into the current one
  60086. * @param r defines the red component to read from
  60087. * @param g defines the green component to read from
  60088. * @param b defines the blue component to read from
  60089. * @param a defines the alpha component to read from
  60090. * @returns the current updated Color4 object
  60091. */
  60092. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60093. /**
  60094. * Copies the given float values into the current one
  60095. * @param r defines the red component to read from
  60096. * @param g defines the green component to read from
  60097. * @param b defines the blue component to read from
  60098. * @param a defines the alpha component to read from
  60099. * @returns the current updated Color4 object
  60100. */
  60101. set(r: number, g: number, b: number, a: number): Color4;
  60102. /**
  60103. * Compute the Color4 hexadecimal code as a string
  60104. * @returns a string containing the hexadecimal representation of the Color4 object
  60105. */
  60106. toHexString(): string;
  60107. /**
  60108. * Computes a new Color4 converted from the current one to linear space
  60109. * @returns a new Color4 object
  60110. */
  60111. toLinearSpace(): Color4;
  60112. /**
  60113. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60114. * @param convertedColor defines the Color4 object where to store the linear space version
  60115. * @returns the unmodified Color4
  60116. */
  60117. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60118. /**
  60119. * Computes a new Color4 converted from the current one to gamma space
  60120. * @returns a new Color4 object
  60121. */
  60122. toGammaSpace(): Color4;
  60123. /**
  60124. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60125. * @param convertedColor defines the Color4 object where to store the gamma space version
  60126. * @returns the unmodified Color4
  60127. */
  60128. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60129. /**
  60130. * Creates a new Color4 from the string containing valid hexadecimal values
  60131. * @param hex defines a string containing valid hexadecimal values
  60132. * @returns a new Color4 object
  60133. */
  60134. static FromHexString(hex: string): Color4;
  60135. /**
  60136. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60137. * @param left defines the start value
  60138. * @param right defines the end value
  60139. * @param amount defines the gradient factor
  60140. * @returns a new Color4 object
  60141. */
  60142. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60143. /**
  60144. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60145. * @param left defines the start value
  60146. * @param right defines the end value
  60147. * @param amount defines the gradient factor
  60148. * @param result defines the Color4 object where to store data
  60149. */
  60150. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60151. /**
  60152. * Creates a new Color4 from a Color3 and an alpha value
  60153. * @param color3 defines the source Color3 to read from
  60154. * @param alpha defines the alpha component (1.0 by default)
  60155. * @returns a new Color4 object
  60156. */
  60157. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60158. /**
  60159. * Creates a new Color4 from the starting index element of the given array
  60160. * @param array defines the source array to read from
  60161. * @param offset defines the offset in the source array
  60162. * @returns a new Color4 object
  60163. */
  60164. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60165. /**
  60166. * Creates a new Color3 from integer values (< 256)
  60167. * @param r defines the red component to read from (value between 0 and 255)
  60168. * @param g defines the green component to read from (value between 0 and 255)
  60169. * @param b defines the blue component to read from (value between 0 and 255)
  60170. * @param a defines the alpha component to read from (value between 0 and 255)
  60171. * @returns a new Color3 object
  60172. */
  60173. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60174. /**
  60175. * Check the content of a given array and convert it to an array containing RGBA data
  60176. * If the original array was already containing count * 4 values then it is returned directly
  60177. * @param colors defines the array to check
  60178. * @param count defines the number of RGBA data to expect
  60179. * @returns an array containing count * 4 values (RGBA)
  60180. */
  60181. static CheckColors4(colors: number[], count: number): number[];
  60182. }
  60183. /**
  60184. * Class representing a vector containing 2 coordinates
  60185. */
  60186. export class Vector2 {
  60187. /** defines the first coordinate */
  60188. x: number;
  60189. /** defines the second coordinate */
  60190. y: number;
  60191. /**
  60192. * Creates a new Vector2 from the given x and y coordinates
  60193. * @param x defines the first coordinate
  60194. * @param y defines the second coordinate
  60195. */
  60196. constructor(
  60197. /** defines the first coordinate */
  60198. x?: number,
  60199. /** defines the second coordinate */
  60200. y?: number);
  60201. /**
  60202. * Gets a string with the Vector2 coordinates
  60203. * @returns a string with the Vector2 coordinates
  60204. */
  60205. toString(): string;
  60206. /**
  60207. * Gets class name
  60208. * @returns the string "Vector2"
  60209. */
  60210. getClassName(): string;
  60211. /**
  60212. * Gets current vector hash code
  60213. * @returns the Vector2 hash code as a number
  60214. */
  60215. getHashCode(): number;
  60216. /**
  60217. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60218. * @param array defines the source array
  60219. * @param index defines the offset in source array
  60220. * @returns the current Vector2
  60221. */
  60222. toArray(array: FloatArray, index?: number): Vector2;
  60223. /**
  60224. * Copy the current vector to an array
  60225. * @returns a new array with 2 elements: the Vector2 coordinates.
  60226. */
  60227. asArray(): number[];
  60228. /**
  60229. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60230. * @param source defines the source Vector2
  60231. * @returns the current updated Vector2
  60232. */
  60233. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60234. /**
  60235. * Sets the Vector2 coordinates with the given floats
  60236. * @param x defines the first coordinate
  60237. * @param y defines the second coordinate
  60238. * @returns the current updated Vector2
  60239. */
  60240. copyFromFloats(x: number, y: number): Vector2;
  60241. /**
  60242. * Sets the Vector2 coordinates with the given floats
  60243. * @param x defines the first coordinate
  60244. * @param y defines the second coordinate
  60245. * @returns the current updated Vector2
  60246. */
  60247. set(x: number, y: number): Vector2;
  60248. /**
  60249. * Add another vector with the current one
  60250. * @param otherVector defines the other vector
  60251. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60252. */
  60253. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60254. /**
  60255. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60256. * @param otherVector defines the other vector
  60257. * @param result defines the target vector
  60258. * @returns the unmodified current Vector2
  60259. */
  60260. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60261. /**
  60262. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60263. * @param otherVector defines the other vector
  60264. * @returns the current updated Vector2
  60265. */
  60266. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60267. /**
  60268. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60269. * @param otherVector defines the other vector
  60270. * @returns a new Vector2
  60271. */
  60272. addVector3(otherVector: Vector3): Vector2;
  60273. /**
  60274. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60275. * @param otherVector defines the other vector
  60276. * @returns a new Vector2
  60277. */
  60278. subtract(otherVector: Vector2): Vector2;
  60279. /**
  60280. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60281. * @param otherVector defines the other vector
  60282. * @param result defines the target vector
  60283. * @returns the unmodified current Vector2
  60284. */
  60285. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60286. /**
  60287. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60288. * @param otherVector defines the other vector
  60289. * @returns the current updated Vector2
  60290. */
  60291. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60292. /**
  60293. * Multiplies in place the current Vector2 coordinates by the given ones
  60294. * @param otherVector defines the other vector
  60295. * @returns the current updated Vector2
  60296. */
  60297. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60298. /**
  60299. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60300. * @param otherVector defines the other vector
  60301. * @returns a new Vector2
  60302. */
  60303. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60304. /**
  60305. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60306. * @param otherVector defines the other vector
  60307. * @param result defines the target vector
  60308. * @returns the unmodified current Vector2
  60309. */
  60310. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60311. /**
  60312. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60313. * @param x defines the first coordinate
  60314. * @param y defines the second coordinate
  60315. * @returns a new Vector2
  60316. */
  60317. multiplyByFloats(x: number, y: number): Vector2;
  60318. /**
  60319. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60320. * @param otherVector defines the other vector
  60321. * @returns a new Vector2
  60322. */
  60323. divide(otherVector: Vector2): Vector2;
  60324. /**
  60325. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60326. * @param otherVector defines the other vector
  60327. * @param result defines the target vector
  60328. * @returns the unmodified current Vector2
  60329. */
  60330. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60331. /**
  60332. * Divides the current Vector2 coordinates by the given ones
  60333. * @param otherVector defines the other vector
  60334. * @returns the current updated Vector2
  60335. */
  60336. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60337. /**
  60338. * Gets a new Vector2 with current Vector2 negated coordinates
  60339. * @returns a new Vector2
  60340. */
  60341. negate(): Vector2;
  60342. /**
  60343. * Multiply the Vector2 coordinates by scale
  60344. * @param scale defines the scaling factor
  60345. * @returns the current updated Vector2
  60346. */
  60347. scaleInPlace(scale: number): Vector2;
  60348. /**
  60349. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60350. * @param scale defines the scaling factor
  60351. * @returns a new Vector2
  60352. */
  60353. scale(scale: number): Vector2;
  60354. /**
  60355. * Scale the current Vector2 values by a factor to a given Vector2
  60356. * @param scale defines the scale factor
  60357. * @param result defines the Vector2 object where to store the result
  60358. * @returns the unmodified current Vector2
  60359. */
  60360. scaleToRef(scale: number, result: Vector2): Vector2;
  60361. /**
  60362. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60363. * @param scale defines the scale factor
  60364. * @param result defines the Vector2 object where to store the result
  60365. * @returns the unmodified current Vector2
  60366. */
  60367. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60368. /**
  60369. * Gets a boolean if two vectors are equals
  60370. * @param otherVector defines the other vector
  60371. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60372. */
  60373. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60374. /**
  60375. * Gets a boolean if two vectors are equals (using an epsilon value)
  60376. * @param otherVector defines the other vector
  60377. * @param epsilon defines the minimal distance to consider equality
  60378. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60379. */
  60380. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60381. /**
  60382. * Gets a new Vector2 from current Vector2 floored values
  60383. * @returns a new Vector2
  60384. */
  60385. floor(): Vector2;
  60386. /**
  60387. * Gets a new Vector2 from current Vector2 floored values
  60388. * @returns a new Vector2
  60389. */
  60390. fract(): Vector2;
  60391. /**
  60392. * Gets the length of the vector
  60393. * @returns the vector length (float)
  60394. */
  60395. length(): number;
  60396. /**
  60397. * Gets the vector squared length
  60398. * @returns the vector squared length (float)
  60399. */
  60400. lengthSquared(): number;
  60401. /**
  60402. * Normalize the vector
  60403. * @returns the current updated Vector2
  60404. */
  60405. normalize(): Vector2;
  60406. /**
  60407. * Gets a new Vector2 copied from the Vector2
  60408. * @returns a new Vector2
  60409. */
  60410. clone(): Vector2;
  60411. /**
  60412. * Gets a new Vector2(0, 0)
  60413. * @returns a new Vector2
  60414. */
  60415. static Zero(): Vector2;
  60416. /**
  60417. * Gets a new Vector2(1, 1)
  60418. * @returns a new Vector2
  60419. */
  60420. static One(): Vector2;
  60421. /**
  60422. * Gets a new Vector2 set from the given index element of the given array
  60423. * @param array defines the data source
  60424. * @param offset defines the offset in the data source
  60425. * @returns a new Vector2
  60426. */
  60427. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60428. /**
  60429. * Sets "result" from the given index element of the given array
  60430. * @param array defines the data source
  60431. * @param offset defines the offset in the data source
  60432. * @param result defines the target vector
  60433. */
  60434. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  60435. /**
  60436. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  60437. * @param value1 defines 1st point of control
  60438. * @param value2 defines 2nd point of control
  60439. * @param value3 defines 3rd point of control
  60440. * @param value4 defines 4th point of control
  60441. * @param amount defines the interpolation factor
  60442. * @returns a new Vector2
  60443. */
  60444. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  60445. /**
  60446. * 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".
  60447. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  60448. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  60449. * @param value defines the value to clamp
  60450. * @param min defines the lower limit
  60451. * @param max defines the upper limit
  60452. * @returns a new Vector2
  60453. */
  60454. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  60455. /**
  60456. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  60457. * @param value1 defines the 1st control point
  60458. * @param tangent1 defines the outgoing tangent
  60459. * @param value2 defines the 2nd control point
  60460. * @param tangent2 defines the incoming tangent
  60461. * @param amount defines the interpolation factor
  60462. * @returns a new Vector2
  60463. */
  60464. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  60465. /**
  60466. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  60467. * @param start defines the start vector
  60468. * @param end defines the end vector
  60469. * @param amount defines the interpolation factor
  60470. * @returns a new Vector2
  60471. */
  60472. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  60473. /**
  60474. * Gets the dot product of the vector "left" and the vector "right"
  60475. * @param left defines first vector
  60476. * @param right defines second vector
  60477. * @returns the dot product (float)
  60478. */
  60479. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  60480. /**
  60481. * Returns a new Vector2 equal to the normalized given vector
  60482. * @param vector defines the vector to normalize
  60483. * @returns a new Vector2
  60484. */
  60485. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  60486. /**
  60487. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  60488. * @param left defines 1st vector
  60489. * @param right defines 2nd vector
  60490. * @returns a new Vector2
  60491. */
  60492. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60493. /**
  60494. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  60495. * @param left defines 1st vector
  60496. * @param right defines 2nd vector
  60497. * @returns a new Vector2
  60498. */
  60499. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60500. /**
  60501. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  60502. * @param vector defines the vector to transform
  60503. * @param transformation defines the matrix to apply
  60504. * @returns a new Vector2
  60505. */
  60506. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  60507. /**
  60508. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  60509. * @param vector defines the vector to transform
  60510. * @param transformation defines the matrix to apply
  60511. * @param result defines the target vector
  60512. */
  60513. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  60514. /**
  60515. * Determines if a given vector is included in a triangle
  60516. * @param p defines the vector to test
  60517. * @param p0 defines 1st triangle point
  60518. * @param p1 defines 2nd triangle point
  60519. * @param p2 defines 3rd triangle point
  60520. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  60521. */
  60522. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  60523. /**
  60524. * Gets the distance between the vectors "value1" and "value2"
  60525. * @param value1 defines first vector
  60526. * @param value2 defines second vector
  60527. * @returns the distance between vectors
  60528. */
  60529. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60530. /**
  60531. * Returns the squared distance between the vectors "value1" and "value2"
  60532. * @param value1 defines first vector
  60533. * @param value2 defines second vector
  60534. * @returns the squared distance between vectors
  60535. */
  60536. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60537. /**
  60538. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  60539. * @param value1 defines first vector
  60540. * @param value2 defines second vector
  60541. * @returns a new Vector2
  60542. */
  60543. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  60544. /**
  60545. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  60546. * @param p defines the middle point
  60547. * @param segA defines one point of the segment
  60548. * @param segB defines the other point of the segment
  60549. * @returns the shortest distance
  60550. */
  60551. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  60552. }
  60553. /**
  60554. * Classed used to store (x,y,z) vector representation
  60555. * A Vector3 is the main object used in 3D geometry
  60556. * It can represent etiher the coordinates of a point the space, either a direction
  60557. * Reminder: js uses a left handed forward facing system
  60558. */
  60559. export class Vector3 {
  60560. /**
  60561. * Defines the first coordinates (on X axis)
  60562. */
  60563. x: number;
  60564. /**
  60565. * Defines the second coordinates (on Y axis)
  60566. */
  60567. y: number;
  60568. /**
  60569. * Defines the third coordinates (on Z axis)
  60570. */
  60571. z: number;
  60572. private static _UpReadOnly;
  60573. /**
  60574. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  60575. * @param x defines the first coordinates (on X axis)
  60576. * @param y defines the second coordinates (on Y axis)
  60577. * @param z defines the third coordinates (on Z axis)
  60578. */
  60579. constructor(
  60580. /**
  60581. * Defines the first coordinates (on X axis)
  60582. */
  60583. x?: number,
  60584. /**
  60585. * Defines the second coordinates (on Y axis)
  60586. */
  60587. y?: number,
  60588. /**
  60589. * Defines the third coordinates (on Z axis)
  60590. */
  60591. z?: number);
  60592. /**
  60593. * Creates a string representation of the Vector3
  60594. * @returns a string with the Vector3 coordinates.
  60595. */
  60596. toString(): string;
  60597. /**
  60598. * Gets the class name
  60599. * @returns the string "Vector3"
  60600. */
  60601. getClassName(): string;
  60602. /**
  60603. * Creates the Vector3 hash code
  60604. * @returns a number which tends to be unique between Vector3 instances
  60605. */
  60606. getHashCode(): number;
  60607. /**
  60608. * Creates an array containing three elements : the coordinates of the Vector3
  60609. * @returns a new array of numbers
  60610. */
  60611. asArray(): number[];
  60612. /**
  60613. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  60614. * @param array defines the destination array
  60615. * @param index defines the offset in the destination array
  60616. * @returns the current Vector3
  60617. */
  60618. toArray(array: FloatArray, index?: number): Vector3;
  60619. /**
  60620. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  60621. * @returns a new Quaternion object, computed from the Vector3 coordinates
  60622. */
  60623. toQuaternion(): Quaternion;
  60624. /**
  60625. * Adds the given vector to the current Vector3
  60626. * @param otherVector defines the second operand
  60627. * @returns the current updated Vector3
  60628. */
  60629. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60630. /**
  60631. * Adds the given coordinates to the current Vector3
  60632. * @param x defines the x coordinate of the operand
  60633. * @param y defines the y coordinate of the operand
  60634. * @param z defines the z coordinate of the operand
  60635. * @returns the current updated Vector3
  60636. */
  60637. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60638. /**
  60639. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  60640. * @param otherVector defines the second operand
  60641. * @returns the resulting Vector3
  60642. */
  60643. add(otherVector: DeepImmutable<Vector3>): Vector3;
  60644. /**
  60645. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  60646. * @param otherVector defines the second operand
  60647. * @param result defines the Vector3 object where to store the result
  60648. * @returns the current Vector3
  60649. */
  60650. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60651. /**
  60652. * Subtract the given vector from the current Vector3
  60653. * @param otherVector defines the second operand
  60654. * @returns the current updated Vector3
  60655. */
  60656. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60657. /**
  60658. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  60659. * @param otherVector defines the second operand
  60660. * @returns the resulting Vector3
  60661. */
  60662. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  60663. /**
  60664. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  60665. * @param otherVector defines the second operand
  60666. * @param result defines the Vector3 object where to store the result
  60667. * @returns the current Vector3
  60668. */
  60669. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60670. /**
  60671. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  60672. * @param x defines the x coordinate of the operand
  60673. * @param y defines the y coordinate of the operand
  60674. * @param z defines the z coordinate of the operand
  60675. * @returns the resulting Vector3
  60676. */
  60677. subtractFromFloats(x: number, y: number, z: number): Vector3;
  60678. /**
  60679. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  60680. * @param x defines the x coordinate of the operand
  60681. * @param y defines the y coordinate of the operand
  60682. * @param z defines the z coordinate of the operand
  60683. * @param result defines the Vector3 object where to store the result
  60684. * @returns the current Vector3
  60685. */
  60686. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  60687. /**
  60688. * Gets a new Vector3 set with the current Vector3 negated coordinates
  60689. * @returns a new Vector3
  60690. */
  60691. negate(): Vector3;
  60692. /**
  60693. * Multiplies the Vector3 coordinates by the float "scale"
  60694. * @param scale defines the multiplier factor
  60695. * @returns the current updated Vector3
  60696. */
  60697. scaleInPlace(scale: number): Vector3;
  60698. /**
  60699. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  60700. * @param scale defines the multiplier factor
  60701. * @returns a new Vector3
  60702. */
  60703. scale(scale: number): Vector3;
  60704. /**
  60705. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  60706. * @param scale defines the multiplier factor
  60707. * @param result defines the Vector3 object where to store the result
  60708. * @returns the current Vector3
  60709. */
  60710. scaleToRef(scale: number, result: Vector3): Vector3;
  60711. /**
  60712. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  60713. * @param scale defines the scale factor
  60714. * @param result defines the Vector3 object where to store the result
  60715. * @returns the unmodified current Vector3
  60716. */
  60717. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  60718. /**
  60719. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  60720. * @param otherVector defines the second operand
  60721. * @returns true if both vectors are equals
  60722. */
  60723. equals(otherVector: DeepImmutable<Vector3>): boolean;
  60724. /**
  60725. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  60726. * @param otherVector defines the second operand
  60727. * @param epsilon defines the minimal distance to define values as equals
  60728. * @returns true if both vectors are distant less than epsilon
  60729. */
  60730. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  60731. /**
  60732. * Returns true if the current Vector3 coordinates equals the given floats
  60733. * @param x defines the x coordinate of the operand
  60734. * @param y defines the y coordinate of the operand
  60735. * @param z defines the z coordinate of the operand
  60736. * @returns true if both vectors are equals
  60737. */
  60738. equalsToFloats(x: number, y: number, z: number): boolean;
  60739. /**
  60740. * Multiplies the current Vector3 coordinates by the given ones
  60741. * @param otherVector defines the second operand
  60742. * @returns the current updated Vector3
  60743. */
  60744. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60745. /**
  60746. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  60747. * @param otherVector defines the second operand
  60748. * @returns the new Vector3
  60749. */
  60750. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  60751. /**
  60752. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  60753. * @param otherVector defines the second operand
  60754. * @param result defines the Vector3 object where to store the result
  60755. * @returns the current Vector3
  60756. */
  60757. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60758. /**
  60759. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  60760. * @param x defines the x coordinate of the operand
  60761. * @param y defines the y coordinate of the operand
  60762. * @param z defines the z coordinate of the operand
  60763. * @returns the new Vector3
  60764. */
  60765. multiplyByFloats(x: number, y: number, z: number): Vector3;
  60766. /**
  60767. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  60768. * @param otherVector defines the second operand
  60769. * @returns the new Vector3
  60770. */
  60771. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  60772. /**
  60773. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  60774. * @param otherVector defines the second operand
  60775. * @param result defines the Vector3 object where to store the result
  60776. * @returns the current Vector3
  60777. */
  60778. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60779. /**
  60780. * Divides the current Vector3 coordinates by the given ones.
  60781. * @param otherVector defines the second operand
  60782. * @returns the current updated Vector3
  60783. */
  60784. divideInPlace(otherVector: Vector3): Vector3;
  60785. /**
  60786. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  60787. * @param other defines the second operand
  60788. * @returns the current updated Vector3
  60789. */
  60790. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60791. /**
  60792. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  60793. * @param other defines the second operand
  60794. * @returns the current updated Vector3
  60795. */
  60796. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60797. /**
  60798. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  60799. * @param x defines the x coordinate of the operand
  60800. * @param y defines the y coordinate of the operand
  60801. * @param z defines the z coordinate of the operand
  60802. * @returns the current updated Vector3
  60803. */
  60804. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60805. /**
  60806. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  60807. * @param x defines the x coordinate of the operand
  60808. * @param y defines the y coordinate of the operand
  60809. * @param z defines the z coordinate of the operand
  60810. * @returns the current updated Vector3
  60811. */
  60812. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60813. /**
  60814. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  60815. * Check if is non uniform within a certain amount of decimal places to account for this
  60816. * @param epsilon the amount the values can differ
  60817. * @returns if the the vector is non uniform to a certain number of decimal places
  60818. */
  60819. isNonUniformWithinEpsilon(epsilon: number): boolean;
  60820. /**
  60821. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  60822. */
  60823. readonly isNonUniform: boolean;
  60824. /**
  60825. * Gets a new Vector3 from current Vector3 floored values
  60826. * @returns a new Vector3
  60827. */
  60828. floor(): Vector3;
  60829. /**
  60830. * Gets a new Vector3 from current Vector3 floored values
  60831. * @returns a new Vector3
  60832. */
  60833. fract(): Vector3;
  60834. /**
  60835. * Gets the length of the Vector3
  60836. * @returns the length of the Vecto3
  60837. */
  60838. length(): number;
  60839. /**
  60840. * Gets the squared length of the Vector3
  60841. * @returns squared length of the Vector3
  60842. */
  60843. lengthSquared(): number;
  60844. /**
  60845. * Normalize the current Vector3.
  60846. * Please note that this is an in place operation.
  60847. * @returns the current updated Vector3
  60848. */
  60849. normalize(): Vector3;
  60850. /**
  60851. * Reorders the x y z properties of the vector in place
  60852. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  60853. * @returns the current updated vector
  60854. */
  60855. reorderInPlace(order: string): this;
  60856. /**
  60857. * Rotates the vector around 0,0,0 by a quaternion
  60858. * @param quaternion the rotation quaternion
  60859. * @param result vector to store the result
  60860. * @returns the resulting vector
  60861. */
  60862. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  60863. /**
  60864. * Rotates a vector around a given point
  60865. * @param quaternion the rotation quaternion
  60866. * @param point the point to rotate around
  60867. * @param result vector to store the result
  60868. * @returns the resulting vector
  60869. */
  60870. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  60871. /**
  60872. * Normalize the current Vector3 with the given input length.
  60873. * Please note that this is an in place operation.
  60874. * @param len the length of the vector
  60875. * @returns the current updated Vector3
  60876. */
  60877. normalizeFromLength(len: number): Vector3;
  60878. /**
  60879. * Normalize the current Vector3 to a new vector
  60880. * @returns the new Vector3
  60881. */
  60882. normalizeToNew(): Vector3;
  60883. /**
  60884. * Normalize the current Vector3 to the reference
  60885. * @param reference define the Vector3 to update
  60886. * @returns the updated Vector3
  60887. */
  60888. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  60889. /**
  60890. * Creates a new Vector3 copied from the current Vector3
  60891. * @returns the new Vector3
  60892. */
  60893. clone(): Vector3;
  60894. /**
  60895. * Copies the given vector coordinates to the current Vector3 ones
  60896. * @param source defines the source Vector3
  60897. * @returns the current updated Vector3
  60898. */
  60899. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  60900. /**
  60901. * Copies the given floats to the current Vector3 coordinates
  60902. * @param x defines the x coordinate of the operand
  60903. * @param y defines the y coordinate of the operand
  60904. * @param z defines the z coordinate of the operand
  60905. * @returns the current updated Vector3
  60906. */
  60907. copyFromFloats(x: number, y: number, z: number): Vector3;
  60908. /**
  60909. * Copies the given floats to the current Vector3 coordinates
  60910. * @param x defines the x coordinate of the operand
  60911. * @param y defines the y coordinate of the operand
  60912. * @param z defines the z coordinate of the operand
  60913. * @returns the current updated Vector3
  60914. */
  60915. set(x: number, y: number, z: number): Vector3;
  60916. /**
  60917. * Copies the given float to the current Vector3 coordinates
  60918. * @param v defines the x, y and z coordinates of the operand
  60919. * @returns the current updated Vector3
  60920. */
  60921. setAll(v: number): Vector3;
  60922. /**
  60923. * Get the clip factor between two vectors
  60924. * @param vector0 defines the first operand
  60925. * @param vector1 defines the second operand
  60926. * @param axis defines the axis to use
  60927. * @param size defines the size along the axis
  60928. * @returns the clip factor
  60929. */
  60930. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  60931. /**
  60932. * Get angle between two vectors
  60933. * @param vector0 angle between vector0 and vector1
  60934. * @param vector1 angle between vector0 and vector1
  60935. * @param normal direction of the normal
  60936. * @return the angle between vector0 and vector1
  60937. */
  60938. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  60939. /**
  60940. * Returns a new Vector3 set from the index "offset" of the given array
  60941. * @param array defines the source array
  60942. * @param offset defines the offset in the source array
  60943. * @returns the new Vector3
  60944. */
  60945. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  60946. /**
  60947. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  60948. * This function is deprecated. Use FromArray instead
  60949. * @param array defines the source array
  60950. * @param offset defines the offset in the source array
  60951. * @returns the new Vector3
  60952. */
  60953. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  60954. /**
  60955. * Sets the given vector "result" with the element values from the index "offset" of the given array
  60956. * @param array defines the source array
  60957. * @param offset defines the offset in the source array
  60958. * @param result defines the Vector3 where to store the result
  60959. */
  60960. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  60961. /**
  60962. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  60963. * This function is deprecated. Use FromArrayToRef instead.
  60964. * @param array defines the source array
  60965. * @param offset defines the offset in the source array
  60966. * @param result defines the Vector3 where to store the result
  60967. */
  60968. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  60969. /**
  60970. * Sets the given vector "result" with the given floats.
  60971. * @param x defines the x coordinate of the source
  60972. * @param y defines the y coordinate of the source
  60973. * @param z defines the z coordinate of the source
  60974. * @param result defines the Vector3 where to store the result
  60975. */
  60976. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  60977. /**
  60978. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  60979. * @returns a new empty Vector3
  60980. */
  60981. static Zero(): Vector3;
  60982. /**
  60983. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  60984. * @returns a new unit Vector3
  60985. */
  60986. static One(): Vector3;
  60987. /**
  60988. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  60989. * @returns a new up Vector3
  60990. */
  60991. static Up(): Vector3;
  60992. /**
  60993. * Gets a up Vector3 that must not be updated
  60994. */
  60995. static readonly UpReadOnly: DeepImmutable<Vector3>;
  60996. /**
  60997. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  60998. * @returns a new down Vector3
  60999. */
  61000. static Down(): Vector3;
  61001. /**
  61002. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61003. * @returns a new forward Vector3
  61004. */
  61005. static Forward(): Vector3;
  61006. /**
  61007. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61008. * @returns a new forward Vector3
  61009. */
  61010. static Backward(): Vector3;
  61011. /**
  61012. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61013. * @returns a new right Vector3
  61014. */
  61015. static Right(): Vector3;
  61016. /**
  61017. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61018. * @returns a new left Vector3
  61019. */
  61020. static Left(): Vector3;
  61021. /**
  61022. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61023. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61024. * @param vector defines the Vector3 to transform
  61025. * @param transformation defines the transformation matrix
  61026. * @returns the transformed Vector3
  61027. */
  61028. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61029. /**
  61030. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61031. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61032. * @param vector defines the Vector3 to transform
  61033. * @param transformation defines the transformation matrix
  61034. * @param result defines the Vector3 where to store the result
  61035. */
  61036. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61037. /**
  61038. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61039. * This method computes tranformed coordinates only, not transformed direction vectors
  61040. * @param x define the x coordinate of the source vector
  61041. * @param y define the y coordinate of the source vector
  61042. * @param z define the z coordinate of the source vector
  61043. * @param transformation defines the transformation matrix
  61044. * @param result defines the Vector3 where to store the result
  61045. */
  61046. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61047. /**
  61048. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61049. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61050. * @param vector defines the Vector3 to transform
  61051. * @param transformation defines the transformation matrix
  61052. * @returns the new Vector3
  61053. */
  61054. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61055. /**
  61056. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61057. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61058. * @param vector defines the Vector3 to transform
  61059. * @param transformation defines the transformation matrix
  61060. * @param result defines the Vector3 where to store the result
  61061. */
  61062. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61063. /**
  61064. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61065. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61066. * @param x define the x coordinate of the source vector
  61067. * @param y define the y coordinate of the source vector
  61068. * @param z define the z coordinate of the source vector
  61069. * @param transformation defines the transformation matrix
  61070. * @param result defines the Vector3 where to store the result
  61071. */
  61072. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61073. /**
  61074. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61075. * @param value1 defines the first control point
  61076. * @param value2 defines the second control point
  61077. * @param value3 defines the third control point
  61078. * @param value4 defines the fourth control point
  61079. * @param amount defines the amount on the spline to use
  61080. * @returns the new Vector3
  61081. */
  61082. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61083. /**
  61084. * 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"
  61085. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61086. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61087. * @param value defines the current value
  61088. * @param min defines the lower range value
  61089. * @param max defines the upper range value
  61090. * @returns the new Vector3
  61091. */
  61092. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61093. /**
  61094. * 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"
  61095. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61096. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61097. * @param value defines the current value
  61098. * @param min defines the lower range value
  61099. * @param max defines the upper range value
  61100. * @param result defines the Vector3 where to store the result
  61101. */
  61102. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61103. /**
  61104. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61105. * @param value1 defines the first control point
  61106. * @param tangent1 defines the first tangent vector
  61107. * @param value2 defines the second control point
  61108. * @param tangent2 defines the second tangent vector
  61109. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61110. * @returns the new Vector3
  61111. */
  61112. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61113. /**
  61114. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61115. * @param start defines the start value
  61116. * @param end defines the end value
  61117. * @param amount max defines amount between both (between 0 and 1)
  61118. * @returns the new Vector3
  61119. */
  61120. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61121. /**
  61122. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61123. * @param start defines the start value
  61124. * @param end defines the end value
  61125. * @param amount max defines amount between both (between 0 and 1)
  61126. * @param result defines the Vector3 where to store the result
  61127. */
  61128. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61129. /**
  61130. * Returns the dot product (float) between the vectors "left" and "right"
  61131. * @param left defines the left operand
  61132. * @param right defines the right operand
  61133. * @returns the dot product
  61134. */
  61135. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61136. /**
  61137. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61138. * The cross product is then orthogonal to both "left" and "right"
  61139. * @param left defines the left operand
  61140. * @param right defines the right operand
  61141. * @returns the cross product
  61142. */
  61143. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61144. /**
  61145. * Sets the given vector "result" with the cross product of "left" and "right"
  61146. * The cross product is then orthogonal to both "left" and "right"
  61147. * @param left defines the left operand
  61148. * @param right defines the right operand
  61149. * @param result defines the Vector3 where to store the result
  61150. */
  61151. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61152. /**
  61153. * Returns a new Vector3 as the normalization of the given vector
  61154. * @param vector defines the Vector3 to normalize
  61155. * @returns the new Vector3
  61156. */
  61157. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61158. /**
  61159. * Sets the given vector "result" with the normalization of the given first vector
  61160. * @param vector defines the Vector3 to normalize
  61161. * @param result defines the Vector3 where to store the result
  61162. */
  61163. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61164. /**
  61165. * Project a Vector3 onto screen space
  61166. * @param vector defines the Vector3 to project
  61167. * @param world defines the world matrix to use
  61168. * @param transform defines the transform (view x projection) matrix to use
  61169. * @param viewport defines the screen viewport to use
  61170. * @returns the new Vector3
  61171. */
  61172. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61173. /** @hidden */
  61174. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61175. /**
  61176. * Unproject from screen space to object space
  61177. * @param source defines the screen space Vector3 to use
  61178. * @param viewportWidth defines the current width of the viewport
  61179. * @param viewportHeight defines the current height of the viewport
  61180. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61181. * @param transform defines the transform (view x projection) matrix to use
  61182. * @returns the new Vector3
  61183. */
  61184. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61185. /**
  61186. * Unproject from screen space to object space
  61187. * @param source defines the screen space Vector3 to use
  61188. * @param viewportWidth defines the current width of the viewport
  61189. * @param viewportHeight defines the current height of the viewport
  61190. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61191. * @param view defines the view matrix to use
  61192. * @param projection defines the projection matrix to use
  61193. * @returns the new Vector3
  61194. */
  61195. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61196. /**
  61197. * Unproject from screen space to object space
  61198. * @param source defines the screen space Vector3 to use
  61199. * @param viewportWidth defines the current width of the viewport
  61200. * @param viewportHeight defines the current height of the viewport
  61201. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61202. * @param view defines the view matrix to use
  61203. * @param projection defines the projection matrix to use
  61204. * @param result defines the Vector3 where to store the result
  61205. */
  61206. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61207. /**
  61208. * Unproject from screen space to object space
  61209. * @param sourceX defines the screen space x coordinate to use
  61210. * @param sourceY defines the screen space y coordinate to use
  61211. * @param sourceZ defines the screen space z coordinate to use
  61212. * @param viewportWidth defines the current width of the viewport
  61213. * @param viewportHeight defines the current height of the viewport
  61214. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61215. * @param view defines the view matrix to use
  61216. * @param projection defines the projection matrix to use
  61217. * @param result defines the Vector3 where to store the result
  61218. */
  61219. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61220. /**
  61221. * Gets the minimal coordinate values between two Vector3
  61222. * @param left defines the first operand
  61223. * @param right defines the second operand
  61224. * @returns the new Vector3
  61225. */
  61226. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61227. /**
  61228. * Gets the maximal coordinate values between two Vector3
  61229. * @param left defines the first operand
  61230. * @param right defines the second operand
  61231. * @returns the new Vector3
  61232. */
  61233. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61234. /**
  61235. * Returns the distance between the vectors "value1" and "value2"
  61236. * @param value1 defines the first operand
  61237. * @param value2 defines the second operand
  61238. * @returns the distance
  61239. */
  61240. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61241. /**
  61242. * Returns the squared distance between the vectors "value1" and "value2"
  61243. * @param value1 defines the first operand
  61244. * @param value2 defines the second operand
  61245. * @returns the squared distance
  61246. */
  61247. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61248. /**
  61249. * Returns a new Vector3 located at the center between "value1" and "value2"
  61250. * @param value1 defines the first operand
  61251. * @param value2 defines the second operand
  61252. * @returns the new Vector3
  61253. */
  61254. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61255. /**
  61256. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61257. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61258. * to something in order to rotate it from its local system to the given target system
  61259. * Note: axis1, axis2 and axis3 are normalized during this operation
  61260. * @param axis1 defines the first axis
  61261. * @param axis2 defines the second axis
  61262. * @param axis3 defines the third axis
  61263. * @returns a new Vector3
  61264. */
  61265. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61266. /**
  61267. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61268. * @param axis1 defines the first axis
  61269. * @param axis2 defines the second axis
  61270. * @param axis3 defines the third axis
  61271. * @param ref defines the Vector3 where to store the result
  61272. */
  61273. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61274. }
  61275. /**
  61276. * Vector4 class created for EulerAngle class conversion to Quaternion
  61277. */
  61278. export class Vector4 {
  61279. /** x value of the vector */
  61280. x: number;
  61281. /** y value of the vector */
  61282. y: number;
  61283. /** z value of the vector */
  61284. z: number;
  61285. /** w value of the vector */
  61286. w: number;
  61287. /**
  61288. * Creates a Vector4 object from the given floats.
  61289. * @param x x value of the vector
  61290. * @param y y value of the vector
  61291. * @param z z value of the vector
  61292. * @param w w value of the vector
  61293. */
  61294. constructor(
  61295. /** x value of the vector */
  61296. x: number,
  61297. /** y value of the vector */
  61298. y: number,
  61299. /** z value of the vector */
  61300. z: number,
  61301. /** w value of the vector */
  61302. w: number);
  61303. /**
  61304. * Returns the string with the Vector4 coordinates.
  61305. * @returns a string containing all the vector values
  61306. */
  61307. toString(): string;
  61308. /**
  61309. * Returns the string "Vector4".
  61310. * @returns "Vector4"
  61311. */
  61312. getClassName(): string;
  61313. /**
  61314. * Returns the Vector4 hash code.
  61315. * @returns a unique hash code
  61316. */
  61317. getHashCode(): number;
  61318. /**
  61319. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61320. * @returns the resulting array
  61321. */
  61322. asArray(): number[];
  61323. /**
  61324. * Populates the given array from the given index with the Vector4 coordinates.
  61325. * @param array array to populate
  61326. * @param index index of the array to start at (default: 0)
  61327. * @returns the Vector4.
  61328. */
  61329. toArray(array: FloatArray, index?: number): Vector4;
  61330. /**
  61331. * Adds the given vector to the current Vector4.
  61332. * @param otherVector the vector to add
  61333. * @returns the updated Vector4.
  61334. */
  61335. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61336. /**
  61337. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61338. * @param otherVector the vector to add
  61339. * @returns the resulting vector
  61340. */
  61341. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61342. /**
  61343. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61344. * @param otherVector the vector to add
  61345. * @param result the vector to store the result
  61346. * @returns the current Vector4.
  61347. */
  61348. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61349. /**
  61350. * Subtract in place the given vector from the current Vector4.
  61351. * @param otherVector the vector to subtract
  61352. * @returns the updated Vector4.
  61353. */
  61354. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61355. /**
  61356. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61357. * @param otherVector the vector to add
  61358. * @returns the new vector with the result
  61359. */
  61360. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61361. /**
  61362. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61363. * @param otherVector the vector to subtract
  61364. * @param result the vector to store the result
  61365. * @returns the current Vector4.
  61366. */
  61367. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61368. /**
  61369. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61370. */
  61371. /**
  61372. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61373. * @param x value to subtract
  61374. * @param y value to subtract
  61375. * @param z value to subtract
  61376. * @param w value to subtract
  61377. * @returns new vector containing the result
  61378. */
  61379. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61380. /**
  61381. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61382. * @param x value to subtract
  61383. * @param y value to subtract
  61384. * @param z value to subtract
  61385. * @param w value to subtract
  61386. * @param result the vector to store the result in
  61387. * @returns the current Vector4.
  61388. */
  61389. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61390. /**
  61391. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61392. * @returns a new vector with the negated values
  61393. */
  61394. negate(): Vector4;
  61395. /**
  61396. * Multiplies the current Vector4 coordinates by scale (float).
  61397. * @param scale the number to scale with
  61398. * @returns the updated Vector4.
  61399. */
  61400. scaleInPlace(scale: number): Vector4;
  61401. /**
  61402. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61403. * @param scale the number to scale with
  61404. * @returns a new vector with the result
  61405. */
  61406. scale(scale: number): Vector4;
  61407. /**
  61408. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61409. * @param scale the number to scale with
  61410. * @param result a vector to store the result in
  61411. * @returns the current Vector4.
  61412. */
  61413. scaleToRef(scale: number, result: Vector4): Vector4;
  61414. /**
  61415. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61416. * @param scale defines the scale factor
  61417. * @param result defines the Vector4 object where to store the result
  61418. * @returns the unmodified current Vector4
  61419. */
  61420. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61421. /**
  61422. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61423. * @param otherVector the vector to compare against
  61424. * @returns true if they are equal
  61425. */
  61426. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61427. /**
  61428. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  61429. * @param otherVector vector to compare against
  61430. * @param epsilon (Default: very small number)
  61431. * @returns true if they are equal
  61432. */
  61433. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  61434. /**
  61435. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  61436. * @param x x value to compare against
  61437. * @param y y value to compare against
  61438. * @param z z value to compare against
  61439. * @param w w value to compare against
  61440. * @returns true if equal
  61441. */
  61442. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  61443. /**
  61444. * Multiplies in place the current Vector4 by the given one.
  61445. * @param otherVector vector to multiple with
  61446. * @returns the updated Vector4.
  61447. */
  61448. multiplyInPlace(otherVector: Vector4): Vector4;
  61449. /**
  61450. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  61451. * @param otherVector vector to multiple with
  61452. * @returns resulting new vector
  61453. */
  61454. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  61455. /**
  61456. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  61457. * @param otherVector vector to multiple with
  61458. * @param result vector to store the result
  61459. * @returns the current Vector4.
  61460. */
  61461. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61462. /**
  61463. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  61464. * @param x x value multiply with
  61465. * @param y y value multiply with
  61466. * @param z z value multiply with
  61467. * @param w w value multiply with
  61468. * @returns resulting new vector
  61469. */
  61470. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  61471. /**
  61472. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  61473. * @param otherVector vector to devide with
  61474. * @returns resulting new vector
  61475. */
  61476. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  61477. /**
  61478. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  61479. * @param otherVector vector to devide with
  61480. * @param result vector to store the result
  61481. * @returns the current Vector4.
  61482. */
  61483. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61484. /**
  61485. * Divides the current Vector3 coordinates by the given ones.
  61486. * @param otherVector vector to devide with
  61487. * @returns the updated Vector3.
  61488. */
  61489. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61490. /**
  61491. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  61492. * @param other defines the second operand
  61493. * @returns the current updated Vector4
  61494. */
  61495. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61496. /**
  61497. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  61498. * @param other defines the second operand
  61499. * @returns the current updated Vector4
  61500. */
  61501. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61502. /**
  61503. * Gets a new Vector4 from current Vector4 floored values
  61504. * @returns a new Vector4
  61505. */
  61506. floor(): Vector4;
  61507. /**
  61508. * Gets a new Vector4 from current Vector3 floored values
  61509. * @returns a new Vector4
  61510. */
  61511. fract(): Vector4;
  61512. /**
  61513. * Returns the Vector4 length (float).
  61514. * @returns the length
  61515. */
  61516. length(): number;
  61517. /**
  61518. * Returns the Vector4 squared length (float).
  61519. * @returns the length squared
  61520. */
  61521. lengthSquared(): number;
  61522. /**
  61523. * Normalizes in place the Vector4.
  61524. * @returns the updated Vector4.
  61525. */
  61526. normalize(): Vector4;
  61527. /**
  61528. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  61529. * @returns this converted to a new vector3
  61530. */
  61531. toVector3(): Vector3;
  61532. /**
  61533. * Returns a new Vector4 copied from the current one.
  61534. * @returns the new cloned vector
  61535. */
  61536. clone(): Vector4;
  61537. /**
  61538. * Updates the current Vector4 with the given one coordinates.
  61539. * @param source the source vector to copy from
  61540. * @returns the updated Vector4.
  61541. */
  61542. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  61543. /**
  61544. * Updates the current Vector4 coordinates with the given floats.
  61545. * @param x float to copy from
  61546. * @param y float to copy from
  61547. * @param z float to copy from
  61548. * @param w float to copy from
  61549. * @returns the updated Vector4.
  61550. */
  61551. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61552. /**
  61553. * Updates the current Vector4 coordinates with the given floats.
  61554. * @param x float to set from
  61555. * @param y float to set from
  61556. * @param z float to set from
  61557. * @param w float to set from
  61558. * @returns the updated Vector4.
  61559. */
  61560. set(x: number, y: number, z: number, w: number): Vector4;
  61561. /**
  61562. * Copies the given float to the current Vector3 coordinates
  61563. * @param v defines the x, y, z and w coordinates of the operand
  61564. * @returns the current updated Vector3
  61565. */
  61566. setAll(v: number): Vector4;
  61567. /**
  61568. * Returns a new Vector4 set from the starting index of the given array.
  61569. * @param array the array to pull values from
  61570. * @param offset the offset into the array to start at
  61571. * @returns the new vector
  61572. */
  61573. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  61574. /**
  61575. * Updates the given vector "result" from the starting index of the given array.
  61576. * @param array the array to pull values from
  61577. * @param offset the offset into the array to start at
  61578. * @param result the vector to store the result in
  61579. */
  61580. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  61581. /**
  61582. * Updates the given vector "result" from the starting index of the given Float32Array.
  61583. * @param array the array to pull values from
  61584. * @param offset the offset into the array to start at
  61585. * @param result the vector to store the result in
  61586. */
  61587. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  61588. /**
  61589. * Updates the given vector "result" coordinates from the given floats.
  61590. * @param x float to set from
  61591. * @param y float to set from
  61592. * @param z float to set from
  61593. * @param w float to set from
  61594. * @param result the vector to the floats in
  61595. */
  61596. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  61597. /**
  61598. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  61599. * @returns the new vector
  61600. */
  61601. static Zero(): Vector4;
  61602. /**
  61603. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  61604. * @returns the new vector
  61605. */
  61606. static One(): Vector4;
  61607. /**
  61608. * Returns a new normalized Vector4 from the given one.
  61609. * @param vector the vector to normalize
  61610. * @returns the vector
  61611. */
  61612. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  61613. /**
  61614. * Updates the given vector "result" from the normalization of the given one.
  61615. * @param vector the vector to normalize
  61616. * @param result the vector to store the result in
  61617. */
  61618. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  61619. /**
  61620. * Returns a vector with the minimum values from the left and right vectors
  61621. * @param left left vector to minimize
  61622. * @param right right vector to minimize
  61623. * @returns a new vector with the minimum of the left and right vector values
  61624. */
  61625. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61626. /**
  61627. * Returns a vector with the maximum values from the left and right vectors
  61628. * @param left left vector to maximize
  61629. * @param right right vector to maximize
  61630. * @returns a new vector with the maximum of the left and right vector values
  61631. */
  61632. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61633. /**
  61634. * Returns the distance (float) between the vectors "value1" and "value2".
  61635. * @param value1 value to calulate the distance between
  61636. * @param value2 value to calulate the distance between
  61637. * @return the distance between the two vectors
  61638. */
  61639. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61640. /**
  61641. * Returns the squared distance (float) between the vectors "value1" and "value2".
  61642. * @param value1 value to calulate the distance between
  61643. * @param value2 value to calulate the distance between
  61644. * @return the distance between the two vectors squared
  61645. */
  61646. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61647. /**
  61648. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  61649. * @param value1 value to calulate the center between
  61650. * @param value2 value to calulate the center between
  61651. * @return the center between the two vectors
  61652. */
  61653. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  61654. /**
  61655. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  61656. * This methods computes transformed normalized direction vectors only.
  61657. * @param vector the vector to transform
  61658. * @param transformation the transformation matrix to apply
  61659. * @returns the new vector
  61660. */
  61661. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  61662. /**
  61663. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  61664. * This methods computes transformed normalized direction vectors only.
  61665. * @param vector the vector to transform
  61666. * @param transformation the transformation matrix to apply
  61667. * @param result the vector to store the result in
  61668. */
  61669. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61670. /**
  61671. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  61672. * This methods computes transformed normalized direction vectors only.
  61673. * @param x value to transform
  61674. * @param y value to transform
  61675. * @param z value to transform
  61676. * @param w value to transform
  61677. * @param transformation the transformation matrix to apply
  61678. * @param result the vector to store the results in
  61679. */
  61680. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61681. /**
  61682. * Creates a new Vector4 from a Vector3
  61683. * @param source defines the source data
  61684. * @param w defines the 4th component (default is 0)
  61685. * @returns a new Vector4
  61686. */
  61687. static FromVector3(source: Vector3, w?: number): Vector4;
  61688. }
  61689. /**
  61690. * Interface for the size containing width and height
  61691. */
  61692. export interface ISize {
  61693. /**
  61694. * Width
  61695. */
  61696. width: number;
  61697. /**
  61698. * Heighht
  61699. */
  61700. height: number;
  61701. }
  61702. /**
  61703. * Size containing widht and height
  61704. */
  61705. export class Size implements ISize {
  61706. /**
  61707. * Width
  61708. */
  61709. width: number;
  61710. /**
  61711. * Height
  61712. */
  61713. height: number;
  61714. /**
  61715. * Creates a Size object from the given width and height (floats).
  61716. * @param width width of the new size
  61717. * @param height height of the new size
  61718. */
  61719. constructor(width: number, height: number);
  61720. /**
  61721. * Returns a string with the Size width and height
  61722. * @returns a string with the Size width and height
  61723. */
  61724. toString(): string;
  61725. /**
  61726. * "Size"
  61727. * @returns the string "Size"
  61728. */
  61729. getClassName(): string;
  61730. /**
  61731. * Returns the Size hash code.
  61732. * @returns a hash code for a unique width and height
  61733. */
  61734. getHashCode(): number;
  61735. /**
  61736. * Updates the current size from the given one.
  61737. * @param src the given size
  61738. */
  61739. copyFrom(src: Size): void;
  61740. /**
  61741. * Updates in place the current Size from the given floats.
  61742. * @param width width of the new size
  61743. * @param height height of the new size
  61744. * @returns the updated Size.
  61745. */
  61746. copyFromFloats(width: number, height: number): Size;
  61747. /**
  61748. * Updates in place the current Size from the given floats.
  61749. * @param width width to set
  61750. * @param height height to set
  61751. * @returns the updated Size.
  61752. */
  61753. set(width: number, height: number): Size;
  61754. /**
  61755. * Multiplies the width and height by numbers
  61756. * @param w factor to multiple the width by
  61757. * @param h factor to multiple the height by
  61758. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  61759. */
  61760. multiplyByFloats(w: number, h: number): Size;
  61761. /**
  61762. * Clones the size
  61763. * @returns a new Size copied from the given one.
  61764. */
  61765. clone(): Size;
  61766. /**
  61767. * True if the current Size and the given one width and height are strictly equal.
  61768. * @param other the other size to compare against
  61769. * @returns True if the current Size and the given one width and height are strictly equal.
  61770. */
  61771. equals(other: Size): boolean;
  61772. /**
  61773. * The surface of the Size : width * height (float).
  61774. */
  61775. readonly surface: number;
  61776. /**
  61777. * Create a new size of zero
  61778. * @returns a new Size set to (0.0, 0.0)
  61779. */
  61780. static Zero(): Size;
  61781. /**
  61782. * Sums the width and height of two sizes
  61783. * @param otherSize size to add to this size
  61784. * @returns a new Size set as the addition result of the current Size and the given one.
  61785. */
  61786. add(otherSize: Size): Size;
  61787. /**
  61788. * Subtracts the width and height of two
  61789. * @param otherSize size to subtract to this size
  61790. * @returns a new Size set as the subtraction result of the given one from the current Size.
  61791. */
  61792. subtract(otherSize: Size): Size;
  61793. /**
  61794. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  61795. * @param start starting size to lerp between
  61796. * @param end end size to lerp between
  61797. * @param amount amount to lerp between the start and end values
  61798. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  61799. */
  61800. static Lerp(start: Size, end: Size, amount: number): Size;
  61801. }
  61802. /**
  61803. * Class used to store quaternion data
  61804. * @see https://en.wikipedia.org/wiki/Quaternion
  61805. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  61806. */
  61807. export class Quaternion {
  61808. /** defines the first component (0 by default) */
  61809. x: number;
  61810. /** defines the second component (0 by default) */
  61811. y: number;
  61812. /** defines the third component (0 by default) */
  61813. z: number;
  61814. /** defines the fourth component (1.0 by default) */
  61815. w: number;
  61816. /**
  61817. * Creates a new Quaternion from the given floats
  61818. * @param x defines the first component (0 by default)
  61819. * @param y defines the second component (0 by default)
  61820. * @param z defines the third component (0 by default)
  61821. * @param w defines the fourth component (1.0 by default)
  61822. */
  61823. constructor(
  61824. /** defines the first component (0 by default) */
  61825. x?: number,
  61826. /** defines the second component (0 by default) */
  61827. y?: number,
  61828. /** defines the third component (0 by default) */
  61829. z?: number,
  61830. /** defines the fourth component (1.0 by default) */
  61831. w?: number);
  61832. /**
  61833. * Gets a string representation for the current quaternion
  61834. * @returns a string with the Quaternion coordinates
  61835. */
  61836. toString(): string;
  61837. /**
  61838. * Gets the class name of the quaternion
  61839. * @returns the string "Quaternion"
  61840. */
  61841. getClassName(): string;
  61842. /**
  61843. * Gets a hash code for this quaternion
  61844. * @returns the quaternion hash code
  61845. */
  61846. getHashCode(): number;
  61847. /**
  61848. * Copy the quaternion to an array
  61849. * @returns a new array populated with 4 elements from the quaternion coordinates
  61850. */
  61851. asArray(): number[];
  61852. /**
  61853. * Check if two quaternions are equals
  61854. * @param otherQuaternion defines the second operand
  61855. * @return true if the current quaternion and the given one coordinates are strictly equals
  61856. */
  61857. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  61858. /**
  61859. * Clone the current quaternion
  61860. * @returns a new quaternion copied from the current one
  61861. */
  61862. clone(): Quaternion;
  61863. /**
  61864. * Copy a quaternion to the current one
  61865. * @param other defines the other quaternion
  61866. * @returns the updated current quaternion
  61867. */
  61868. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  61869. /**
  61870. * Updates the current quaternion with the given float coordinates
  61871. * @param x defines the x coordinate
  61872. * @param y defines the y coordinate
  61873. * @param z defines the z coordinate
  61874. * @param w defines the w coordinate
  61875. * @returns the updated current quaternion
  61876. */
  61877. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  61878. /**
  61879. * Updates the current quaternion from the given float coordinates
  61880. * @param x defines the x coordinate
  61881. * @param y defines the y coordinate
  61882. * @param z defines the z coordinate
  61883. * @param w defines the w coordinate
  61884. * @returns the updated current quaternion
  61885. */
  61886. set(x: number, y: number, z: number, w: number): Quaternion;
  61887. /**
  61888. * Adds two quaternions
  61889. * @param other defines the second operand
  61890. * @returns a new quaternion as the addition result of the given one and the current quaternion
  61891. */
  61892. add(other: DeepImmutable<Quaternion>): Quaternion;
  61893. /**
  61894. * Add a quaternion to the current one
  61895. * @param other defines the quaternion to add
  61896. * @returns the current quaternion
  61897. */
  61898. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  61899. /**
  61900. * Subtract two quaternions
  61901. * @param other defines the second operand
  61902. * @returns a new quaternion as the subtraction result of the given one from the current one
  61903. */
  61904. subtract(other: Quaternion): Quaternion;
  61905. /**
  61906. * Multiplies the current quaternion by a scale factor
  61907. * @param value defines the scale factor
  61908. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  61909. */
  61910. scale(value: number): Quaternion;
  61911. /**
  61912. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  61913. * @param scale defines the scale factor
  61914. * @param result defines the Quaternion object where to store the result
  61915. * @returns the unmodified current quaternion
  61916. */
  61917. scaleToRef(scale: number, result: Quaternion): Quaternion;
  61918. /**
  61919. * Multiplies in place the current quaternion by a scale factor
  61920. * @param value defines the scale factor
  61921. * @returns the current modified quaternion
  61922. */
  61923. scaleInPlace(value: number): Quaternion;
  61924. /**
  61925. * Scale the current quaternion values by a factor and add the result to a given quaternion
  61926. * @param scale defines the scale factor
  61927. * @param result defines the Quaternion object where to store the result
  61928. * @returns the unmodified current quaternion
  61929. */
  61930. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  61931. /**
  61932. * Multiplies two quaternions
  61933. * @param q1 defines the second operand
  61934. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  61935. */
  61936. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  61937. /**
  61938. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  61939. * @param q1 defines the second operand
  61940. * @param result defines the target quaternion
  61941. * @returns the current quaternion
  61942. */
  61943. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  61944. /**
  61945. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  61946. * @param q1 defines the second operand
  61947. * @returns the currentupdated quaternion
  61948. */
  61949. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  61950. /**
  61951. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  61952. * @param ref defines the target quaternion
  61953. * @returns the current quaternion
  61954. */
  61955. conjugateToRef(ref: Quaternion): Quaternion;
  61956. /**
  61957. * Conjugates in place (1-q) the current quaternion
  61958. * @returns the current updated quaternion
  61959. */
  61960. conjugateInPlace(): Quaternion;
  61961. /**
  61962. * Conjugates in place (1-q) the current quaternion
  61963. * @returns a new quaternion
  61964. */
  61965. conjugate(): Quaternion;
  61966. /**
  61967. * Gets length of current quaternion
  61968. * @returns the quaternion length (float)
  61969. */
  61970. length(): number;
  61971. /**
  61972. * Normalize in place the current quaternion
  61973. * @returns the current updated quaternion
  61974. */
  61975. normalize(): Quaternion;
  61976. /**
  61977. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  61978. * @param order is a reserved parameter and is ignore for now
  61979. * @returns a new Vector3 containing the Euler angles
  61980. */
  61981. toEulerAngles(order?: string): Vector3;
  61982. /**
  61983. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  61984. * @param result defines the vector which will be filled with the Euler angles
  61985. * @param order is a reserved parameter and is ignore for now
  61986. * @returns the current unchanged quaternion
  61987. */
  61988. toEulerAnglesToRef(result: Vector3): Quaternion;
  61989. /**
  61990. * Updates the given rotation matrix with the current quaternion values
  61991. * @param result defines the target matrix
  61992. * @returns the current unchanged quaternion
  61993. */
  61994. toRotationMatrix(result: Matrix): Quaternion;
  61995. /**
  61996. * Updates the current quaternion from the given rotation matrix values
  61997. * @param matrix defines the source matrix
  61998. * @returns the current updated quaternion
  61999. */
  62000. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62001. /**
  62002. * Creates a new quaternion from a rotation matrix
  62003. * @param matrix defines the source matrix
  62004. * @returns a new quaternion created from the given rotation matrix values
  62005. */
  62006. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62007. /**
  62008. * Updates the given quaternion with the given rotation matrix values
  62009. * @param matrix defines the source matrix
  62010. * @param result defines the target quaternion
  62011. */
  62012. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62013. /**
  62014. * Returns the dot product (float) between the quaternions "left" and "right"
  62015. * @param left defines the left operand
  62016. * @param right defines the right operand
  62017. * @returns the dot product
  62018. */
  62019. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62020. /**
  62021. * Checks if the two quaternions are close to each other
  62022. * @param quat0 defines the first quaternion to check
  62023. * @param quat1 defines the second quaternion to check
  62024. * @returns true if the two quaternions are close to each other
  62025. */
  62026. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62027. /**
  62028. * Creates an empty quaternion
  62029. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62030. */
  62031. static Zero(): Quaternion;
  62032. /**
  62033. * Inverse a given quaternion
  62034. * @param q defines the source quaternion
  62035. * @returns a new quaternion as the inverted current quaternion
  62036. */
  62037. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62038. /**
  62039. * Inverse a given quaternion
  62040. * @param q defines the source quaternion
  62041. * @param result the quaternion the result will be stored in
  62042. * @returns the result quaternion
  62043. */
  62044. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62045. /**
  62046. * Creates an identity quaternion
  62047. * @returns the identity quaternion
  62048. */
  62049. static Identity(): Quaternion;
  62050. /**
  62051. * Gets a boolean indicating if the given quaternion is identity
  62052. * @param quaternion defines the quaternion to check
  62053. * @returns true if the quaternion is identity
  62054. */
  62055. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62056. /**
  62057. * Creates a quaternion from a rotation around an axis
  62058. * @param axis defines the axis to use
  62059. * @param angle defines the angle to use
  62060. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62061. */
  62062. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62063. /**
  62064. * Creates a rotation around an axis and stores it into the given quaternion
  62065. * @param axis defines the axis to use
  62066. * @param angle defines the angle to use
  62067. * @param result defines the target quaternion
  62068. * @returns the target quaternion
  62069. */
  62070. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62071. /**
  62072. * Creates a new quaternion from data stored into an array
  62073. * @param array defines the data source
  62074. * @param offset defines the offset in the source array where the data starts
  62075. * @returns a new quaternion
  62076. */
  62077. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62078. /**
  62079. * Create a quaternion from Euler rotation angles
  62080. * @param x Pitch
  62081. * @param y Yaw
  62082. * @param z Roll
  62083. * @returns the new Quaternion
  62084. */
  62085. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62086. /**
  62087. * Updates a quaternion from Euler rotation angles
  62088. * @param x Pitch
  62089. * @param y Yaw
  62090. * @param z Roll
  62091. * @param result the quaternion to store the result
  62092. * @returns the updated quaternion
  62093. */
  62094. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62095. /**
  62096. * Create a quaternion from Euler rotation vector
  62097. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62098. * @returns the new Quaternion
  62099. */
  62100. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62101. /**
  62102. * Updates a quaternion from Euler rotation vector
  62103. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62104. * @param result the quaternion to store the result
  62105. * @returns the updated quaternion
  62106. */
  62107. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62108. /**
  62109. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62110. * @param yaw defines the rotation around Y axis
  62111. * @param pitch defines the rotation around X axis
  62112. * @param roll defines the rotation around Z axis
  62113. * @returns the new quaternion
  62114. */
  62115. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62116. /**
  62117. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62118. * @param yaw defines the rotation around Y axis
  62119. * @param pitch defines the rotation around X axis
  62120. * @param roll defines the rotation around Z axis
  62121. * @param result defines the target quaternion
  62122. */
  62123. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62124. /**
  62125. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62126. * @param alpha defines the rotation around first axis
  62127. * @param beta defines the rotation around second axis
  62128. * @param gamma defines the rotation around third axis
  62129. * @returns the new quaternion
  62130. */
  62131. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62132. /**
  62133. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62134. * @param alpha defines the rotation around first axis
  62135. * @param beta defines the rotation around second axis
  62136. * @param gamma defines the rotation around third axis
  62137. * @param result defines the target quaternion
  62138. */
  62139. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62140. /**
  62141. * 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)
  62142. * @param axis1 defines the first axis
  62143. * @param axis2 defines the second axis
  62144. * @param axis3 defines the third axis
  62145. * @returns the new quaternion
  62146. */
  62147. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62148. /**
  62149. * 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
  62150. * @param axis1 defines the first axis
  62151. * @param axis2 defines the second axis
  62152. * @param axis3 defines the third axis
  62153. * @param ref defines the target quaternion
  62154. */
  62155. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62156. /**
  62157. * Interpolates between two quaternions
  62158. * @param left defines first quaternion
  62159. * @param right defines second quaternion
  62160. * @param amount defines the gradient to use
  62161. * @returns the new interpolated quaternion
  62162. */
  62163. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62164. /**
  62165. * Interpolates between two quaternions and stores it into a target quaternion
  62166. * @param left defines first quaternion
  62167. * @param right defines second quaternion
  62168. * @param amount defines the gradient to use
  62169. * @param result defines the target quaternion
  62170. */
  62171. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62172. /**
  62173. * Interpolate between two quaternions using Hermite interpolation
  62174. * @param value1 defines first quaternion
  62175. * @param tangent1 defines the incoming tangent
  62176. * @param value2 defines second quaternion
  62177. * @param tangent2 defines the outgoing tangent
  62178. * @param amount defines the target quaternion
  62179. * @returns the new interpolated quaternion
  62180. */
  62181. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62182. }
  62183. /**
  62184. * Class used to store matrix data (4x4)
  62185. */
  62186. export class Matrix {
  62187. private static _updateFlagSeed;
  62188. private static _identityReadOnly;
  62189. private _isIdentity;
  62190. private _isIdentityDirty;
  62191. private _isIdentity3x2;
  62192. private _isIdentity3x2Dirty;
  62193. /**
  62194. * Gets the update flag of the matrix which is an unique number for the matrix.
  62195. * It will be incremented every time the matrix data change.
  62196. * You can use it to speed the comparison between two versions of the same matrix.
  62197. */
  62198. updateFlag: number;
  62199. private readonly _m;
  62200. /**
  62201. * Gets the internal data of the matrix
  62202. */
  62203. readonly m: DeepImmutable<Float32Array>;
  62204. /** @hidden */
  62205. _markAsUpdated(): void;
  62206. /** @hidden */
  62207. private _updateIdentityStatus;
  62208. /**
  62209. * Creates an empty matrix (filled with zeros)
  62210. */
  62211. constructor();
  62212. /**
  62213. * Check if the current matrix is identity
  62214. * @returns true is the matrix is the identity matrix
  62215. */
  62216. isIdentity(): boolean;
  62217. /**
  62218. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62219. * @returns true is the matrix is the identity matrix
  62220. */
  62221. isIdentityAs3x2(): boolean;
  62222. /**
  62223. * Gets the determinant of the matrix
  62224. * @returns the matrix determinant
  62225. */
  62226. determinant(): number;
  62227. /**
  62228. * Returns the matrix as a Float32Array
  62229. * @returns the matrix underlying array
  62230. */
  62231. toArray(): DeepImmutable<Float32Array>;
  62232. /**
  62233. * Returns the matrix as a Float32Array
  62234. * @returns the matrix underlying array.
  62235. */
  62236. asArray(): DeepImmutable<Float32Array>;
  62237. /**
  62238. * Inverts the current matrix in place
  62239. * @returns the current inverted matrix
  62240. */
  62241. invert(): Matrix;
  62242. /**
  62243. * Sets all the matrix elements to zero
  62244. * @returns the current matrix
  62245. */
  62246. reset(): Matrix;
  62247. /**
  62248. * Adds the current matrix with a second one
  62249. * @param other defines the matrix to add
  62250. * @returns a new matrix as the addition of the current matrix and the given one
  62251. */
  62252. add(other: DeepImmutable<Matrix>): Matrix;
  62253. /**
  62254. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62255. * @param other defines the matrix to add
  62256. * @param result defines the target matrix
  62257. * @returns the current matrix
  62258. */
  62259. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62260. /**
  62261. * Adds in place the given matrix to the current matrix
  62262. * @param other defines the second operand
  62263. * @returns the current updated matrix
  62264. */
  62265. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62266. /**
  62267. * Sets the given matrix to the current inverted Matrix
  62268. * @param other defines the target matrix
  62269. * @returns the unmodified current matrix
  62270. */
  62271. invertToRef(other: Matrix): Matrix;
  62272. /**
  62273. * add a value at the specified position in the current Matrix
  62274. * @param index the index of the value within the matrix. between 0 and 15.
  62275. * @param value the value to be added
  62276. * @returns the current updated matrix
  62277. */
  62278. addAtIndex(index: number, value: number): Matrix;
  62279. /**
  62280. * mutiply the specified position in the current Matrix by a value
  62281. * @param index the index of the value within the matrix. between 0 and 15.
  62282. * @param value the value to be added
  62283. * @returns the current updated matrix
  62284. */
  62285. multiplyAtIndex(index: number, value: number): Matrix;
  62286. /**
  62287. * Inserts the translation vector (using 3 floats) in the current matrix
  62288. * @param x defines the 1st component of the translation
  62289. * @param y defines the 2nd component of the translation
  62290. * @param z defines the 3rd component of the translation
  62291. * @returns the current updated matrix
  62292. */
  62293. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62294. /**
  62295. * Inserts the translation vector in the current matrix
  62296. * @param vector3 defines the translation to insert
  62297. * @returns the current updated matrix
  62298. */
  62299. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62300. /**
  62301. * Gets the translation value of the current matrix
  62302. * @returns a new Vector3 as the extracted translation from the matrix
  62303. */
  62304. getTranslation(): Vector3;
  62305. /**
  62306. * Fill a Vector3 with the extracted translation from the matrix
  62307. * @param result defines the Vector3 where to store the translation
  62308. * @returns the current matrix
  62309. */
  62310. getTranslationToRef(result: Vector3): Matrix;
  62311. /**
  62312. * Remove rotation and scaling part from the matrix
  62313. * @returns the updated matrix
  62314. */
  62315. removeRotationAndScaling(): Matrix;
  62316. /**
  62317. * Multiply two matrices
  62318. * @param other defines the second operand
  62319. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62320. */
  62321. multiply(other: DeepImmutable<Matrix>): Matrix;
  62322. /**
  62323. * Copy the current matrix from the given one
  62324. * @param other defines the source matrix
  62325. * @returns the current updated matrix
  62326. */
  62327. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62328. /**
  62329. * Populates the given array from the starting index with the current matrix values
  62330. * @param array defines the target array
  62331. * @param offset defines the offset in the target array where to start storing values
  62332. * @returns the current matrix
  62333. */
  62334. copyToArray(array: Float32Array, offset?: number): Matrix;
  62335. /**
  62336. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62337. * @param other defines the second operand
  62338. * @param result defines the matrix where to store the multiplication
  62339. * @returns the current matrix
  62340. */
  62341. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62342. /**
  62343. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62344. * @param other defines the second operand
  62345. * @param result defines the array where to store the multiplication
  62346. * @param offset defines the offset in the target array where to start storing values
  62347. * @returns the current matrix
  62348. */
  62349. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62350. /**
  62351. * Check equality between this matrix and a second one
  62352. * @param value defines the second matrix to compare
  62353. * @returns true is the current matrix and the given one values are strictly equal
  62354. */
  62355. equals(value: DeepImmutable<Matrix>): boolean;
  62356. /**
  62357. * Clone the current matrix
  62358. * @returns a new matrix from the current matrix
  62359. */
  62360. clone(): Matrix;
  62361. /**
  62362. * Returns the name of the current matrix class
  62363. * @returns the string "Matrix"
  62364. */
  62365. getClassName(): string;
  62366. /**
  62367. * Gets the hash code of the current matrix
  62368. * @returns the hash code
  62369. */
  62370. getHashCode(): number;
  62371. /**
  62372. * Decomposes the current Matrix into a translation, rotation and scaling components
  62373. * @param scale defines the scale vector3 given as a reference to update
  62374. * @param rotation defines the rotation quaternion given as a reference to update
  62375. * @param translation defines the translation vector3 given as a reference to update
  62376. * @returns true if operation was successful
  62377. */
  62378. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62379. /**
  62380. * Gets specific row of the matrix
  62381. * @param index defines the number of the row to get
  62382. * @returns the index-th row of the current matrix as a new Vector4
  62383. */
  62384. getRow(index: number): Nullable<Vector4>;
  62385. /**
  62386. * Sets the index-th row of the current matrix to the vector4 values
  62387. * @param index defines the number of the row to set
  62388. * @param row defines the target vector4
  62389. * @returns the updated current matrix
  62390. */
  62391. setRow(index: number, row: Vector4): Matrix;
  62392. /**
  62393. * Compute the transpose of the matrix
  62394. * @returns the new transposed matrix
  62395. */
  62396. transpose(): Matrix;
  62397. /**
  62398. * Compute the transpose of the matrix and store it in a given matrix
  62399. * @param result defines the target matrix
  62400. * @returns the current matrix
  62401. */
  62402. transposeToRef(result: Matrix): Matrix;
  62403. /**
  62404. * Sets the index-th row of the current matrix with the given 4 x float values
  62405. * @param index defines the row index
  62406. * @param x defines the x component to set
  62407. * @param y defines the y component to set
  62408. * @param z defines the z component to set
  62409. * @param w defines the w component to set
  62410. * @returns the updated current matrix
  62411. */
  62412. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62413. /**
  62414. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62415. * @param scale defines the scale factor
  62416. * @returns a new matrix
  62417. */
  62418. scale(scale: number): Matrix;
  62419. /**
  62420. * Scale the current matrix values by a factor to a given result matrix
  62421. * @param scale defines the scale factor
  62422. * @param result defines the matrix to store the result
  62423. * @returns the current matrix
  62424. */
  62425. scaleToRef(scale: number, result: Matrix): Matrix;
  62426. /**
  62427. * Scale the current matrix values by a factor and add the result to a given matrix
  62428. * @param scale defines the scale factor
  62429. * @param result defines the Matrix to store the result
  62430. * @returns the current matrix
  62431. */
  62432. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  62433. /**
  62434. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  62435. * @param ref matrix to store the result
  62436. */
  62437. toNormalMatrix(ref: Matrix): void;
  62438. /**
  62439. * Gets only rotation part of the current matrix
  62440. * @returns a new matrix sets to the extracted rotation matrix from the current one
  62441. */
  62442. getRotationMatrix(): Matrix;
  62443. /**
  62444. * Extracts the rotation matrix from the current one and sets it as the given "result"
  62445. * @param result defines the target matrix to store data to
  62446. * @returns the current matrix
  62447. */
  62448. getRotationMatrixToRef(result: Matrix): Matrix;
  62449. /**
  62450. * Toggles model matrix from being right handed to left handed in place and vice versa
  62451. */
  62452. toggleModelMatrixHandInPlace(): void;
  62453. /**
  62454. * Toggles projection matrix from being right handed to left handed in place and vice versa
  62455. */
  62456. toggleProjectionMatrixHandInPlace(): void;
  62457. /**
  62458. * Creates a matrix from an array
  62459. * @param array defines the source array
  62460. * @param offset defines an offset in the source array
  62461. * @returns a new Matrix set from the starting index of the given array
  62462. */
  62463. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  62464. /**
  62465. * Copy the content of an array into a given matrix
  62466. * @param array defines the source array
  62467. * @param offset defines an offset in the source array
  62468. * @param result defines the target matrix
  62469. */
  62470. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  62471. /**
  62472. * Stores an array into a matrix after having multiplied each component by a given factor
  62473. * @param array defines the source array
  62474. * @param offset defines the offset in the source array
  62475. * @param scale defines the scaling factor
  62476. * @param result defines the target matrix
  62477. */
  62478. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  62479. /**
  62480. * Gets an identity matrix that must not be updated
  62481. */
  62482. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  62483. /**
  62484. * Stores a list of values (16) inside a given matrix
  62485. * @param initialM11 defines 1st value of 1st row
  62486. * @param initialM12 defines 2nd value of 1st row
  62487. * @param initialM13 defines 3rd value of 1st row
  62488. * @param initialM14 defines 4th value of 1st row
  62489. * @param initialM21 defines 1st value of 2nd row
  62490. * @param initialM22 defines 2nd value of 2nd row
  62491. * @param initialM23 defines 3rd value of 2nd row
  62492. * @param initialM24 defines 4th value of 2nd row
  62493. * @param initialM31 defines 1st value of 3rd row
  62494. * @param initialM32 defines 2nd value of 3rd row
  62495. * @param initialM33 defines 3rd value of 3rd row
  62496. * @param initialM34 defines 4th value of 3rd row
  62497. * @param initialM41 defines 1st value of 4th row
  62498. * @param initialM42 defines 2nd value of 4th row
  62499. * @param initialM43 defines 3rd value of 4th row
  62500. * @param initialM44 defines 4th value of 4th row
  62501. * @param result defines the target matrix
  62502. */
  62503. 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;
  62504. /**
  62505. * Creates new matrix from a list of values (16)
  62506. * @param initialM11 defines 1st value of 1st row
  62507. * @param initialM12 defines 2nd value of 1st row
  62508. * @param initialM13 defines 3rd value of 1st row
  62509. * @param initialM14 defines 4th value of 1st row
  62510. * @param initialM21 defines 1st value of 2nd row
  62511. * @param initialM22 defines 2nd value of 2nd row
  62512. * @param initialM23 defines 3rd value of 2nd row
  62513. * @param initialM24 defines 4th value of 2nd row
  62514. * @param initialM31 defines 1st value of 3rd row
  62515. * @param initialM32 defines 2nd value of 3rd row
  62516. * @param initialM33 defines 3rd value of 3rd row
  62517. * @param initialM34 defines 4th value of 3rd row
  62518. * @param initialM41 defines 1st value of 4th row
  62519. * @param initialM42 defines 2nd value of 4th row
  62520. * @param initialM43 defines 3rd value of 4th row
  62521. * @param initialM44 defines 4th value of 4th row
  62522. * @returns the new matrix
  62523. */
  62524. 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;
  62525. /**
  62526. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62527. * @param scale defines the scale vector3
  62528. * @param rotation defines the rotation quaternion
  62529. * @param translation defines the translation vector3
  62530. * @returns a new matrix
  62531. */
  62532. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  62533. /**
  62534. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62535. * @param scale defines the scale vector3
  62536. * @param rotation defines the rotation quaternion
  62537. * @param translation defines the translation vector3
  62538. * @param result defines the target matrix
  62539. */
  62540. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  62541. /**
  62542. * Creates a new identity matrix
  62543. * @returns a new identity matrix
  62544. */
  62545. static Identity(): Matrix;
  62546. /**
  62547. * Creates a new identity matrix and stores the result in a given matrix
  62548. * @param result defines the target matrix
  62549. */
  62550. static IdentityToRef(result: Matrix): void;
  62551. /**
  62552. * Creates a new zero matrix
  62553. * @returns a new zero matrix
  62554. */
  62555. static Zero(): Matrix;
  62556. /**
  62557. * Creates a new rotation matrix for "angle" radians around the X axis
  62558. * @param angle defines the angle (in radians) to use
  62559. * @return the new matrix
  62560. */
  62561. static RotationX(angle: number): Matrix;
  62562. /**
  62563. * Creates a new matrix as the invert of a given matrix
  62564. * @param source defines the source matrix
  62565. * @returns the new matrix
  62566. */
  62567. static Invert(source: DeepImmutable<Matrix>): Matrix;
  62568. /**
  62569. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  62570. * @param angle defines the angle (in radians) to use
  62571. * @param result defines the target matrix
  62572. */
  62573. static RotationXToRef(angle: number, result: Matrix): void;
  62574. /**
  62575. * Creates a new rotation matrix for "angle" radians around the Y axis
  62576. * @param angle defines the angle (in radians) to use
  62577. * @return the new matrix
  62578. */
  62579. static RotationY(angle: number): Matrix;
  62580. /**
  62581. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  62582. * @param angle defines the angle (in radians) to use
  62583. * @param result defines the target matrix
  62584. */
  62585. static RotationYToRef(angle: number, result: Matrix): void;
  62586. /**
  62587. * Creates a new rotation matrix for "angle" radians around the Z axis
  62588. * @param angle defines the angle (in radians) to use
  62589. * @return the new matrix
  62590. */
  62591. static RotationZ(angle: number): Matrix;
  62592. /**
  62593. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  62594. * @param angle defines the angle (in radians) to use
  62595. * @param result defines the target matrix
  62596. */
  62597. static RotationZToRef(angle: number, result: Matrix): void;
  62598. /**
  62599. * Creates a new rotation matrix for "angle" radians around the given axis
  62600. * @param axis defines the axis to use
  62601. * @param angle defines the angle (in radians) to use
  62602. * @return the new matrix
  62603. */
  62604. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  62605. /**
  62606. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  62607. * @param axis defines the axis to use
  62608. * @param angle defines the angle (in radians) to use
  62609. * @param result defines the target matrix
  62610. */
  62611. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  62612. /**
  62613. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  62614. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  62615. * @param from defines the vector to align
  62616. * @param to defines the vector to align to
  62617. * @param result defines the target matrix
  62618. */
  62619. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  62620. /**
  62621. * Creates a rotation matrix
  62622. * @param yaw defines the yaw angle in radians (Y axis)
  62623. * @param pitch defines the pitch angle in radians (X axis)
  62624. * @param roll defines the roll angle in radians (X axis)
  62625. * @returns the new rotation matrix
  62626. */
  62627. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  62628. /**
  62629. * Creates a rotation matrix and stores it in a given matrix
  62630. * @param yaw defines the yaw angle in radians (Y axis)
  62631. * @param pitch defines the pitch angle in radians (X axis)
  62632. * @param roll defines the roll angle in radians (X axis)
  62633. * @param result defines the target matrix
  62634. */
  62635. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  62636. /**
  62637. * Creates a scaling matrix
  62638. * @param x defines the scale factor on X axis
  62639. * @param y defines the scale factor on Y axis
  62640. * @param z defines the scale factor on Z axis
  62641. * @returns the new matrix
  62642. */
  62643. static Scaling(x: number, y: number, z: number): Matrix;
  62644. /**
  62645. * Creates a scaling matrix and stores it in a given matrix
  62646. * @param x defines the scale factor on X axis
  62647. * @param y defines the scale factor on Y axis
  62648. * @param z defines the scale factor on Z axis
  62649. * @param result defines the target matrix
  62650. */
  62651. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  62652. /**
  62653. * Creates a translation matrix
  62654. * @param x defines the translation on X axis
  62655. * @param y defines the translation on Y axis
  62656. * @param z defines the translationon Z axis
  62657. * @returns the new matrix
  62658. */
  62659. static Translation(x: number, y: number, z: number): Matrix;
  62660. /**
  62661. * Creates a translation matrix and stores it in a given matrix
  62662. * @param x defines the translation on X axis
  62663. * @param y defines the translation on Y axis
  62664. * @param z defines the translationon Z axis
  62665. * @param result defines the target matrix
  62666. */
  62667. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  62668. /**
  62669. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62670. * @param startValue defines the start value
  62671. * @param endValue defines the end value
  62672. * @param gradient defines the gradient factor
  62673. * @returns the new matrix
  62674. */
  62675. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62676. /**
  62677. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62678. * @param startValue defines the start value
  62679. * @param endValue defines the end value
  62680. * @param gradient defines the gradient factor
  62681. * @param result defines the Matrix object where to store data
  62682. */
  62683. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62684. /**
  62685. * Builds a new matrix whose values are computed by:
  62686. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62687. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62688. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62689. * @param startValue defines the first matrix
  62690. * @param endValue defines the second matrix
  62691. * @param gradient defines the gradient between the two matrices
  62692. * @returns the new matrix
  62693. */
  62694. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62695. /**
  62696. * Update a matrix to values which are computed by:
  62697. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62698. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62699. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62700. * @param startValue defines the first matrix
  62701. * @param endValue defines the second matrix
  62702. * @param gradient defines the gradient between the two matrices
  62703. * @param result defines the target matrix
  62704. */
  62705. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62706. /**
  62707. * 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"
  62708. * This function works in left handed mode
  62709. * @param eye defines the final position of the entity
  62710. * @param target defines where the entity should look at
  62711. * @param up defines the up vector for the entity
  62712. * @returns the new matrix
  62713. */
  62714. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62715. /**
  62716. * 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".
  62717. * This function works in left handed mode
  62718. * @param eye defines the final position of the entity
  62719. * @param target defines where the entity should look at
  62720. * @param up defines the up vector for the entity
  62721. * @param result defines the target matrix
  62722. */
  62723. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62724. /**
  62725. * 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"
  62726. * This function works in right handed mode
  62727. * @param eye defines the final position of the entity
  62728. * @param target defines where the entity should look at
  62729. * @param up defines the up vector for the entity
  62730. * @returns the new matrix
  62731. */
  62732. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62733. /**
  62734. * 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".
  62735. * This function works in right handed mode
  62736. * @param eye defines the final position of the entity
  62737. * @param target defines where the entity should look at
  62738. * @param up defines the up vector for the entity
  62739. * @param result defines the target matrix
  62740. */
  62741. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62742. /**
  62743. * Create a left-handed orthographic projection matrix
  62744. * @param width defines the viewport width
  62745. * @param height defines the viewport height
  62746. * @param znear defines the near clip plane
  62747. * @param zfar defines the far clip plane
  62748. * @returns a new matrix as a left-handed orthographic projection matrix
  62749. */
  62750. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62751. /**
  62752. * Store a left-handed orthographic projection to a given matrix
  62753. * @param width defines the viewport width
  62754. * @param height defines the viewport height
  62755. * @param znear defines the near clip plane
  62756. * @param zfar defines the far clip plane
  62757. * @param result defines the target matrix
  62758. */
  62759. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  62760. /**
  62761. * Create a left-handed orthographic projection matrix
  62762. * @param left defines the viewport left coordinate
  62763. * @param right defines the viewport right coordinate
  62764. * @param bottom defines the viewport bottom coordinate
  62765. * @param top defines the viewport top coordinate
  62766. * @param znear defines the near clip plane
  62767. * @param zfar defines the far clip plane
  62768. * @returns a new matrix as a left-handed orthographic projection matrix
  62769. */
  62770. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62771. /**
  62772. * Stores a left-handed orthographic projection into a given matrix
  62773. * @param left defines the viewport left coordinate
  62774. * @param right defines the viewport right coordinate
  62775. * @param bottom defines the viewport bottom coordinate
  62776. * @param top defines the viewport top coordinate
  62777. * @param znear defines the near clip plane
  62778. * @param zfar defines the far clip plane
  62779. * @param result defines the target matrix
  62780. */
  62781. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62782. /**
  62783. * Creates a right-handed orthographic projection matrix
  62784. * @param left defines the viewport left coordinate
  62785. * @param right defines the viewport right coordinate
  62786. * @param bottom defines the viewport bottom coordinate
  62787. * @param top defines the viewport top coordinate
  62788. * @param znear defines the near clip plane
  62789. * @param zfar defines the far clip plane
  62790. * @returns a new matrix as a right-handed orthographic projection matrix
  62791. */
  62792. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62793. /**
  62794. * Stores a right-handed orthographic projection into a given matrix
  62795. * @param left defines the viewport left coordinate
  62796. * @param right defines the viewport right coordinate
  62797. * @param bottom defines the viewport bottom coordinate
  62798. * @param top defines the viewport top coordinate
  62799. * @param znear defines the near clip plane
  62800. * @param zfar defines the far clip plane
  62801. * @param result defines the target matrix
  62802. */
  62803. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62804. /**
  62805. * Creates a left-handed perspective projection matrix
  62806. * @param width defines the viewport width
  62807. * @param height defines the viewport height
  62808. * @param znear defines the near clip plane
  62809. * @param zfar defines the far clip plane
  62810. * @returns a new matrix as a left-handed perspective projection matrix
  62811. */
  62812. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62813. /**
  62814. * Creates a left-handed perspective projection matrix
  62815. * @param fov defines the horizontal field of view
  62816. * @param aspect defines the aspect ratio
  62817. * @param znear defines the near clip plane
  62818. * @param zfar defines the far clip plane
  62819. * @returns a new matrix as a left-handed perspective projection matrix
  62820. */
  62821. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62822. /**
  62823. * Stores a left-handed perspective projection into a given matrix
  62824. * @param fov defines the horizontal field of view
  62825. * @param aspect defines the aspect ratio
  62826. * @param znear defines the near clip plane
  62827. * @param zfar defines the far clip plane
  62828. * @param result defines the target matrix
  62829. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62830. */
  62831. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62832. /**
  62833. * Creates a right-handed perspective projection matrix
  62834. * @param fov defines the horizontal field of view
  62835. * @param aspect defines the aspect ratio
  62836. * @param znear defines the near clip plane
  62837. * @param zfar defines the far clip plane
  62838. * @returns a new matrix as a right-handed perspective projection matrix
  62839. */
  62840. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62841. /**
  62842. * Stores a right-handed perspective projection into a given matrix
  62843. * @param fov defines the horizontal field of view
  62844. * @param aspect defines the aspect ratio
  62845. * @param znear defines the near clip plane
  62846. * @param zfar defines the far clip plane
  62847. * @param result defines the target matrix
  62848. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62849. */
  62850. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62851. /**
  62852. * Stores a perspective projection for WebVR info a given matrix
  62853. * @param fov defines the field of view
  62854. * @param znear defines the near clip plane
  62855. * @param zfar defines the far clip plane
  62856. * @param result defines the target matrix
  62857. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  62858. */
  62859. static PerspectiveFovWebVRToRef(fov: {
  62860. upDegrees: number;
  62861. downDegrees: number;
  62862. leftDegrees: number;
  62863. rightDegrees: number;
  62864. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  62865. /**
  62866. * Computes a complete transformation matrix
  62867. * @param viewport defines the viewport to use
  62868. * @param world defines the world matrix
  62869. * @param view defines the view matrix
  62870. * @param projection defines the projection matrix
  62871. * @param zmin defines the near clip plane
  62872. * @param zmax defines the far clip plane
  62873. * @returns the transformation matrix
  62874. */
  62875. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  62876. /**
  62877. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  62878. * @param matrix defines the matrix to use
  62879. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  62880. */
  62881. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  62882. /**
  62883. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  62884. * @param matrix defines the matrix to use
  62885. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  62886. */
  62887. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  62888. /**
  62889. * Compute the transpose of a given matrix
  62890. * @param matrix defines the matrix to transpose
  62891. * @returns the new matrix
  62892. */
  62893. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  62894. /**
  62895. * Compute the transpose of a matrix and store it in a target matrix
  62896. * @param matrix defines the matrix to transpose
  62897. * @param result defines the target matrix
  62898. */
  62899. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  62900. /**
  62901. * Computes a reflection matrix from a plane
  62902. * @param plane defines the reflection plane
  62903. * @returns a new matrix
  62904. */
  62905. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  62906. /**
  62907. * Computes a reflection matrix from a plane
  62908. * @param plane defines the reflection plane
  62909. * @param result defines the target matrix
  62910. */
  62911. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  62912. /**
  62913. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  62914. * @param xaxis defines the value of the 1st axis
  62915. * @param yaxis defines the value of the 2nd axis
  62916. * @param zaxis defines the value of the 3rd axis
  62917. * @param result defines the target matrix
  62918. */
  62919. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  62920. /**
  62921. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  62922. * @param quat defines the quaternion to use
  62923. * @param result defines the target matrix
  62924. */
  62925. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  62926. }
  62927. /**
  62928. * Represens a plane by the equation ax + by + cz + d = 0
  62929. */
  62930. export class Plane {
  62931. /**
  62932. * Normal of the plane (a,b,c)
  62933. */
  62934. normal: Vector3;
  62935. /**
  62936. * d component of the plane
  62937. */
  62938. d: number;
  62939. /**
  62940. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  62941. * @param a a component of the plane
  62942. * @param b b component of the plane
  62943. * @param c c component of the plane
  62944. * @param d d component of the plane
  62945. */
  62946. constructor(a: number, b: number, c: number, d: number);
  62947. /**
  62948. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  62949. */
  62950. asArray(): number[];
  62951. /**
  62952. * @returns a new plane copied from the current Plane.
  62953. */
  62954. clone(): Plane;
  62955. /**
  62956. * @returns the string "Plane".
  62957. */
  62958. getClassName(): string;
  62959. /**
  62960. * @returns the Plane hash code.
  62961. */
  62962. getHashCode(): number;
  62963. /**
  62964. * Normalize the current Plane in place.
  62965. * @returns the updated Plane.
  62966. */
  62967. normalize(): Plane;
  62968. /**
  62969. * Applies a transformation the plane and returns the result
  62970. * @param transformation the transformation matrix to be applied to the plane
  62971. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  62972. */
  62973. transform(transformation: DeepImmutable<Matrix>): Plane;
  62974. /**
  62975. * Calcualtte the dot product between the point and the plane normal
  62976. * @param point point to calculate the dot product with
  62977. * @returns the dot product (float) of the point coordinates and the plane normal.
  62978. */
  62979. dotCoordinate(point: DeepImmutable<Vector3>): number;
  62980. /**
  62981. * Updates the current Plane from the plane defined by the three given points.
  62982. * @param point1 one of the points used to contruct the plane
  62983. * @param point2 one of the points used to contruct the plane
  62984. * @param point3 one of the points used to contruct the plane
  62985. * @returns the updated Plane.
  62986. */
  62987. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62988. /**
  62989. * Checks if the plane is facing a given direction
  62990. * @param direction the direction to check if the plane is facing
  62991. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  62992. * @returns True is the vector "direction" is the same side than the plane normal.
  62993. */
  62994. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  62995. /**
  62996. * Calculates the distance to a point
  62997. * @param point point to calculate distance to
  62998. * @returns the signed distance (float) from the given point to the Plane.
  62999. */
  63000. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63001. /**
  63002. * Creates a plane from an array
  63003. * @param array the array to create a plane from
  63004. * @returns a new Plane from the given array.
  63005. */
  63006. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63007. /**
  63008. * Creates a plane from three points
  63009. * @param point1 point used to create the plane
  63010. * @param point2 point used to create the plane
  63011. * @param point3 point used to create the plane
  63012. * @returns a new Plane defined by the three given points.
  63013. */
  63014. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63015. /**
  63016. * Creates a plane from an origin point and a normal
  63017. * @param origin origin of the plane to be constructed
  63018. * @param normal normal of the plane to be constructed
  63019. * @returns a new Plane the normal vector to this plane at the given origin point.
  63020. * Note : the vector "normal" is updated because normalized.
  63021. */
  63022. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63023. /**
  63024. * Calculates the distance from a plane and a point
  63025. * @param origin origin of the plane to be constructed
  63026. * @param normal normal of the plane to be constructed
  63027. * @param point point to calculate distance to
  63028. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63029. */
  63030. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63031. }
  63032. /**
  63033. * Class used to represent a viewport on screen
  63034. */
  63035. export class Viewport {
  63036. /** viewport left coordinate */
  63037. x: number;
  63038. /** viewport top coordinate */
  63039. y: number;
  63040. /**viewport width */
  63041. width: number;
  63042. /** viewport height */
  63043. height: number;
  63044. /**
  63045. * Creates a Viewport object located at (x, y) and sized (width, height)
  63046. * @param x defines viewport left coordinate
  63047. * @param y defines viewport top coordinate
  63048. * @param width defines the viewport width
  63049. * @param height defines the viewport height
  63050. */
  63051. constructor(
  63052. /** viewport left coordinate */
  63053. x: number,
  63054. /** viewport top coordinate */
  63055. y: number,
  63056. /**viewport width */
  63057. width: number,
  63058. /** viewport height */
  63059. height: number);
  63060. /**
  63061. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63062. * @param renderWidth defines the rendering width
  63063. * @param renderHeight defines the rendering height
  63064. * @returns a new Viewport
  63065. */
  63066. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63067. /**
  63068. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63069. * @param renderWidth defines the rendering width
  63070. * @param renderHeight defines the rendering height
  63071. * @param ref defines the target viewport
  63072. * @returns the current viewport
  63073. */
  63074. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63075. /**
  63076. * Returns a new Viewport copied from the current one
  63077. * @returns a new Viewport
  63078. */
  63079. clone(): Viewport;
  63080. }
  63081. /**
  63082. * Reprasents a camera frustum
  63083. */
  63084. export class Frustum {
  63085. /**
  63086. * Gets the planes representing the frustum
  63087. * @param transform matrix to be applied to the returned planes
  63088. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63089. */
  63090. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63091. /**
  63092. * Gets the near frustum plane transformed by the transform matrix
  63093. * @param transform transformation matrix to be applied to the resulting frustum plane
  63094. * @param frustumPlane the resuling frustum plane
  63095. */
  63096. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63097. /**
  63098. * Gets the far frustum plane transformed by the transform matrix
  63099. * @param transform transformation matrix to be applied to the resulting frustum plane
  63100. * @param frustumPlane the resuling frustum plane
  63101. */
  63102. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63103. /**
  63104. * Gets the left frustum plane transformed by the transform matrix
  63105. * @param transform transformation matrix to be applied to the resulting frustum plane
  63106. * @param frustumPlane the resuling frustum plane
  63107. */
  63108. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63109. /**
  63110. * Gets the right frustum plane transformed by the transform matrix
  63111. * @param transform transformation matrix to be applied to the resulting frustum plane
  63112. * @param frustumPlane the resuling frustum plane
  63113. */
  63114. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63115. /**
  63116. * Gets the top frustum plane transformed by the transform matrix
  63117. * @param transform transformation matrix to be applied to the resulting frustum plane
  63118. * @param frustumPlane the resuling frustum plane
  63119. */
  63120. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63121. /**
  63122. * Gets the bottom frustum plane transformed by the transform matrix
  63123. * @param transform transformation matrix to be applied to the resulting frustum plane
  63124. * @param frustumPlane the resuling frustum plane
  63125. */
  63126. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63127. /**
  63128. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63129. * @param transform transformation matrix to be applied to the resulting frustum planes
  63130. * @param frustumPlanes the resuling frustum planes
  63131. */
  63132. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63133. }
  63134. /** Defines supported spaces */
  63135. export enum Space {
  63136. /** Local (object) space */
  63137. LOCAL = 0,
  63138. /** World space */
  63139. WORLD = 1,
  63140. /** Bone space */
  63141. BONE = 2
  63142. }
  63143. /** Defines the 3 main axes */
  63144. export class Axis {
  63145. /** X axis */
  63146. static X: Vector3;
  63147. /** Y axis */
  63148. static Y: Vector3;
  63149. /** Z axis */
  63150. static Z: Vector3;
  63151. }
  63152. /** Class used to represent a Bezier curve */
  63153. export class BezierCurve {
  63154. /**
  63155. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63156. * @param t defines the time
  63157. * @param x1 defines the left coordinate on X axis
  63158. * @param y1 defines the left coordinate on Y axis
  63159. * @param x2 defines the right coordinate on X axis
  63160. * @param y2 defines the right coordinate on Y axis
  63161. * @returns the interpolated value
  63162. */
  63163. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63164. }
  63165. /**
  63166. * Defines potential orientation for back face culling
  63167. */
  63168. export enum Orientation {
  63169. /**
  63170. * Clockwise
  63171. */
  63172. CW = 0,
  63173. /** Counter clockwise */
  63174. CCW = 1
  63175. }
  63176. /**
  63177. * Defines angle representation
  63178. */
  63179. export class Angle {
  63180. private _radians;
  63181. /**
  63182. * Creates an Angle object of "radians" radians (float).
  63183. * @param radians the angle in radians
  63184. */
  63185. constructor(radians: number);
  63186. /**
  63187. * Get value in degrees
  63188. * @returns the Angle value in degrees (float)
  63189. */
  63190. degrees(): number;
  63191. /**
  63192. * Get value in radians
  63193. * @returns the Angle value in radians (float)
  63194. */
  63195. radians(): number;
  63196. /**
  63197. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63198. * @param a defines first vector
  63199. * @param b defines second vector
  63200. * @returns a new Angle
  63201. */
  63202. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63203. /**
  63204. * Gets a new Angle object from the given float in radians
  63205. * @param radians defines the angle value in radians
  63206. * @returns a new Angle
  63207. */
  63208. static FromRadians(radians: number): Angle;
  63209. /**
  63210. * Gets a new Angle object from the given float in degrees
  63211. * @param degrees defines the angle value in degrees
  63212. * @returns a new Angle
  63213. */
  63214. static FromDegrees(degrees: number): Angle;
  63215. }
  63216. /**
  63217. * This represents an arc in a 2d space.
  63218. */
  63219. export class Arc2 {
  63220. /** Defines the start point of the arc */
  63221. startPoint: Vector2;
  63222. /** Defines the mid point of the arc */
  63223. midPoint: Vector2;
  63224. /** Defines the end point of the arc */
  63225. endPoint: Vector2;
  63226. /**
  63227. * Defines the center point of the arc.
  63228. */
  63229. centerPoint: Vector2;
  63230. /**
  63231. * Defines the radius of the arc.
  63232. */
  63233. radius: number;
  63234. /**
  63235. * Defines the angle of the arc (from mid point to end point).
  63236. */
  63237. angle: Angle;
  63238. /**
  63239. * Defines the start angle of the arc (from start point to middle point).
  63240. */
  63241. startAngle: Angle;
  63242. /**
  63243. * Defines the orientation of the arc (clock wise/counter clock wise).
  63244. */
  63245. orientation: Orientation;
  63246. /**
  63247. * Creates an Arc object from the three given points : start, middle and end.
  63248. * @param startPoint Defines the start point of the arc
  63249. * @param midPoint Defines the midlle point of the arc
  63250. * @param endPoint Defines the end point of the arc
  63251. */
  63252. constructor(
  63253. /** Defines the start point of the arc */
  63254. startPoint: Vector2,
  63255. /** Defines the mid point of the arc */
  63256. midPoint: Vector2,
  63257. /** Defines the end point of the arc */
  63258. endPoint: Vector2);
  63259. }
  63260. /**
  63261. * Represents a 2D path made up of multiple 2D points
  63262. */
  63263. export class Path2 {
  63264. private _points;
  63265. private _length;
  63266. /**
  63267. * If the path start and end point are the same
  63268. */
  63269. closed: boolean;
  63270. /**
  63271. * Creates a Path2 object from the starting 2D coordinates x and y.
  63272. * @param x the starting points x value
  63273. * @param y the starting points y value
  63274. */
  63275. constructor(x: number, y: number);
  63276. /**
  63277. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63278. * @param x the added points x value
  63279. * @param y the added points y value
  63280. * @returns the updated Path2.
  63281. */
  63282. addLineTo(x: number, y: number): Path2;
  63283. /**
  63284. * 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.
  63285. * @param midX middle point x value
  63286. * @param midY middle point y value
  63287. * @param endX end point x value
  63288. * @param endY end point y value
  63289. * @param numberOfSegments (default: 36)
  63290. * @returns the updated Path2.
  63291. */
  63292. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63293. /**
  63294. * Closes the Path2.
  63295. * @returns the Path2.
  63296. */
  63297. close(): Path2;
  63298. /**
  63299. * Gets the sum of the distance between each sequential point in the path
  63300. * @returns the Path2 total length (float).
  63301. */
  63302. length(): number;
  63303. /**
  63304. * Gets the points which construct the path
  63305. * @returns the Path2 internal array of points.
  63306. */
  63307. getPoints(): Vector2[];
  63308. /**
  63309. * Retreives the point at the distance aways from the starting point
  63310. * @param normalizedLengthPosition the length along the path to retreive the point from
  63311. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63312. */
  63313. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63314. /**
  63315. * Creates a new path starting from an x and y position
  63316. * @param x starting x value
  63317. * @param y starting y value
  63318. * @returns a new Path2 starting at the coordinates (x, y).
  63319. */
  63320. static StartingAt(x: number, y: number): Path2;
  63321. }
  63322. /**
  63323. * Represents a 3D path made up of multiple 3D points
  63324. */
  63325. export class Path3D {
  63326. /**
  63327. * an array of Vector3, the curve axis of the Path3D
  63328. */
  63329. path: Vector3[];
  63330. private _curve;
  63331. private _distances;
  63332. private _tangents;
  63333. private _normals;
  63334. private _binormals;
  63335. private _raw;
  63336. /**
  63337. * new Path3D(path, normal, raw)
  63338. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63339. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63340. * @param path an array of Vector3, the curve axis of the Path3D
  63341. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63342. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63343. */
  63344. constructor(
  63345. /**
  63346. * an array of Vector3, the curve axis of the Path3D
  63347. */
  63348. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63349. /**
  63350. * Returns the Path3D array of successive Vector3 designing its curve.
  63351. * @returns the Path3D array of successive Vector3 designing its curve.
  63352. */
  63353. getCurve(): Vector3[];
  63354. /**
  63355. * Returns an array populated with tangent vectors on each Path3D curve point.
  63356. * @returns an array populated with tangent vectors on each Path3D curve point.
  63357. */
  63358. getTangents(): Vector3[];
  63359. /**
  63360. * Returns an array populated with normal vectors on each Path3D curve point.
  63361. * @returns an array populated with normal vectors on each Path3D curve point.
  63362. */
  63363. getNormals(): Vector3[];
  63364. /**
  63365. * Returns an array populated with binormal vectors on each Path3D curve point.
  63366. * @returns an array populated with binormal vectors on each Path3D curve point.
  63367. */
  63368. getBinormals(): Vector3[];
  63369. /**
  63370. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63371. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63372. */
  63373. getDistances(): number[];
  63374. /**
  63375. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63376. * @param path path which all values are copied into the curves points
  63377. * @param firstNormal which should be projected onto the curve
  63378. * @returns the same object updated.
  63379. */
  63380. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63381. private _compute;
  63382. private _getFirstNonNullVector;
  63383. private _getLastNonNullVector;
  63384. private _normalVector;
  63385. }
  63386. /**
  63387. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63388. * A Curve3 is designed from a series of successive Vector3.
  63389. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63390. */
  63391. export class Curve3 {
  63392. private _points;
  63393. private _length;
  63394. /**
  63395. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63396. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63397. * @param v1 (Vector3) the control point
  63398. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63399. * @param nbPoints (integer) the wanted number of points in the curve
  63400. * @returns the created Curve3
  63401. */
  63402. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63403. /**
  63404. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63405. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63406. * @param v1 (Vector3) the first control point
  63407. * @param v2 (Vector3) the second control point
  63408. * @param v3 (Vector3) the end point of the Cubic Bezier
  63409. * @param nbPoints (integer) the wanted number of points in the curve
  63410. * @returns the created Curve3
  63411. */
  63412. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63413. /**
  63414. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63415. * @param p1 (Vector3) the origin point of the Hermite Spline
  63416. * @param t1 (Vector3) the tangent vector at the origin point
  63417. * @param p2 (Vector3) the end point of the Hermite Spline
  63418. * @param t2 (Vector3) the tangent vector at the end point
  63419. * @param nbPoints (integer) the wanted number of points in the curve
  63420. * @returns the created Curve3
  63421. */
  63422. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63423. /**
  63424. * Returns a Curve3 object along a CatmullRom Spline curve :
  63425. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  63426. * @param nbPoints (integer) the wanted number of points between each curve control points
  63427. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  63428. * @returns the created Curve3
  63429. */
  63430. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  63431. /**
  63432. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63433. * A Curve3 is designed from a series of successive Vector3.
  63434. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  63435. * @param points points which make up the curve
  63436. */
  63437. constructor(points: Vector3[]);
  63438. /**
  63439. * @returns the Curve3 stored array of successive Vector3
  63440. */
  63441. getPoints(): Vector3[];
  63442. /**
  63443. * @returns the computed length (float) of the curve.
  63444. */
  63445. length(): number;
  63446. /**
  63447. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  63448. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  63449. * curveA and curveB keep unchanged.
  63450. * @param curve the curve to continue from this curve
  63451. * @returns the newly constructed curve
  63452. */
  63453. continue(curve: DeepImmutable<Curve3>): Curve3;
  63454. private _computeLength;
  63455. }
  63456. /**
  63457. * Contains position and normal vectors for a vertex
  63458. */
  63459. export class PositionNormalVertex {
  63460. /** the position of the vertex (defaut: 0,0,0) */
  63461. position: Vector3;
  63462. /** the normal of the vertex (defaut: 0,1,0) */
  63463. normal: Vector3;
  63464. /**
  63465. * Creates a PositionNormalVertex
  63466. * @param position the position of the vertex (defaut: 0,0,0)
  63467. * @param normal the normal of the vertex (defaut: 0,1,0)
  63468. */
  63469. constructor(
  63470. /** the position of the vertex (defaut: 0,0,0) */
  63471. position?: Vector3,
  63472. /** the normal of the vertex (defaut: 0,1,0) */
  63473. normal?: Vector3);
  63474. /**
  63475. * Clones the PositionNormalVertex
  63476. * @returns the cloned PositionNormalVertex
  63477. */
  63478. clone(): PositionNormalVertex;
  63479. }
  63480. /**
  63481. * Contains position, normal and uv vectors for a vertex
  63482. */
  63483. export class PositionNormalTextureVertex {
  63484. /** the position of the vertex (defaut: 0,0,0) */
  63485. position: Vector3;
  63486. /** the normal of the vertex (defaut: 0,1,0) */
  63487. normal: Vector3;
  63488. /** the uv of the vertex (default: 0,0) */
  63489. uv: Vector2;
  63490. /**
  63491. * Creates a PositionNormalTextureVertex
  63492. * @param position the position of the vertex (defaut: 0,0,0)
  63493. * @param normal the normal of the vertex (defaut: 0,1,0)
  63494. * @param uv the uv of the vertex (default: 0,0)
  63495. */
  63496. constructor(
  63497. /** the position of the vertex (defaut: 0,0,0) */
  63498. position?: Vector3,
  63499. /** the normal of the vertex (defaut: 0,1,0) */
  63500. normal?: Vector3,
  63501. /** the uv of the vertex (default: 0,0) */
  63502. uv?: Vector2);
  63503. /**
  63504. * Clones the PositionNormalTextureVertex
  63505. * @returns the cloned PositionNormalTextureVertex
  63506. */
  63507. clone(): PositionNormalTextureVertex;
  63508. }
  63509. /**
  63510. * @hidden
  63511. */
  63512. export class Tmp {
  63513. static Color3: Color3[];
  63514. static Color4: Color4[];
  63515. static Vector2: Vector2[];
  63516. static Vector3: Vector3[];
  63517. static Vector4: Vector4[];
  63518. static Quaternion: Quaternion[];
  63519. static Matrix: Matrix[];
  63520. }
  63521. }
  63522. declare module BABYLON {
  63523. /**
  63524. * Class used to enable access to offline support
  63525. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63526. */
  63527. export interface IOfflineProvider {
  63528. /**
  63529. * Gets a boolean indicating if scene must be saved in the database
  63530. */
  63531. enableSceneOffline: boolean;
  63532. /**
  63533. * Gets a boolean indicating if textures must be saved in the database
  63534. */
  63535. enableTexturesOffline: boolean;
  63536. /**
  63537. * Open the offline support and make it available
  63538. * @param successCallback defines the callback to call on success
  63539. * @param errorCallback defines the callback to call on error
  63540. */
  63541. open(successCallback: () => void, errorCallback: () => void): void;
  63542. /**
  63543. * Loads an image from the offline support
  63544. * @param url defines the url to load from
  63545. * @param image defines the target DOM image
  63546. */
  63547. loadImage(url: string, image: HTMLImageElement): void;
  63548. /**
  63549. * Loads a file from offline support
  63550. * @param url defines the URL to load from
  63551. * @param sceneLoaded defines a callback to call on success
  63552. * @param progressCallBack defines a callback to call when progress changed
  63553. * @param errorCallback defines a callback to call on error
  63554. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63555. */
  63556. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63557. }
  63558. }
  63559. declare module BABYLON {
  63560. /**
  63561. * A class serves as a medium between the observable and its observers
  63562. */
  63563. export class EventState {
  63564. /**
  63565. * Create a new EventState
  63566. * @param mask defines the mask associated with this state
  63567. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63568. * @param target defines the original target of the state
  63569. * @param currentTarget defines the current target of the state
  63570. */
  63571. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63572. /**
  63573. * Initialize the current event state
  63574. * @param mask defines the mask associated with this state
  63575. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63576. * @param target defines the original target of the state
  63577. * @param currentTarget defines the current target of the state
  63578. * @returns the current event state
  63579. */
  63580. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63581. /**
  63582. * An Observer can set this property to true to prevent subsequent observers of being notified
  63583. */
  63584. skipNextObservers: boolean;
  63585. /**
  63586. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63587. */
  63588. mask: number;
  63589. /**
  63590. * The object that originally notified the event
  63591. */
  63592. target?: any;
  63593. /**
  63594. * The current object in the bubbling phase
  63595. */
  63596. currentTarget?: any;
  63597. /**
  63598. * This will be populated with the return value of the last function that was executed.
  63599. * If it is the first function in the callback chain it will be the event data.
  63600. */
  63601. lastReturnValue?: any;
  63602. }
  63603. /**
  63604. * Represent an Observer registered to a given Observable object.
  63605. */
  63606. export class Observer<T> {
  63607. /**
  63608. * Defines the callback to call when the observer is notified
  63609. */
  63610. callback: (eventData: T, eventState: EventState) => void;
  63611. /**
  63612. * Defines the mask of the observer (used to filter notifications)
  63613. */
  63614. mask: number;
  63615. /**
  63616. * Defines the current scope used to restore the JS context
  63617. */
  63618. scope: any;
  63619. /** @hidden */
  63620. _willBeUnregistered: boolean;
  63621. /**
  63622. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63623. */
  63624. unregisterOnNextCall: boolean;
  63625. /**
  63626. * Creates a new observer
  63627. * @param callback defines the callback to call when the observer is notified
  63628. * @param mask defines the mask of the observer (used to filter notifications)
  63629. * @param scope defines the current scope used to restore the JS context
  63630. */
  63631. constructor(
  63632. /**
  63633. * Defines the callback to call when the observer is notified
  63634. */
  63635. callback: (eventData: T, eventState: EventState) => void,
  63636. /**
  63637. * Defines the mask of the observer (used to filter notifications)
  63638. */
  63639. mask: number,
  63640. /**
  63641. * Defines the current scope used to restore the JS context
  63642. */
  63643. scope?: any);
  63644. }
  63645. /**
  63646. * Represent a list of observers registered to multiple Observables object.
  63647. */
  63648. export class MultiObserver<T> {
  63649. private _observers;
  63650. private _observables;
  63651. /**
  63652. * Release associated resources
  63653. */
  63654. dispose(): void;
  63655. /**
  63656. * Raise a callback when one of the observable will notify
  63657. * @param observables defines a list of observables to watch
  63658. * @param callback defines the callback to call on notification
  63659. * @param mask defines the mask used to filter notifications
  63660. * @param scope defines the current scope used to restore the JS context
  63661. * @returns the new MultiObserver
  63662. */
  63663. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  63664. }
  63665. /**
  63666. * The Observable class is a simple implementation of the Observable pattern.
  63667. *
  63668. * 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.
  63669. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  63670. * 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).
  63671. * 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.
  63672. */
  63673. export class Observable<T> {
  63674. private _observers;
  63675. private _eventState;
  63676. private _onObserverAdded;
  63677. /**
  63678. * Creates a new observable
  63679. * @param onObserverAdded defines a callback to call when a new observer is added
  63680. */
  63681. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  63682. /**
  63683. * Create a new Observer with the specified callback
  63684. * @param callback the callback that will be executed for that Observer
  63685. * @param mask the mask used to filter observers
  63686. * @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.
  63687. * @param scope optional scope for the callback to be called from
  63688. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  63689. * @returns the new observer created for the callback
  63690. */
  63691. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  63692. /**
  63693. * Create a new Observer with the specified callback and unregisters after the next notification
  63694. * @param callback the callback that will be executed for that Observer
  63695. * @returns the new observer created for the callback
  63696. */
  63697. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  63698. /**
  63699. * Remove an Observer from the Observable object
  63700. * @param observer the instance of the Observer to remove
  63701. * @returns false if it doesn't belong to this Observable
  63702. */
  63703. remove(observer: Nullable<Observer<T>>): boolean;
  63704. /**
  63705. * Remove a callback from the Observable object
  63706. * @param callback the callback to remove
  63707. * @param scope optional scope. If used only the callbacks with this scope will be removed
  63708. * @returns false if it doesn't belong to this Observable
  63709. */
  63710. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  63711. private _deferUnregister;
  63712. private _remove;
  63713. /**
  63714. * Moves the observable to the top of the observer list making it get called first when notified
  63715. * @param observer the observer to move
  63716. */
  63717. makeObserverTopPriority(observer: Observer<T>): void;
  63718. /**
  63719. * Moves the observable to the bottom of the observer list making it get called last when notified
  63720. * @param observer the observer to move
  63721. */
  63722. makeObserverBottomPriority(observer: Observer<T>): void;
  63723. /**
  63724. * Notify all Observers by calling their respective callback with the given data
  63725. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  63726. * @param eventData defines the data to send to all observers
  63727. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  63728. * @param target defines the original target of the state
  63729. * @param currentTarget defines the current target of the state
  63730. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63731. */
  63732. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63733. /**
  63734. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63735. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  63736. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  63737. * and it is crucial that all callbacks will be executed.
  63738. * The order of the callbacks is kept, callbacks are not executed parallel.
  63739. *
  63740. * @param eventData The data to be sent to each callback
  63741. * @param mask is used to filter observers defaults to -1
  63742. * @param target defines the callback target (see EventState)
  63743. * @param currentTarget defines he current object in the bubbling phase
  63744. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  63745. */
  63746. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  63747. /**
  63748. * Notify a specific observer
  63749. * @param observer defines the observer to notify
  63750. * @param eventData defines the data to be sent to each callback
  63751. * @param mask is used to filter observers defaults to -1
  63752. */
  63753. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  63754. /**
  63755. * Gets a boolean indicating if the observable has at least one observer
  63756. * @returns true is the Observable has at least one Observer registered
  63757. */
  63758. hasObservers(): boolean;
  63759. /**
  63760. * Clear the list of observers
  63761. */
  63762. clear(): void;
  63763. /**
  63764. * Clone the current observable
  63765. * @returns a new observable
  63766. */
  63767. clone(): Observable<T>;
  63768. /**
  63769. * Does this observable handles observer registered with a given mask
  63770. * @param mask defines the mask to be tested
  63771. * @return whether or not one observer registered with the given mask is handeled
  63772. **/
  63773. hasSpecificMask(mask?: number): boolean;
  63774. }
  63775. }
  63776. declare module BABYLON {
  63777. /**
  63778. * Class used to help managing file picking and drag'n'drop
  63779. * File Storage
  63780. */
  63781. export class FilesInputStore {
  63782. /**
  63783. * List of files ready to be loaded
  63784. */
  63785. static FilesToLoad: {
  63786. [key: string]: File;
  63787. };
  63788. }
  63789. }
  63790. declare module BABYLON {
  63791. /** Defines the cross module used constants to avoid circular dependncies */
  63792. export class Constants {
  63793. /** Defines that alpha blending is disabled */
  63794. static readonly ALPHA_DISABLE: number;
  63795. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  63796. static readonly ALPHA_ADD: number;
  63797. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  63798. static readonly ALPHA_COMBINE: number;
  63799. /** Defines that alpha blending to DEST - SRC * DEST */
  63800. static readonly ALPHA_SUBTRACT: number;
  63801. /** Defines that alpha blending to SRC * DEST */
  63802. static readonly ALPHA_MULTIPLY: number;
  63803. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  63804. static readonly ALPHA_MAXIMIZED: number;
  63805. /** Defines that alpha blending to SRC + DEST */
  63806. static readonly ALPHA_ONEONE: number;
  63807. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  63808. static readonly ALPHA_PREMULTIPLIED: number;
  63809. /**
  63810. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  63811. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  63812. */
  63813. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  63814. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  63815. static readonly ALPHA_INTERPOLATE: number;
  63816. /**
  63817. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  63818. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  63819. */
  63820. static readonly ALPHA_SCREENMODE: number;
  63821. /** Defines that the ressource is not delayed*/
  63822. static readonly DELAYLOADSTATE_NONE: number;
  63823. /** Defines that the ressource was successfully delay loaded */
  63824. static readonly DELAYLOADSTATE_LOADED: number;
  63825. /** Defines that the ressource is currently delay loading */
  63826. static readonly DELAYLOADSTATE_LOADING: number;
  63827. /** Defines that the ressource is delayed and has not started loading */
  63828. static readonly DELAYLOADSTATE_NOTLOADED: number;
  63829. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  63830. static readonly NEVER: number;
  63831. /** 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 */
  63832. static readonly ALWAYS: number;
  63833. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  63834. static readonly LESS: number;
  63835. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  63836. static readonly EQUAL: number;
  63837. /** 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 */
  63838. static readonly LEQUAL: number;
  63839. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  63840. static readonly GREATER: number;
  63841. /** 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 */
  63842. static readonly GEQUAL: number;
  63843. /** 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 */
  63844. static readonly NOTEQUAL: number;
  63845. /** Passed to stencilOperation to specify that stencil value must be kept */
  63846. static readonly KEEP: number;
  63847. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63848. static readonly REPLACE: number;
  63849. /** Passed to stencilOperation to specify that stencil value must be incremented */
  63850. static readonly INCR: number;
  63851. /** Passed to stencilOperation to specify that stencil value must be decremented */
  63852. static readonly DECR: number;
  63853. /** Passed to stencilOperation to specify that stencil value must be inverted */
  63854. static readonly INVERT: number;
  63855. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  63856. static readonly INCR_WRAP: number;
  63857. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  63858. static readonly DECR_WRAP: number;
  63859. /** Texture is not repeating outside of 0..1 UVs */
  63860. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  63861. /** Texture is repeating outside of 0..1 UVs */
  63862. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  63863. /** Texture is repeating and mirrored */
  63864. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  63865. /** ALPHA */
  63866. static readonly TEXTUREFORMAT_ALPHA: number;
  63867. /** LUMINANCE */
  63868. static readonly TEXTUREFORMAT_LUMINANCE: number;
  63869. /** LUMINANCE_ALPHA */
  63870. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  63871. /** RGB */
  63872. static readonly TEXTUREFORMAT_RGB: number;
  63873. /** RGBA */
  63874. static readonly TEXTUREFORMAT_RGBA: number;
  63875. /** RED */
  63876. static readonly TEXTUREFORMAT_RED: number;
  63877. /** RED (2nd reference) */
  63878. static readonly TEXTUREFORMAT_R: number;
  63879. /** RG */
  63880. static readonly TEXTUREFORMAT_RG: number;
  63881. /** RED_INTEGER */
  63882. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  63883. /** RED_INTEGER (2nd reference) */
  63884. static readonly TEXTUREFORMAT_R_INTEGER: number;
  63885. /** RG_INTEGER */
  63886. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  63887. /** RGB_INTEGER */
  63888. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  63889. /** RGBA_INTEGER */
  63890. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  63891. /** UNSIGNED_BYTE */
  63892. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  63893. /** UNSIGNED_BYTE (2nd reference) */
  63894. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  63895. /** FLOAT */
  63896. static readonly TEXTURETYPE_FLOAT: number;
  63897. /** HALF_FLOAT */
  63898. static readonly TEXTURETYPE_HALF_FLOAT: number;
  63899. /** BYTE */
  63900. static readonly TEXTURETYPE_BYTE: number;
  63901. /** SHORT */
  63902. static readonly TEXTURETYPE_SHORT: number;
  63903. /** UNSIGNED_SHORT */
  63904. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  63905. /** INT */
  63906. static readonly TEXTURETYPE_INT: number;
  63907. /** UNSIGNED_INT */
  63908. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  63909. /** UNSIGNED_SHORT_4_4_4_4 */
  63910. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  63911. /** UNSIGNED_SHORT_5_5_5_1 */
  63912. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  63913. /** UNSIGNED_SHORT_5_6_5 */
  63914. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  63915. /** UNSIGNED_INT_2_10_10_10_REV */
  63916. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  63917. /** UNSIGNED_INT_24_8 */
  63918. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  63919. /** UNSIGNED_INT_10F_11F_11F_REV */
  63920. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  63921. /** UNSIGNED_INT_5_9_9_9_REV */
  63922. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  63923. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  63924. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63925. /** nearest is mag = nearest and min = nearest and mip = linear */
  63926. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  63927. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63928. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  63929. /** Trilinear is mag = linear and min = linear and mip = linear */
  63930. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  63931. /** nearest is mag = nearest and min = nearest and mip = linear */
  63932. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  63933. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63934. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  63935. /** Trilinear is mag = linear and min = linear and mip = linear */
  63936. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  63937. /** mag = nearest and min = nearest and mip = nearest */
  63938. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  63939. /** mag = nearest and min = linear and mip = nearest */
  63940. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  63941. /** mag = nearest and min = linear and mip = linear */
  63942. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  63943. /** mag = nearest and min = linear and mip = none */
  63944. static readonly TEXTURE_NEAREST_LINEAR: number;
  63945. /** mag = nearest and min = nearest and mip = none */
  63946. static readonly TEXTURE_NEAREST_NEAREST: number;
  63947. /** mag = linear and min = nearest and mip = nearest */
  63948. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  63949. /** mag = linear and min = nearest and mip = linear */
  63950. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  63951. /** mag = linear and min = linear and mip = none */
  63952. static readonly TEXTURE_LINEAR_LINEAR: number;
  63953. /** mag = linear and min = nearest and mip = none */
  63954. static readonly TEXTURE_LINEAR_NEAREST: number;
  63955. /** Explicit coordinates mode */
  63956. static readonly TEXTURE_EXPLICIT_MODE: number;
  63957. /** Spherical coordinates mode */
  63958. static readonly TEXTURE_SPHERICAL_MODE: number;
  63959. /** Planar coordinates mode */
  63960. static readonly TEXTURE_PLANAR_MODE: number;
  63961. /** Cubic coordinates mode */
  63962. static readonly TEXTURE_CUBIC_MODE: number;
  63963. /** Projection coordinates mode */
  63964. static readonly TEXTURE_PROJECTION_MODE: number;
  63965. /** Skybox coordinates mode */
  63966. static readonly TEXTURE_SKYBOX_MODE: number;
  63967. /** Inverse Cubic coordinates mode */
  63968. static readonly TEXTURE_INVCUBIC_MODE: number;
  63969. /** Equirectangular coordinates mode */
  63970. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  63971. /** Equirectangular Fixed coordinates mode */
  63972. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  63973. /** Equirectangular Fixed Mirrored coordinates mode */
  63974. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  63975. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  63976. static readonly SCALEMODE_FLOOR: number;
  63977. /** Defines that texture rescaling will look for the nearest power of 2 size */
  63978. static readonly SCALEMODE_NEAREST: number;
  63979. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  63980. static readonly SCALEMODE_CEILING: number;
  63981. /**
  63982. * The dirty texture flag value
  63983. */
  63984. static readonly MATERIAL_TextureDirtyFlag: number;
  63985. /**
  63986. * The dirty light flag value
  63987. */
  63988. static readonly MATERIAL_LightDirtyFlag: number;
  63989. /**
  63990. * The dirty fresnel flag value
  63991. */
  63992. static readonly MATERIAL_FresnelDirtyFlag: number;
  63993. /**
  63994. * The dirty attribute flag value
  63995. */
  63996. static readonly MATERIAL_AttributesDirtyFlag: number;
  63997. /**
  63998. * The dirty misc flag value
  63999. */
  64000. static readonly MATERIAL_MiscDirtyFlag: number;
  64001. /**
  64002. * The all dirty flag value
  64003. */
  64004. static readonly MATERIAL_AllDirtyFlag: number;
  64005. /**
  64006. * Returns the triangle fill mode
  64007. */
  64008. static readonly MATERIAL_TriangleFillMode: number;
  64009. /**
  64010. * Returns the wireframe mode
  64011. */
  64012. static readonly MATERIAL_WireFrameFillMode: number;
  64013. /**
  64014. * Returns the point fill mode
  64015. */
  64016. static readonly MATERIAL_PointFillMode: number;
  64017. /**
  64018. * Returns the point list draw mode
  64019. */
  64020. static readonly MATERIAL_PointListDrawMode: number;
  64021. /**
  64022. * Returns the line list draw mode
  64023. */
  64024. static readonly MATERIAL_LineListDrawMode: number;
  64025. /**
  64026. * Returns the line loop draw mode
  64027. */
  64028. static readonly MATERIAL_LineLoopDrawMode: number;
  64029. /**
  64030. * Returns the line strip draw mode
  64031. */
  64032. static readonly MATERIAL_LineStripDrawMode: number;
  64033. /**
  64034. * Returns the triangle strip draw mode
  64035. */
  64036. static readonly MATERIAL_TriangleStripDrawMode: number;
  64037. /**
  64038. * Returns the triangle fan draw mode
  64039. */
  64040. static readonly MATERIAL_TriangleFanDrawMode: number;
  64041. /**
  64042. * Stores the clock-wise side orientation
  64043. */
  64044. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64045. /**
  64046. * Stores the counter clock-wise side orientation
  64047. */
  64048. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64049. /**
  64050. * Nothing
  64051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64052. */
  64053. static readonly ACTION_NothingTrigger: number;
  64054. /**
  64055. * On pick
  64056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64057. */
  64058. static readonly ACTION_OnPickTrigger: number;
  64059. /**
  64060. * On left pick
  64061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64062. */
  64063. static readonly ACTION_OnLeftPickTrigger: number;
  64064. /**
  64065. * On right pick
  64066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64067. */
  64068. static readonly ACTION_OnRightPickTrigger: number;
  64069. /**
  64070. * On center pick
  64071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64072. */
  64073. static readonly ACTION_OnCenterPickTrigger: number;
  64074. /**
  64075. * On pick down
  64076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64077. */
  64078. static readonly ACTION_OnPickDownTrigger: number;
  64079. /**
  64080. * On double pick
  64081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64082. */
  64083. static readonly ACTION_OnDoublePickTrigger: number;
  64084. /**
  64085. * On pick up
  64086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64087. */
  64088. static readonly ACTION_OnPickUpTrigger: number;
  64089. /**
  64090. * On pick out.
  64091. * This trigger will only be raised if you also declared a OnPickDown
  64092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64093. */
  64094. static readonly ACTION_OnPickOutTrigger: number;
  64095. /**
  64096. * On long press
  64097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64098. */
  64099. static readonly ACTION_OnLongPressTrigger: number;
  64100. /**
  64101. * On pointer over
  64102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64103. */
  64104. static readonly ACTION_OnPointerOverTrigger: number;
  64105. /**
  64106. * On pointer out
  64107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64108. */
  64109. static readonly ACTION_OnPointerOutTrigger: number;
  64110. /**
  64111. * On every frame
  64112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64113. */
  64114. static readonly ACTION_OnEveryFrameTrigger: number;
  64115. /**
  64116. * On intersection enter
  64117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64118. */
  64119. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64120. /**
  64121. * On intersection exit
  64122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64123. */
  64124. static readonly ACTION_OnIntersectionExitTrigger: number;
  64125. /**
  64126. * On key down
  64127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64128. */
  64129. static readonly ACTION_OnKeyDownTrigger: number;
  64130. /**
  64131. * On key up
  64132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64133. */
  64134. static readonly ACTION_OnKeyUpTrigger: number;
  64135. /**
  64136. * Billboard mode will only apply to Y axis
  64137. */
  64138. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64139. /**
  64140. * Billboard mode will apply to all axes
  64141. */
  64142. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64143. /**
  64144. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64145. */
  64146. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64147. /**
  64148. * Gets or sets base Assets URL
  64149. */
  64150. static readonly PARTICLES_BaseAssetsUrl: string;
  64151. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64152. * Test order :
  64153. * Is the bounding sphere outside the frustum ?
  64154. * If not, are the bounding box vertices outside the frustum ?
  64155. * It not, then the cullable object is in the frustum.
  64156. */
  64157. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64158. /** Culling strategy : Bounding Sphere Only.
  64159. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64160. * It's also less accurate than the standard because some not visible objects can still be selected.
  64161. * Test : is the bounding sphere outside the frustum ?
  64162. * If not, then the cullable object is in the frustum.
  64163. */
  64164. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64165. /** Culling strategy : Optimistic Inclusion.
  64166. * This in an inclusion test first, then the standard exclusion test.
  64167. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64168. * 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.
  64169. * Anyway, it's as accurate as the standard strategy.
  64170. * Test :
  64171. * Is the cullable object bounding sphere center in the frustum ?
  64172. * If not, apply the default culling strategy.
  64173. */
  64174. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64175. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64176. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64177. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64178. * 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.
  64179. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64180. * Test :
  64181. * Is the cullable object bounding sphere center in the frustum ?
  64182. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64183. */
  64184. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64185. /**
  64186. * No logging while loading
  64187. */
  64188. static readonly SCENELOADER_NO_LOGGING: number;
  64189. /**
  64190. * Minimal logging while loading
  64191. */
  64192. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64193. /**
  64194. * Summary logging while loading
  64195. */
  64196. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64197. /**
  64198. * Detailled logging while loading
  64199. */
  64200. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64201. }
  64202. }
  64203. declare module BABYLON {
  64204. /**
  64205. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64206. * Babylon.js
  64207. */
  64208. export class DomManagement {
  64209. /**
  64210. * Checks if the window object exists
  64211. * @returns true if the window object exists
  64212. */
  64213. static IsWindowObjectExist(): boolean;
  64214. /**
  64215. * Extracts text content from a DOM element hierarchy
  64216. * @param element defines the root element
  64217. * @returns a string
  64218. */
  64219. static GetDOMTextContent(element: HTMLElement): string;
  64220. }
  64221. }
  64222. declare module BABYLON {
  64223. /**
  64224. * Logger used througouht the application to allow configuration of
  64225. * the log level required for the messages.
  64226. */
  64227. export class Logger {
  64228. /**
  64229. * No log
  64230. */
  64231. static readonly NoneLogLevel: number;
  64232. /**
  64233. * Only message logs
  64234. */
  64235. static readonly MessageLogLevel: number;
  64236. /**
  64237. * Only warning logs
  64238. */
  64239. static readonly WarningLogLevel: number;
  64240. /**
  64241. * Only error logs
  64242. */
  64243. static readonly ErrorLogLevel: number;
  64244. /**
  64245. * All logs
  64246. */
  64247. static readonly AllLogLevel: number;
  64248. private static _LogCache;
  64249. /**
  64250. * Gets a value indicating the number of loading errors
  64251. * @ignorenaming
  64252. */
  64253. static errorsCount: number;
  64254. /**
  64255. * Callback called when a new log is added
  64256. */
  64257. static OnNewCacheEntry: (entry: string) => void;
  64258. private static _AddLogEntry;
  64259. private static _FormatMessage;
  64260. private static _LogDisabled;
  64261. private static _LogEnabled;
  64262. private static _WarnDisabled;
  64263. private static _WarnEnabled;
  64264. private static _ErrorDisabled;
  64265. private static _ErrorEnabled;
  64266. /**
  64267. * Log a message to the console
  64268. */
  64269. static Log: (message: string) => void;
  64270. /**
  64271. * Write a warning message to the console
  64272. */
  64273. static Warn: (message: string) => void;
  64274. /**
  64275. * Write an error message to the console
  64276. */
  64277. static Error: (message: string) => void;
  64278. /**
  64279. * Gets current log cache (list of logs)
  64280. */
  64281. static readonly LogCache: string;
  64282. /**
  64283. * Clears the log cache
  64284. */
  64285. static ClearLogCache(): void;
  64286. /**
  64287. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64288. */
  64289. static LogLevels: number;
  64290. }
  64291. }
  64292. declare module BABYLON {
  64293. /** @hidden */
  64294. export class _TypeStore {
  64295. /** @hidden */
  64296. static RegisteredTypes: {
  64297. [key: string]: Object;
  64298. };
  64299. /** @hidden */
  64300. static GetClass(fqdn: string): any;
  64301. }
  64302. }
  64303. declare module BABYLON {
  64304. /**
  64305. * Class containing a set of static utilities functions for deep copy.
  64306. */
  64307. export class DeepCopier {
  64308. /**
  64309. * Tries to copy an object by duplicating every property
  64310. * @param source defines the source object
  64311. * @param destination defines the target object
  64312. * @param doNotCopyList defines a list of properties to avoid
  64313. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64314. */
  64315. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64316. }
  64317. }
  64318. declare module BABYLON {
  64319. /**
  64320. * Class containing a set of static utilities functions for precision date
  64321. */
  64322. export class PrecisionDate {
  64323. /**
  64324. * Gets either window.performance.now() if supported or Date.now() else
  64325. */
  64326. static readonly Now: number;
  64327. }
  64328. }
  64329. declare module BABYLON {
  64330. /** @hidden */
  64331. export class _DevTools {
  64332. static WarnImport(name: string): string;
  64333. }
  64334. }
  64335. declare module BABYLON {
  64336. /**
  64337. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64338. */
  64339. export class WebRequest {
  64340. private _xhr;
  64341. /**
  64342. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64343. * i.e. when loading files, where the server/service expects an Authorization header
  64344. */
  64345. static CustomRequestHeaders: {
  64346. [key: string]: string;
  64347. };
  64348. /**
  64349. * Add callback functions in this array to update all the requests before they get sent to the network
  64350. */
  64351. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64352. private _injectCustomRequestHeaders;
  64353. /**
  64354. * Gets or sets a function to be called when loading progress changes
  64355. */
  64356. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64357. /**
  64358. * Returns client's state
  64359. */
  64360. readonly readyState: number;
  64361. /**
  64362. * Returns client's status
  64363. */
  64364. readonly status: number;
  64365. /**
  64366. * Returns client's status as a text
  64367. */
  64368. readonly statusText: string;
  64369. /**
  64370. * Returns client's response
  64371. */
  64372. readonly response: any;
  64373. /**
  64374. * Returns client's response url
  64375. */
  64376. readonly responseURL: string;
  64377. /**
  64378. * Returns client's response as text
  64379. */
  64380. readonly responseText: string;
  64381. /**
  64382. * Gets or sets the expected response type
  64383. */
  64384. responseType: XMLHttpRequestResponseType;
  64385. /** @hidden */
  64386. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64387. /** @hidden */
  64388. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64389. /**
  64390. * Cancels any network activity
  64391. */
  64392. abort(): void;
  64393. /**
  64394. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64395. * @param body defines an optional request body
  64396. */
  64397. send(body?: Document | BodyInit | null): void;
  64398. /**
  64399. * Sets the request method, request URL
  64400. * @param method defines the method to use (GET, POST, etc..)
  64401. * @param url defines the url to connect with
  64402. */
  64403. open(method: string, url: string): void;
  64404. }
  64405. }
  64406. declare module BABYLON {
  64407. /**
  64408. * Class used to evalaute queries containing `and` and `or` operators
  64409. */
  64410. export class AndOrNotEvaluator {
  64411. /**
  64412. * Evaluate a query
  64413. * @param query defines the query to evaluate
  64414. * @param evaluateCallback defines the callback used to filter result
  64415. * @returns true if the query matches
  64416. */
  64417. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64418. private static _HandleParenthesisContent;
  64419. private static _SimplifyNegation;
  64420. }
  64421. }
  64422. declare module BABYLON {
  64423. /**
  64424. * Class used to store custom tags
  64425. */
  64426. export class Tags {
  64427. /**
  64428. * Adds support for tags on the given object
  64429. * @param obj defines the object to use
  64430. */
  64431. static EnableFor(obj: any): void;
  64432. /**
  64433. * Removes tags support
  64434. * @param obj defines the object to use
  64435. */
  64436. static DisableFor(obj: any): void;
  64437. /**
  64438. * Gets a boolean indicating if the given object has tags
  64439. * @param obj defines the object to use
  64440. * @returns a boolean
  64441. */
  64442. static HasTags(obj: any): boolean;
  64443. /**
  64444. * Gets the tags available on a given object
  64445. * @param obj defines the object to use
  64446. * @param asString defines if the tags must be returned as a string instead of an array of strings
  64447. * @returns the tags
  64448. */
  64449. static GetTags(obj: any, asString?: boolean): any;
  64450. /**
  64451. * Adds tags to an object
  64452. * @param obj defines the object to use
  64453. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  64454. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  64455. */
  64456. static AddTagsTo(obj: any, tagsString: string): void;
  64457. /**
  64458. * @hidden
  64459. */
  64460. static _AddTagTo(obj: any, tag: string): void;
  64461. /**
  64462. * Removes specific tags from a specific object
  64463. * @param obj defines the object to use
  64464. * @param tagsString defines the tags to remove
  64465. */
  64466. static RemoveTagsFrom(obj: any, tagsString: string): void;
  64467. /**
  64468. * @hidden
  64469. */
  64470. static _RemoveTagFrom(obj: any, tag: string): void;
  64471. /**
  64472. * Defines if tags hosted on an object match a given query
  64473. * @param obj defines the object to use
  64474. * @param tagsQuery defines the tag query
  64475. * @returns a boolean
  64476. */
  64477. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  64478. }
  64479. }
  64480. declare module BABYLON {
  64481. /**
  64482. * Manages the defines for the Material
  64483. */
  64484. export class MaterialDefines {
  64485. private _keys;
  64486. private _isDirty;
  64487. /** @hidden */
  64488. _renderId: number;
  64489. /** @hidden */
  64490. _areLightsDirty: boolean;
  64491. /** @hidden */
  64492. _areAttributesDirty: boolean;
  64493. /** @hidden */
  64494. _areTexturesDirty: boolean;
  64495. /** @hidden */
  64496. _areFresnelDirty: boolean;
  64497. /** @hidden */
  64498. _areMiscDirty: boolean;
  64499. /** @hidden */
  64500. _areImageProcessingDirty: boolean;
  64501. /** @hidden */
  64502. _normals: boolean;
  64503. /** @hidden */
  64504. _uvs: boolean;
  64505. /** @hidden */
  64506. _needNormals: boolean;
  64507. /** @hidden */
  64508. _needUVs: boolean;
  64509. /**
  64510. * Specifies if the material needs to be re-calculated
  64511. */
  64512. readonly isDirty: boolean;
  64513. /**
  64514. * Marks the material to indicate that it has been re-calculated
  64515. */
  64516. markAsProcessed(): void;
  64517. /**
  64518. * Marks the material to indicate that it needs to be re-calculated
  64519. */
  64520. markAsUnprocessed(): void;
  64521. /**
  64522. * Marks the material to indicate all of its defines need to be re-calculated
  64523. */
  64524. markAllAsDirty(): void;
  64525. /**
  64526. * Marks the material to indicate that image processing needs to be re-calculated
  64527. */
  64528. markAsImageProcessingDirty(): void;
  64529. /**
  64530. * Marks the material to indicate the lights need to be re-calculated
  64531. */
  64532. markAsLightDirty(): void;
  64533. /**
  64534. * Marks the attribute state as changed
  64535. */
  64536. markAsAttributesDirty(): void;
  64537. /**
  64538. * Marks the texture state as changed
  64539. */
  64540. markAsTexturesDirty(): void;
  64541. /**
  64542. * Marks the fresnel state as changed
  64543. */
  64544. markAsFresnelDirty(): void;
  64545. /**
  64546. * Marks the misc state as changed
  64547. */
  64548. markAsMiscDirty(): void;
  64549. /**
  64550. * Rebuilds the material defines
  64551. */
  64552. rebuild(): void;
  64553. /**
  64554. * Specifies if two material defines are equal
  64555. * @param other - A material define instance to compare to
  64556. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  64557. */
  64558. isEqual(other: MaterialDefines): boolean;
  64559. /**
  64560. * Clones this instance's defines to another instance
  64561. * @param other - material defines to clone values to
  64562. */
  64563. cloneTo(other: MaterialDefines): void;
  64564. /**
  64565. * Resets the material define values
  64566. */
  64567. reset(): void;
  64568. /**
  64569. * Converts the material define values to a string
  64570. * @returns - String of material define information
  64571. */
  64572. toString(): string;
  64573. }
  64574. }
  64575. declare module BABYLON {
  64576. /**
  64577. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64578. */
  64579. export class PerformanceMonitor {
  64580. private _enabled;
  64581. private _rollingFrameTime;
  64582. private _lastFrameTimeMs;
  64583. /**
  64584. * constructor
  64585. * @param frameSampleSize The number of samples required to saturate the sliding window
  64586. */
  64587. constructor(frameSampleSize?: number);
  64588. /**
  64589. * Samples current frame
  64590. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64591. */
  64592. sampleFrame(timeMs?: number): void;
  64593. /**
  64594. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64595. */
  64596. readonly averageFrameTime: number;
  64597. /**
  64598. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64599. */
  64600. readonly averageFrameTimeVariance: number;
  64601. /**
  64602. * Returns the frame time of the most recent frame
  64603. */
  64604. readonly instantaneousFrameTime: number;
  64605. /**
  64606. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64607. */
  64608. readonly averageFPS: number;
  64609. /**
  64610. * Returns the average framerate in frames per second using the most recent frame time
  64611. */
  64612. readonly instantaneousFPS: number;
  64613. /**
  64614. * Returns true if enough samples have been taken to completely fill the sliding window
  64615. */
  64616. readonly isSaturated: boolean;
  64617. /**
  64618. * Enables contributions to the sliding window sample set
  64619. */
  64620. enable(): void;
  64621. /**
  64622. * Disables contributions to the sliding window sample set
  64623. * Samples will not be interpolated over the disabled period
  64624. */
  64625. disable(): void;
  64626. /**
  64627. * Returns true if sampling is enabled
  64628. */
  64629. readonly isEnabled: boolean;
  64630. /**
  64631. * Resets performance monitor
  64632. */
  64633. reset(): void;
  64634. }
  64635. /**
  64636. * RollingAverage
  64637. *
  64638. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64639. */
  64640. export class RollingAverage {
  64641. /**
  64642. * Current average
  64643. */
  64644. average: number;
  64645. /**
  64646. * Current variance
  64647. */
  64648. variance: number;
  64649. protected _samples: Array<number>;
  64650. protected _sampleCount: number;
  64651. protected _pos: number;
  64652. protected _m2: number;
  64653. /**
  64654. * constructor
  64655. * @param length The number of samples required to saturate the sliding window
  64656. */
  64657. constructor(length: number);
  64658. /**
  64659. * Adds a sample to the sample set
  64660. * @param v The sample value
  64661. */
  64662. add(v: number): void;
  64663. /**
  64664. * Returns previously added values or null if outside of history or outside the sliding window domain
  64665. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64666. * @return Value previously recorded with add() or null if outside of range
  64667. */
  64668. history(i: number): number;
  64669. /**
  64670. * Returns true if enough samples have been taken to completely fill the sliding window
  64671. * @return true if sample-set saturated
  64672. */
  64673. isSaturated(): boolean;
  64674. /**
  64675. * Resets the rolling average (equivalent to 0 samples taken so far)
  64676. */
  64677. reset(): void;
  64678. /**
  64679. * Wraps a value around the sample range boundaries
  64680. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64681. * @return Wrapped position in sample range
  64682. */
  64683. protected _wrapPosition(i: number): number;
  64684. }
  64685. }
  64686. declare module BABYLON {
  64687. /**
  64688. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64689. * The underlying implementation relies on an associative array to ensure the best performances.
  64690. * The value can be anything including 'null' but except 'undefined'
  64691. */
  64692. export class StringDictionary<T> {
  64693. /**
  64694. * This will clear this dictionary and copy the content from the 'source' one.
  64695. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64696. * @param source the dictionary to take the content from and copy to this dictionary
  64697. */
  64698. copyFrom(source: StringDictionary<T>): void;
  64699. /**
  64700. * Get a value based from its key
  64701. * @param key the given key to get the matching value from
  64702. * @return the value if found, otherwise undefined is returned
  64703. */
  64704. get(key: string): T | undefined;
  64705. /**
  64706. * Get a value from its key or add it if it doesn't exist.
  64707. * This method will ensure you that a given key/data will be present in the dictionary.
  64708. * @param key the given key to get the matching value from
  64709. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64710. * The factory will only be invoked if there's no data for the given key.
  64711. * @return the value corresponding to the key.
  64712. */
  64713. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64714. /**
  64715. * Get a value from its key if present in the dictionary otherwise add it
  64716. * @param key the key to get the value from
  64717. * @param val if there's no such key/value pair in the dictionary add it with this value
  64718. * @return the value corresponding to the key
  64719. */
  64720. getOrAdd(key: string, val: T): T;
  64721. /**
  64722. * Check if there's a given key in the dictionary
  64723. * @param key the key to check for
  64724. * @return true if the key is present, false otherwise
  64725. */
  64726. contains(key: string): boolean;
  64727. /**
  64728. * Add a new key and its corresponding value
  64729. * @param key the key to add
  64730. * @param value the value corresponding to the key
  64731. * @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
  64732. */
  64733. add(key: string, value: T): boolean;
  64734. /**
  64735. * Update a specific value associated to a key
  64736. * @param key defines the key to use
  64737. * @param value defines the value to store
  64738. * @returns true if the value was updated (or false if the key was not found)
  64739. */
  64740. set(key: string, value: T): boolean;
  64741. /**
  64742. * Get the element of the given key and remove it from the dictionary
  64743. * @param key defines the key to search
  64744. * @returns the value associated with the key or null if not found
  64745. */
  64746. getAndRemove(key: string): Nullable<T>;
  64747. /**
  64748. * Remove a key/value from the dictionary.
  64749. * @param key the key to remove
  64750. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64751. */
  64752. remove(key: string): boolean;
  64753. /**
  64754. * Clear the whole content of the dictionary
  64755. */
  64756. clear(): void;
  64757. /**
  64758. * Gets the current count
  64759. */
  64760. readonly count: number;
  64761. /**
  64762. * Execute a callback on each key/val of the dictionary.
  64763. * Note that you can remove any element in this dictionary in the callback implementation
  64764. * @param callback the callback to execute on a given key/value pair
  64765. */
  64766. forEach(callback: (key: string, val: T) => void): void;
  64767. /**
  64768. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64769. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64770. * Note that you can remove any element in this dictionary in the callback implementation
  64771. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64772. * @returns the first item
  64773. */
  64774. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64775. private _count;
  64776. private _data;
  64777. }
  64778. }
  64779. declare module BABYLON {
  64780. /**
  64781. * Helper class that provides a small promise polyfill
  64782. */
  64783. export class PromisePolyfill {
  64784. /**
  64785. * Static function used to check if the polyfill is required
  64786. * If this is the case then the function will inject the polyfill to window.Promise
  64787. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  64788. */
  64789. static Apply(force?: boolean): void;
  64790. }
  64791. }
  64792. declare module BABYLON {
  64793. /**
  64794. * Class used to store data that will be store in GPU memory
  64795. */
  64796. export class Buffer {
  64797. private _engine;
  64798. private _buffer;
  64799. /** @hidden */
  64800. _data: Nullable<DataArray>;
  64801. private _updatable;
  64802. private _instanced;
  64803. /**
  64804. * Gets the byte stride.
  64805. */
  64806. readonly byteStride: number;
  64807. /**
  64808. * Constructor
  64809. * @param engine the engine
  64810. * @param data the data to use for this buffer
  64811. * @param updatable whether the data is updatable
  64812. * @param stride the stride (optional)
  64813. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64814. * @param instanced whether the buffer is instanced (optional)
  64815. * @param useBytes set to true if the stride in in bytes (optional)
  64816. */
  64817. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64818. /**
  64819. * Create a new VertexBuffer based on the current buffer
  64820. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64821. * @param offset defines offset in the buffer (0 by default)
  64822. * @param size defines the size in floats of attributes (position is 3 for instance)
  64823. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64824. * @param instanced defines if the vertex buffer contains indexed data
  64825. * @param useBytes defines if the offset and stride are in bytes
  64826. * @returns the new vertex buffer
  64827. */
  64828. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64829. /**
  64830. * Gets a boolean indicating if the Buffer is updatable?
  64831. * @returns true if the buffer is updatable
  64832. */
  64833. isUpdatable(): boolean;
  64834. /**
  64835. * Gets current buffer's data
  64836. * @returns a DataArray or null
  64837. */
  64838. getData(): Nullable<DataArray>;
  64839. /**
  64840. * Gets underlying native buffer
  64841. * @returns underlying native buffer
  64842. */
  64843. getBuffer(): Nullable<WebGLBuffer>;
  64844. /**
  64845. * Gets the stride in float32 units (i.e. byte stride / 4).
  64846. * May not be an integer if the byte stride is not divisible by 4.
  64847. * DEPRECATED. Use byteStride instead.
  64848. * @returns the stride in float32 units
  64849. */
  64850. getStrideSize(): number;
  64851. /**
  64852. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64853. * @param data defines the data to store
  64854. */
  64855. create(data?: Nullable<DataArray>): void;
  64856. /** @hidden */
  64857. _rebuild(): void;
  64858. /**
  64859. * Update current buffer data
  64860. * @param data defines the data to store
  64861. */
  64862. update(data: DataArray): void;
  64863. /**
  64864. * Updates the data directly.
  64865. * @param data the new data
  64866. * @param offset the new offset
  64867. * @param vertexCount the vertex count (optional)
  64868. * @param useBytes set to true if the offset is in bytes
  64869. */
  64870. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64871. /**
  64872. * Release all resources
  64873. */
  64874. dispose(): void;
  64875. }
  64876. /**
  64877. * Specialized buffer used to store vertex data
  64878. */
  64879. export class VertexBuffer {
  64880. /** @hidden */
  64881. _buffer: Buffer;
  64882. private _kind;
  64883. private _size;
  64884. private _ownsBuffer;
  64885. private _instanced;
  64886. private _instanceDivisor;
  64887. /**
  64888. * The byte type.
  64889. */
  64890. static readonly BYTE: number;
  64891. /**
  64892. * The unsigned byte type.
  64893. */
  64894. static readonly UNSIGNED_BYTE: number;
  64895. /**
  64896. * The short type.
  64897. */
  64898. static readonly SHORT: number;
  64899. /**
  64900. * The unsigned short type.
  64901. */
  64902. static readonly UNSIGNED_SHORT: number;
  64903. /**
  64904. * The integer type.
  64905. */
  64906. static readonly INT: number;
  64907. /**
  64908. * The unsigned integer type.
  64909. */
  64910. static readonly UNSIGNED_INT: number;
  64911. /**
  64912. * The float type.
  64913. */
  64914. static readonly FLOAT: number;
  64915. /**
  64916. * Gets or sets the instance divisor when in instanced mode
  64917. */
  64918. instanceDivisor: number;
  64919. /**
  64920. * Gets the byte stride.
  64921. */
  64922. readonly byteStride: number;
  64923. /**
  64924. * Gets the byte offset.
  64925. */
  64926. readonly byteOffset: number;
  64927. /**
  64928. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64929. */
  64930. readonly normalized: boolean;
  64931. /**
  64932. * Gets the data type of each component in the array.
  64933. */
  64934. readonly type: number;
  64935. /**
  64936. * Constructor
  64937. * @param engine the engine
  64938. * @param data the data to use for this vertex buffer
  64939. * @param kind the vertex buffer kind
  64940. * @param updatable whether the data is updatable
  64941. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64942. * @param stride the stride (optional)
  64943. * @param instanced whether the buffer is instanced (optional)
  64944. * @param offset the offset of the data (optional)
  64945. * @param size the number of components (optional)
  64946. * @param type the type of the component (optional)
  64947. * @param normalized whether the data contains normalized data (optional)
  64948. * @param useBytes set to true if stride and offset are in bytes (optional)
  64949. */
  64950. 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);
  64951. /** @hidden */
  64952. _rebuild(): void;
  64953. /**
  64954. * Returns the kind of the VertexBuffer (string)
  64955. * @returns a string
  64956. */
  64957. getKind(): string;
  64958. /**
  64959. * Gets a boolean indicating if the VertexBuffer is updatable?
  64960. * @returns true if the buffer is updatable
  64961. */
  64962. isUpdatable(): boolean;
  64963. /**
  64964. * Gets current buffer's data
  64965. * @returns a DataArray or null
  64966. */
  64967. getData(): Nullable<DataArray>;
  64968. /**
  64969. * Gets underlying native buffer
  64970. * @returns underlying native buffer
  64971. */
  64972. getBuffer(): Nullable<WebGLBuffer>;
  64973. /**
  64974. * Gets the stride in float32 units (i.e. byte stride / 4).
  64975. * May not be an integer if the byte stride is not divisible by 4.
  64976. * DEPRECATED. Use byteStride instead.
  64977. * @returns the stride in float32 units
  64978. */
  64979. getStrideSize(): number;
  64980. /**
  64981. * Returns the offset as a multiple of the type byte length.
  64982. * DEPRECATED. Use byteOffset instead.
  64983. * @returns the offset in bytes
  64984. */
  64985. getOffset(): number;
  64986. /**
  64987. * Returns the number of components per vertex attribute (integer)
  64988. * @returns the size in float
  64989. */
  64990. getSize(): number;
  64991. /**
  64992. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64993. * @returns true if this buffer is instanced
  64994. */
  64995. getIsInstanced(): boolean;
  64996. /**
  64997. * Returns the instancing divisor, zero for non-instanced (integer).
  64998. * @returns a number
  64999. */
  65000. getInstanceDivisor(): number;
  65001. /**
  65002. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65003. * @param data defines the data to store
  65004. */
  65005. create(data?: DataArray): void;
  65006. /**
  65007. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65008. * This function will create a new buffer if the current one is not updatable
  65009. * @param data defines the data to store
  65010. */
  65011. update(data: DataArray): void;
  65012. /**
  65013. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65014. * Returns the directly updated WebGLBuffer.
  65015. * @param data the new data
  65016. * @param offset the new offset
  65017. * @param useBytes set to true if the offset is in bytes
  65018. */
  65019. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65020. /**
  65021. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65022. */
  65023. dispose(): void;
  65024. /**
  65025. * Enumerates each value of this vertex buffer as numbers.
  65026. * @param count the number of values to enumerate
  65027. * @param callback the callback function called for each value
  65028. */
  65029. forEach(count: number, callback: (value: number, index: number) => void): void;
  65030. /**
  65031. * Positions
  65032. */
  65033. static readonly PositionKind: string;
  65034. /**
  65035. * Normals
  65036. */
  65037. static readonly NormalKind: string;
  65038. /**
  65039. * Tangents
  65040. */
  65041. static readonly TangentKind: string;
  65042. /**
  65043. * Texture coordinates
  65044. */
  65045. static readonly UVKind: string;
  65046. /**
  65047. * Texture coordinates 2
  65048. */
  65049. static readonly UV2Kind: string;
  65050. /**
  65051. * Texture coordinates 3
  65052. */
  65053. static readonly UV3Kind: string;
  65054. /**
  65055. * Texture coordinates 4
  65056. */
  65057. static readonly UV4Kind: string;
  65058. /**
  65059. * Texture coordinates 5
  65060. */
  65061. static readonly UV5Kind: string;
  65062. /**
  65063. * Texture coordinates 6
  65064. */
  65065. static readonly UV6Kind: string;
  65066. /**
  65067. * Colors
  65068. */
  65069. static readonly ColorKind: string;
  65070. /**
  65071. * Matrix indices (for bones)
  65072. */
  65073. static readonly MatricesIndicesKind: string;
  65074. /**
  65075. * Matrix weights (for bones)
  65076. */
  65077. static readonly MatricesWeightsKind: string;
  65078. /**
  65079. * Additional matrix indices (for bones)
  65080. */
  65081. static readonly MatricesIndicesExtraKind: string;
  65082. /**
  65083. * Additional matrix weights (for bones)
  65084. */
  65085. static readonly MatricesWeightsExtraKind: string;
  65086. /**
  65087. * Deduces the stride given a kind.
  65088. * @param kind The kind string to deduce
  65089. * @returns The deduced stride
  65090. */
  65091. static DeduceStride(kind: string): number;
  65092. /**
  65093. * Gets the byte length of the given type.
  65094. * @param type the type
  65095. * @returns the number of bytes
  65096. */
  65097. static GetTypeByteLength(type: number): number;
  65098. /**
  65099. * Enumerates each value of the given parameters as numbers.
  65100. * @param data the data to enumerate
  65101. * @param byteOffset the byte offset of the data
  65102. * @param byteStride the byte stride of the data
  65103. * @param componentCount the number of components per element
  65104. * @param componentType the type of the component
  65105. * @param count the total number of components
  65106. * @param normalized whether the data is normalized
  65107. * @param callback the callback function called for each value
  65108. */
  65109. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65110. private static _GetFloatValue;
  65111. }
  65112. }
  65113. declare module BABYLON {
  65114. /**
  65115. * Class representing spherical polynomial coefficients to the 3rd degree
  65116. */
  65117. export class SphericalPolynomial {
  65118. /**
  65119. * The x coefficients of the spherical polynomial
  65120. */
  65121. x: Vector3;
  65122. /**
  65123. * The y coefficients of the spherical polynomial
  65124. */
  65125. y: Vector3;
  65126. /**
  65127. * The z coefficients of the spherical polynomial
  65128. */
  65129. z: Vector3;
  65130. /**
  65131. * The xx coefficients of the spherical polynomial
  65132. */
  65133. xx: Vector3;
  65134. /**
  65135. * The yy coefficients of the spherical polynomial
  65136. */
  65137. yy: Vector3;
  65138. /**
  65139. * The zz coefficients of the spherical polynomial
  65140. */
  65141. zz: Vector3;
  65142. /**
  65143. * The xy coefficients of the spherical polynomial
  65144. */
  65145. xy: Vector3;
  65146. /**
  65147. * The yz coefficients of the spherical polynomial
  65148. */
  65149. yz: Vector3;
  65150. /**
  65151. * The zx coefficients of the spherical polynomial
  65152. */
  65153. zx: Vector3;
  65154. /**
  65155. * Adds an ambient color to the spherical polynomial
  65156. * @param color the color to add
  65157. */
  65158. addAmbient(color: Color3): void;
  65159. /**
  65160. * Scales the spherical polynomial by the given amount
  65161. * @param scale the amount to scale
  65162. */
  65163. scale(scale: number): void;
  65164. /**
  65165. * Gets the spherical polynomial from harmonics
  65166. * @param harmonics the spherical harmonics
  65167. * @returns the spherical polynomial
  65168. */
  65169. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65170. /**
  65171. * Constructs a spherical polynomial from an array.
  65172. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65173. * @returns the spherical polynomial
  65174. */
  65175. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65176. }
  65177. /**
  65178. * Class representing spherical harmonics coefficients to the 3rd degree
  65179. */
  65180. export class SphericalHarmonics {
  65181. /**
  65182. * The l0,0 coefficients of the spherical harmonics
  65183. */
  65184. l00: Vector3;
  65185. /**
  65186. * The l1,-1 coefficients of the spherical harmonics
  65187. */
  65188. l1_1: Vector3;
  65189. /**
  65190. * The l1,0 coefficients of the spherical harmonics
  65191. */
  65192. l10: Vector3;
  65193. /**
  65194. * The l1,1 coefficients of the spherical harmonics
  65195. */
  65196. l11: Vector3;
  65197. /**
  65198. * The l2,-2 coefficients of the spherical harmonics
  65199. */
  65200. l2_2: Vector3;
  65201. /**
  65202. * The l2,-1 coefficients of the spherical harmonics
  65203. */
  65204. l2_1: Vector3;
  65205. /**
  65206. * The l2,0 coefficients of the spherical harmonics
  65207. */
  65208. l20: Vector3;
  65209. /**
  65210. * The l2,1 coefficients of the spherical harmonics
  65211. */
  65212. l21: Vector3;
  65213. /**
  65214. * The l2,2 coefficients of the spherical harmonics
  65215. */
  65216. lL22: Vector3;
  65217. /**
  65218. * Adds a light to the spherical harmonics
  65219. * @param direction the direction of the light
  65220. * @param color the color of the light
  65221. * @param deltaSolidAngle the delta solid angle of the light
  65222. */
  65223. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65224. /**
  65225. * Scales the spherical harmonics by the given amount
  65226. * @param scale the amount to scale
  65227. */
  65228. scale(scale: number): void;
  65229. /**
  65230. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65231. *
  65232. * ```
  65233. * E_lm = A_l * L_lm
  65234. * ```
  65235. *
  65236. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65237. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65238. * the scaling factors are given in equation 9.
  65239. */
  65240. convertIncidentRadianceToIrradiance(): void;
  65241. /**
  65242. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65243. *
  65244. * ```
  65245. * L = (1/pi) * E * rho
  65246. * ```
  65247. *
  65248. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65249. */
  65250. convertIrradianceToLambertianRadiance(): void;
  65251. /**
  65252. * Gets the spherical harmonics from polynomial
  65253. * @param polynomial the spherical polynomial
  65254. * @returns the spherical harmonics
  65255. */
  65256. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65257. /**
  65258. * Constructs a spherical harmonics from an array.
  65259. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65260. * @returns the spherical harmonics
  65261. */
  65262. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65263. }
  65264. }
  65265. declare module BABYLON {
  65266. /**
  65267. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65268. */
  65269. export interface CubeMapInfo {
  65270. /**
  65271. * The pixel array for the front face.
  65272. * This is stored in format, left to right, up to down format.
  65273. */
  65274. front: Nullable<ArrayBufferView>;
  65275. /**
  65276. * The pixel array for the back face.
  65277. * This is stored in format, left to right, up to down format.
  65278. */
  65279. back: Nullable<ArrayBufferView>;
  65280. /**
  65281. * The pixel array for the left face.
  65282. * This is stored in format, left to right, up to down format.
  65283. */
  65284. left: Nullable<ArrayBufferView>;
  65285. /**
  65286. * The pixel array for the right face.
  65287. * This is stored in format, left to right, up to down format.
  65288. */
  65289. right: Nullable<ArrayBufferView>;
  65290. /**
  65291. * The pixel array for the up face.
  65292. * This is stored in format, left to right, up to down format.
  65293. */
  65294. up: Nullable<ArrayBufferView>;
  65295. /**
  65296. * The pixel array for the down face.
  65297. * This is stored in format, left to right, up to down format.
  65298. */
  65299. down: Nullable<ArrayBufferView>;
  65300. /**
  65301. * The size of the cubemap stored.
  65302. *
  65303. * Each faces will be size * size pixels.
  65304. */
  65305. size: number;
  65306. /**
  65307. * The format of the texture.
  65308. *
  65309. * RGBA, RGB.
  65310. */
  65311. format: number;
  65312. /**
  65313. * The type of the texture data.
  65314. *
  65315. * UNSIGNED_INT, FLOAT.
  65316. */
  65317. type: number;
  65318. /**
  65319. * Specifies whether the texture is in gamma space.
  65320. */
  65321. gammaSpace: boolean;
  65322. }
  65323. /**
  65324. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65325. */
  65326. export class PanoramaToCubeMapTools {
  65327. private static FACE_FRONT;
  65328. private static FACE_BACK;
  65329. private static FACE_RIGHT;
  65330. private static FACE_LEFT;
  65331. private static FACE_DOWN;
  65332. private static FACE_UP;
  65333. /**
  65334. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65335. *
  65336. * @param float32Array The source data.
  65337. * @param inputWidth The width of the input panorama.
  65338. * @param inputHeight The height of the input panorama.
  65339. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65340. * @return The cubemap data
  65341. */
  65342. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65343. private static CreateCubemapTexture;
  65344. private static CalcProjectionSpherical;
  65345. }
  65346. }
  65347. declare module BABYLON {
  65348. /**
  65349. * Helper class dealing with the extraction of spherical polynomial dataArray
  65350. * from a cube map.
  65351. */
  65352. export class CubeMapToSphericalPolynomialTools {
  65353. private static FileFaces;
  65354. /**
  65355. * Converts a texture to the according Spherical Polynomial data.
  65356. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65357. *
  65358. * @param texture The texture to extract the information from.
  65359. * @return The Spherical Polynomial data.
  65360. */
  65361. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65362. /**
  65363. * Converts a cubemap to the according Spherical Polynomial data.
  65364. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65365. *
  65366. * @param cubeInfo The Cube map to extract the information from.
  65367. * @return The Spherical Polynomial data.
  65368. */
  65369. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  65370. }
  65371. }
  65372. declare module BABYLON {
  65373. /**
  65374. * The engine store class is responsible to hold all the instances of Engine and Scene created
  65375. * during the life time of the application.
  65376. */
  65377. export class EngineStore {
  65378. /** Gets the list of created engines */
  65379. static Instances: Engine[];
  65380. /**
  65381. * Gets the latest created engine
  65382. */
  65383. static readonly LastCreatedEngine: Nullable<Engine>;
  65384. /**
  65385. * Gets the latest created scene
  65386. */
  65387. static readonly LastCreatedScene: Nullable<Scene>;
  65388. }
  65389. }
  65390. declare module BABYLON {
  65391. /**
  65392. * Define options used to create a render target texture
  65393. */
  65394. export class RenderTargetCreationOptions {
  65395. /**
  65396. * Specifies is mipmaps must be generated
  65397. */
  65398. generateMipMaps?: boolean;
  65399. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  65400. generateDepthBuffer?: boolean;
  65401. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  65402. generateStencilBuffer?: boolean;
  65403. /** Defines texture type (int by default) */
  65404. type?: number;
  65405. /** Defines sampling mode (trilinear by default) */
  65406. samplingMode?: number;
  65407. /** Defines format (RGBA by default) */
  65408. format?: number;
  65409. }
  65410. }
  65411. declare module BABYLON {
  65412. /**
  65413. * @hidden
  65414. **/
  65415. export class _AlphaState {
  65416. private _isAlphaBlendDirty;
  65417. private _isBlendFunctionParametersDirty;
  65418. private _isBlendEquationParametersDirty;
  65419. private _isBlendConstantsDirty;
  65420. private _alphaBlend;
  65421. private _blendFunctionParameters;
  65422. private _blendEquationParameters;
  65423. private _blendConstants;
  65424. /**
  65425. * Initializes the state.
  65426. */
  65427. constructor();
  65428. readonly isDirty: boolean;
  65429. alphaBlend: boolean;
  65430. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  65431. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  65432. setAlphaEquationParameters(rgb: number, alpha: number): void;
  65433. reset(): void;
  65434. apply(gl: WebGLRenderingContext): void;
  65435. }
  65436. }
  65437. declare module BABYLON {
  65438. /**
  65439. * @hidden
  65440. **/
  65441. export class _DepthCullingState {
  65442. private _isDepthTestDirty;
  65443. private _isDepthMaskDirty;
  65444. private _isDepthFuncDirty;
  65445. private _isCullFaceDirty;
  65446. private _isCullDirty;
  65447. private _isZOffsetDirty;
  65448. private _isFrontFaceDirty;
  65449. private _depthTest;
  65450. private _depthMask;
  65451. private _depthFunc;
  65452. private _cull;
  65453. private _cullFace;
  65454. private _zOffset;
  65455. private _frontFace;
  65456. /**
  65457. * Initializes the state.
  65458. */
  65459. constructor();
  65460. readonly isDirty: boolean;
  65461. zOffset: number;
  65462. cullFace: Nullable<number>;
  65463. cull: Nullable<boolean>;
  65464. depthFunc: Nullable<number>;
  65465. depthMask: boolean;
  65466. depthTest: boolean;
  65467. frontFace: Nullable<number>;
  65468. reset(): void;
  65469. apply(gl: WebGLRenderingContext): void;
  65470. }
  65471. }
  65472. declare module BABYLON {
  65473. /**
  65474. * @hidden
  65475. **/
  65476. export class _StencilState {
  65477. /** 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 */
  65478. static readonly ALWAYS: number;
  65479. /** Passed to stencilOperation to specify that stencil value must be kept */
  65480. static readonly KEEP: number;
  65481. /** Passed to stencilOperation to specify that stencil value must be replaced */
  65482. static readonly REPLACE: number;
  65483. private _isStencilTestDirty;
  65484. private _isStencilMaskDirty;
  65485. private _isStencilFuncDirty;
  65486. private _isStencilOpDirty;
  65487. private _stencilTest;
  65488. private _stencilMask;
  65489. private _stencilFunc;
  65490. private _stencilFuncRef;
  65491. private _stencilFuncMask;
  65492. private _stencilOpStencilFail;
  65493. private _stencilOpDepthFail;
  65494. private _stencilOpStencilDepthPass;
  65495. readonly isDirty: boolean;
  65496. stencilFunc: number;
  65497. stencilFuncRef: number;
  65498. stencilFuncMask: number;
  65499. stencilOpStencilFail: number;
  65500. stencilOpDepthFail: number;
  65501. stencilOpStencilDepthPass: number;
  65502. stencilMask: number;
  65503. stencilTest: boolean;
  65504. constructor();
  65505. reset(): void;
  65506. apply(gl: WebGLRenderingContext): void;
  65507. }
  65508. }
  65509. declare module BABYLON {
  65510. /**
  65511. * @hidden
  65512. **/
  65513. export class _TimeToken {
  65514. _startTimeQuery: Nullable<WebGLQuery>;
  65515. _endTimeQuery: Nullable<WebGLQuery>;
  65516. _timeElapsedQuery: Nullable<WebGLQuery>;
  65517. _timeElapsedQueryEnded: boolean;
  65518. }
  65519. }
  65520. declare module BABYLON {
  65521. /**
  65522. * Class used to store data associated with WebGL texture data for the engine
  65523. * This class should not be used directly
  65524. */
  65525. export class InternalTexture {
  65526. /** hidden */
  65527. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  65528. /**
  65529. * The source of the texture data is unknown
  65530. */
  65531. static DATASOURCE_UNKNOWN: number;
  65532. /**
  65533. * Texture data comes from an URL
  65534. */
  65535. static DATASOURCE_URL: number;
  65536. /**
  65537. * Texture data is only used for temporary storage
  65538. */
  65539. static DATASOURCE_TEMP: number;
  65540. /**
  65541. * Texture data comes from raw data (ArrayBuffer)
  65542. */
  65543. static DATASOURCE_RAW: number;
  65544. /**
  65545. * Texture content is dynamic (video or dynamic texture)
  65546. */
  65547. static DATASOURCE_DYNAMIC: number;
  65548. /**
  65549. * Texture content is generated by rendering to it
  65550. */
  65551. static DATASOURCE_RENDERTARGET: number;
  65552. /**
  65553. * Texture content is part of a multi render target process
  65554. */
  65555. static DATASOURCE_MULTIRENDERTARGET: number;
  65556. /**
  65557. * Texture data comes from a cube data file
  65558. */
  65559. static DATASOURCE_CUBE: number;
  65560. /**
  65561. * Texture data comes from a raw cube data
  65562. */
  65563. static DATASOURCE_CUBERAW: number;
  65564. /**
  65565. * Texture data come from a prefiltered cube data file
  65566. */
  65567. static DATASOURCE_CUBEPREFILTERED: number;
  65568. /**
  65569. * Texture content is raw 3D data
  65570. */
  65571. static DATASOURCE_RAW3D: number;
  65572. /**
  65573. * Texture content is a depth texture
  65574. */
  65575. static DATASOURCE_DEPTHTEXTURE: number;
  65576. /**
  65577. * Texture data comes from a raw cube data encoded with RGBD
  65578. */
  65579. static DATASOURCE_CUBERAW_RGBD: number;
  65580. /**
  65581. * Defines if the texture is ready
  65582. */
  65583. isReady: boolean;
  65584. /**
  65585. * Defines if the texture is a cube texture
  65586. */
  65587. isCube: boolean;
  65588. /**
  65589. * Defines if the texture contains 3D data
  65590. */
  65591. is3D: boolean;
  65592. /**
  65593. * Defines if the texture contains multiview data
  65594. */
  65595. isMultiview: boolean;
  65596. /**
  65597. * Gets the URL used to load this texture
  65598. */
  65599. url: string;
  65600. /**
  65601. * Gets the sampling mode of the texture
  65602. */
  65603. samplingMode: number;
  65604. /**
  65605. * Gets a boolean indicating if the texture needs mipmaps generation
  65606. */
  65607. generateMipMaps: boolean;
  65608. /**
  65609. * Gets the number of samples used by the texture (WebGL2+ only)
  65610. */
  65611. samples: number;
  65612. /**
  65613. * Gets the type of the texture (int, float...)
  65614. */
  65615. type: number;
  65616. /**
  65617. * Gets the format of the texture (RGB, RGBA...)
  65618. */
  65619. format: number;
  65620. /**
  65621. * Observable called when the texture is loaded
  65622. */
  65623. onLoadedObservable: Observable<InternalTexture>;
  65624. /**
  65625. * Gets the width of the texture
  65626. */
  65627. width: number;
  65628. /**
  65629. * Gets the height of the texture
  65630. */
  65631. height: number;
  65632. /**
  65633. * Gets the depth of the texture
  65634. */
  65635. depth: number;
  65636. /**
  65637. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  65638. */
  65639. baseWidth: number;
  65640. /**
  65641. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  65642. */
  65643. baseHeight: number;
  65644. /**
  65645. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  65646. */
  65647. baseDepth: number;
  65648. /**
  65649. * Gets a boolean indicating if the texture is inverted on Y axis
  65650. */
  65651. invertY: boolean;
  65652. /** @hidden */
  65653. _invertVScale: boolean;
  65654. /** @hidden */
  65655. _associatedChannel: number;
  65656. /** @hidden */
  65657. _dataSource: number;
  65658. /** @hidden */
  65659. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  65660. /** @hidden */
  65661. _bufferView: Nullable<ArrayBufferView>;
  65662. /** @hidden */
  65663. _bufferViewArray: Nullable<ArrayBufferView[]>;
  65664. /** @hidden */
  65665. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  65666. /** @hidden */
  65667. _size: number;
  65668. /** @hidden */
  65669. _extension: string;
  65670. /** @hidden */
  65671. _files: Nullable<string[]>;
  65672. /** @hidden */
  65673. _workingCanvas: HTMLCanvasElement;
  65674. /** @hidden */
  65675. _workingContext: CanvasRenderingContext2D;
  65676. /** @hidden */
  65677. _framebuffer: Nullable<WebGLFramebuffer>;
  65678. /** @hidden */
  65679. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  65680. /** @hidden */
  65681. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  65682. /** @hidden */
  65683. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  65684. /** @hidden */
  65685. _attachments: Nullable<number[]>;
  65686. /** @hidden */
  65687. _cachedCoordinatesMode: Nullable<number>;
  65688. /** @hidden */
  65689. _cachedWrapU: Nullable<number>;
  65690. /** @hidden */
  65691. _cachedWrapV: Nullable<number>;
  65692. /** @hidden */
  65693. _cachedWrapR: Nullable<number>;
  65694. /** @hidden */
  65695. _cachedAnisotropicFilteringLevel: Nullable<number>;
  65696. /** @hidden */
  65697. _isDisabled: boolean;
  65698. /** @hidden */
  65699. _compression: Nullable<string>;
  65700. /** @hidden */
  65701. _generateStencilBuffer: boolean;
  65702. /** @hidden */
  65703. _generateDepthBuffer: boolean;
  65704. /** @hidden */
  65705. _comparisonFunction: number;
  65706. /** @hidden */
  65707. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  65708. /** @hidden */
  65709. _lodGenerationScale: number;
  65710. /** @hidden */
  65711. _lodGenerationOffset: number;
  65712. /** @hidden */
  65713. _colorTextureArray: Nullable<WebGLTexture>;
  65714. /** @hidden */
  65715. _depthStencilTextureArray: Nullable<WebGLTexture>;
  65716. /** @hidden */
  65717. _lodTextureHigh: BaseTexture;
  65718. /** @hidden */
  65719. _lodTextureMid: BaseTexture;
  65720. /** @hidden */
  65721. _lodTextureLow: BaseTexture;
  65722. /** @hidden */
  65723. _isRGBD: boolean;
  65724. /** @hidden */
  65725. _webGLTexture: Nullable<WebGLTexture>;
  65726. /** @hidden */
  65727. _references: number;
  65728. private _engine;
  65729. /**
  65730. * Gets the Engine the texture belongs to.
  65731. * @returns The babylon engine
  65732. */
  65733. getEngine(): Engine;
  65734. /**
  65735. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  65736. */
  65737. readonly dataSource: number;
  65738. /**
  65739. * Creates a new InternalTexture
  65740. * @param engine defines the engine to use
  65741. * @param dataSource defines the type of data that will be used
  65742. * @param delayAllocation if the texture allocation should be delayed (default: false)
  65743. */
  65744. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  65745. /**
  65746. * Increments the number of references (ie. the number of Texture that point to it)
  65747. */
  65748. incrementReferences(): void;
  65749. /**
  65750. * Change the size of the texture (not the size of the content)
  65751. * @param width defines the new width
  65752. * @param height defines the new height
  65753. * @param depth defines the new depth (1 by default)
  65754. */
  65755. updateSize(width: int, height: int, depth?: int): void;
  65756. /** @hidden */
  65757. _rebuild(): void;
  65758. /** @hidden */
  65759. _swapAndDie(target: InternalTexture): void;
  65760. /**
  65761. * Dispose the current allocated resources
  65762. */
  65763. dispose(): void;
  65764. }
  65765. }
  65766. declare module BABYLON {
  65767. /**
  65768. * This represents the main contract an easing function should follow.
  65769. * Easing functions are used throughout the animation system.
  65770. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65771. */
  65772. export interface IEasingFunction {
  65773. /**
  65774. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65775. * of the easing function.
  65776. * The link below provides some of the most common examples of easing functions.
  65777. * @see https://easings.net/
  65778. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65779. * @returns the corresponding value on the curve defined by the easing function
  65780. */
  65781. ease(gradient: number): number;
  65782. }
  65783. /**
  65784. * Base class used for every default easing function.
  65785. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65786. */
  65787. export class EasingFunction implements IEasingFunction {
  65788. /**
  65789. * Interpolation follows the mathematical formula associated with the easing function.
  65790. */
  65791. static readonly EASINGMODE_EASEIN: number;
  65792. /**
  65793. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  65794. */
  65795. static readonly EASINGMODE_EASEOUT: number;
  65796. /**
  65797. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  65798. */
  65799. static readonly EASINGMODE_EASEINOUT: number;
  65800. private _easingMode;
  65801. /**
  65802. * Sets the easing mode of the current function.
  65803. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  65804. */
  65805. setEasingMode(easingMode: number): void;
  65806. /**
  65807. * Gets the current easing mode.
  65808. * @returns the easing mode
  65809. */
  65810. getEasingMode(): number;
  65811. /**
  65812. * @hidden
  65813. */
  65814. easeInCore(gradient: number): number;
  65815. /**
  65816. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65817. * of the easing function.
  65818. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65819. * @returns the corresponding value on the curve defined by the easing function
  65820. */
  65821. ease(gradient: number): number;
  65822. }
  65823. /**
  65824. * Easing function with a circle shape (see link below).
  65825. * @see https://easings.net/#easeInCirc
  65826. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65827. */
  65828. export class CircleEase extends EasingFunction implements IEasingFunction {
  65829. /** @hidden */
  65830. easeInCore(gradient: number): number;
  65831. }
  65832. /**
  65833. * Easing function with a ease back shape (see link below).
  65834. * @see https://easings.net/#easeInBack
  65835. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65836. */
  65837. export class BackEase extends EasingFunction implements IEasingFunction {
  65838. /** Defines the amplitude of the function */
  65839. amplitude: number;
  65840. /**
  65841. * Instantiates a back ease easing
  65842. * @see https://easings.net/#easeInBack
  65843. * @param amplitude Defines the amplitude of the function
  65844. */
  65845. constructor(
  65846. /** Defines the amplitude of the function */
  65847. amplitude?: number);
  65848. /** @hidden */
  65849. easeInCore(gradient: number): number;
  65850. }
  65851. /**
  65852. * Easing function with a bouncing shape (see link below).
  65853. * @see https://easings.net/#easeInBounce
  65854. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65855. */
  65856. export class BounceEase extends EasingFunction implements IEasingFunction {
  65857. /** Defines the number of bounces */
  65858. bounces: number;
  65859. /** Defines the amplitude of the bounce */
  65860. bounciness: number;
  65861. /**
  65862. * Instantiates a bounce easing
  65863. * @see https://easings.net/#easeInBounce
  65864. * @param bounces Defines the number of bounces
  65865. * @param bounciness Defines the amplitude of the bounce
  65866. */
  65867. constructor(
  65868. /** Defines the number of bounces */
  65869. bounces?: number,
  65870. /** Defines the amplitude of the bounce */
  65871. bounciness?: number);
  65872. /** @hidden */
  65873. easeInCore(gradient: number): number;
  65874. }
  65875. /**
  65876. * Easing function with a power of 3 shape (see link below).
  65877. * @see https://easings.net/#easeInCubic
  65878. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65879. */
  65880. export class CubicEase extends EasingFunction implements IEasingFunction {
  65881. /** @hidden */
  65882. easeInCore(gradient: number): number;
  65883. }
  65884. /**
  65885. * Easing function with an elastic shape (see link below).
  65886. * @see https://easings.net/#easeInElastic
  65887. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65888. */
  65889. export class ElasticEase extends EasingFunction implements IEasingFunction {
  65890. /** Defines the number of oscillations*/
  65891. oscillations: number;
  65892. /** Defines the amplitude of the oscillations*/
  65893. springiness: number;
  65894. /**
  65895. * Instantiates an elastic easing function
  65896. * @see https://easings.net/#easeInElastic
  65897. * @param oscillations Defines the number of oscillations
  65898. * @param springiness Defines the amplitude of the oscillations
  65899. */
  65900. constructor(
  65901. /** Defines the number of oscillations*/
  65902. oscillations?: number,
  65903. /** Defines the amplitude of the oscillations*/
  65904. springiness?: number);
  65905. /** @hidden */
  65906. easeInCore(gradient: number): number;
  65907. }
  65908. /**
  65909. * Easing function with an exponential shape (see link below).
  65910. * @see https://easings.net/#easeInExpo
  65911. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65912. */
  65913. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  65914. /** Defines the exponent of the function */
  65915. exponent: number;
  65916. /**
  65917. * Instantiates an exponential easing function
  65918. * @see https://easings.net/#easeInExpo
  65919. * @param exponent Defines the exponent of the function
  65920. */
  65921. constructor(
  65922. /** Defines the exponent of the function */
  65923. exponent?: number);
  65924. /** @hidden */
  65925. easeInCore(gradient: number): number;
  65926. }
  65927. /**
  65928. * Easing function with a power shape (see link below).
  65929. * @see https://easings.net/#easeInQuad
  65930. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65931. */
  65932. export class PowerEase extends EasingFunction implements IEasingFunction {
  65933. /** Defines the power of the function */
  65934. power: number;
  65935. /**
  65936. * Instantiates an power base easing function
  65937. * @see https://easings.net/#easeInQuad
  65938. * @param power Defines the power of the function
  65939. */
  65940. constructor(
  65941. /** Defines the power of the function */
  65942. power?: number);
  65943. /** @hidden */
  65944. easeInCore(gradient: number): number;
  65945. }
  65946. /**
  65947. * Easing function with a power of 2 shape (see link below).
  65948. * @see https://easings.net/#easeInQuad
  65949. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65950. */
  65951. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  65952. /** @hidden */
  65953. easeInCore(gradient: number): number;
  65954. }
  65955. /**
  65956. * Easing function with a power of 4 shape (see link below).
  65957. * @see https://easings.net/#easeInQuart
  65958. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65959. */
  65960. export class QuarticEase extends EasingFunction implements IEasingFunction {
  65961. /** @hidden */
  65962. easeInCore(gradient: number): number;
  65963. }
  65964. /**
  65965. * Easing function with a power of 5 shape (see link below).
  65966. * @see https://easings.net/#easeInQuint
  65967. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65968. */
  65969. export class QuinticEase extends EasingFunction implements IEasingFunction {
  65970. /** @hidden */
  65971. easeInCore(gradient: number): number;
  65972. }
  65973. /**
  65974. * Easing function with a sin shape (see link below).
  65975. * @see https://easings.net/#easeInSine
  65976. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65977. */
  65978. export class SineEase extends EasingFunction implements IEasingFunction {
  65979. /** @hidden */
  65980. easeInCore(gradient: number): number;
  65981. }
  65982. /**
  65983. * Easing function with a bezier shape (see link below).
  65984. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65985. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65986. */
  65987. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  65988. /** Defines the x component of the start tangent in the bezier curve */
  65989. x1: number;
  65990. /** Defines the y component of the start tangent in the bezier curve */
  65991. y1: number;
  65992. /** Defines the x component of the end tangent in the bezier curve */
  65993. x2: number;
  65994. /** Defines the y component of the end tangent in the bezier curve */
  65995. y2: number;
  65996. /**
  65997. * Instantiates a bezier function
  65998. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65999. * @param x1 Defines the x component of the start tangent in the bezier curve
  66000. * @param y1 Defines the y component of the start tangent in the bezier curve
  66001. * @param x2 Defines the x component of the end tangent in the bezier curve
  66002. * @param y2 Defines the y component of the end tangent in the bezier curve
  66003. */
  66004. constructor(
  66005. /** Defines the x component of the start tangent in the bezier curve */
  66006. x1?: number,
  66007. /** Defines the y component of the start tangent in the bezier curve */
  66008. y1?: number,
  66009. /** Defines the x component of the end tangent in the bezier curve */
  66010. x2?: number,
  66011. /** Defines the y component of the end tangent in the bezier curve */
  66012. y2?: number);
  66013. /** @hidden */
  66014. easeInCore(gradient: number): number;
  66015. }
  66016. }
  66017. declare module BABYLON {
  66018. /**
  66019. * Defines an interface which represents an animation key frame
  66020. */
  66021. export interface IAnimationKey {
  66022. /**
  66023. * Frame of the key frame
  66024. */
  66025. frame: number;
  66026. /**
  66027. * Value at the specifies key frame
  66028. */
  66029. value: any;
  66030. /**
  66031. * The input tangent for the cubic hermite spline
  66032. */
  66033. inTangent?: any;
  66034. /**
  66035. * The output tangent for the cubic hermite spline
  66036. */
  66037. outTangent?: any;
  66038. /**
  66039. * The animation interpolation type
  66040. */
  66041. interpolation?: AnimationKeyInterpolation;
  66042. }
  66043. /**
  66044. * Enum for the animation key frame interpolation type
  66045. */
  66046. export enum AnimationKeyInterpolation {
  66047. /**
  66048. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66049. */
  66050. STEP = 1
  66051. }
  66052. }
  66053. declare module BABYLON {
  66054. /**
  66055. * Represents the range of an animation
  66056. */
  66057. export class AnimationRange {
  66058. /**The name of the animation range**/
  66059. name: string;
  66060. /**The starting frame of the animation */
  66061. from: number;
  66062. /**The ending frame of the animation*/
  66063. to: number;
  66064. /**
  66065. * Initializes the range of an animation
  66066. * @param name The name of the animation range
  66067. * @param from The starting frame of the animation
  66068. * @param to The ending frame of the animation
  66069. */
  66070. constructor(
  66071. /**The name of the animation range**/
  66072. name: string,
  66073. /**The starting frame of the animation */
  66074. from: number,
  66075. /**The ending frame of the animation*/
  66076. to: number);
  66077. /**
  66078. * Makes a copy of the animation range
  66079. * @returns A copy of the animation range
  66080. */
  66081. clone(): AnimationRange;
  66082. }
  66083. }
  66084. declare module BABYLON {
  66085. /**
  66086. * Composed of a frame, and an action function
  66087. */
  66088. export class AnimationEvent {
  66089. /** The frame for which the event is triggered **/
  66090. frame: number;
  66091. /** The event to perform when triggered **/
  66092. action: (currentFrame: number) => void;
  66093. /** Specifies if the event should be triggered only once**/
  66094. onlyOnce?: boolean | undefined;
  66095. /**
  66096. * Specifies if the animation event is done
  66097. */
  66098. isDone: boolean;
  66099. /**
  66100. * Initializes the animation event
  66101. * @param frame The frame for which the event is triggered
  66102. * @param action The event to perform when triggered
  66103. * @param onlyOnce Specifies if the event should be triggered only once
  66104. */
  66105. constructor(
  66106. /** The frame for which the event is triggered **/
  66107. frame: number,
  66108. /** The event to perform when triggered **/
  66109. action: (currentFrame: number) => void,
  66110. /** Specifies if the event should be triggered only once**/
  66111. onlyOnce?: boolean | undefined);
  66112. /** @hidden */
  66113. _clone(): AnimationEvent;
  66114. }
  66115. }
  66116. declare module BABYLON {
  66117. /**
  66118. * Interface used to define a behavior
  66119. */
  66120. export interface Behavior<T> {
  66121. /** gets or sets behavior's name */
  66122. name: string;
  66123. /**
  66124. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66125. */
  66126. init(): void;
  66127. /**
  66128. * Called when the behavior is attached to a target
  66129. * @param target defines the target where the behavior is attached to
  66130. */
  66131. attach(target: T): void;
  66132. /**
  66133. * Called when the behavior is detached from its target
  66134. */
  66135. detach(): void;
  66136. }
  66137. /**
  66138. * Interface implemented by classes supporting behaviors
  66139. */
  66140. export interface IBehaviorAware<T> {
  66141. /**
  66142. * Attach a behavior
  66143. * @param behavior defines the behavior to attach
  66144. * @returns the current host
  66145. */
  66146. addBehavior(behavior: Behavior<T>): T;
  66147. /**
  66148. * Remove a behavior from the current object
  66149. * @param behavior defines the behavior to detach
  66150. * @returns the current host
  66151. */
  66152. removeBehavior(behavior: Behavior<T>): T;
  66153. /**
  66154. * Gets a behavior using its name to search
  66155. * @param name defines the name to search
  66156. * @returns the behavior or null if not found
  66157. */
  66158. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66159. }
  66160. }
  66161. declare module BABYLON {
  66162. /**
  66163. * @hidden
  66164. */
  66165. export class IntersectionInfo {
  66166. bu: Nullable<number>;
  66167. bv: Nullable<number>;
  66168. distance: number;
  66169. faceId: number;
  66170. subMeshId: number;
  66171. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66172. }
  66173. }
  66174. declare module BABYLON {
  66175. /**
  66176. * Class used to store bounding sphere information
  66177. */
  66178. export class BoundingSphere {
  66179. /**
  66180. * Gets the center of the bounding sphere in local space
  66181. */
  66182. readonly center: Vector3;
  66183. /**
  66184. * Radius of the bounding sphere in local space
  66185. */
  66186. radius: number;
  66187. /**
  66188. * Gets the center of the bounding sphere in world space
  66189. */
  66190. readonly centerWorld: Vector3;
  66191. /**
  66192. * Radius of the bounding sphere in world space
  66193. */
  66194. radiusWorld: number;
  66195. /**
  66196. * Gets the minimum vector in local space
  66197. */
  66198. readonly minimum: Vector3;
  66199. /**
  66200. * Gets the maximum vector in local space
  66201. */
  66202. readonly maximum: Vector3;
  66203. private _worldMatrix;
  66204. private static readonly TmpVector3;
  66205. /**
  66206. * Creates a new bounding sphere
  66207. * @param min defines the minimum vector (in local space)
  66208. * @param max defines the maximum vector (in local space)
  66209. * @param worldMatrix defines the new world matrix
  66210. */
  66211. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66212. /**
  66213. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66214. * @param min defines the new minimum vector (in local space)
  66215. * @param max defines the new maximum vector (in local space)
  66216. * @param worldMatrix defines the new world matrix
  66217. */
  66218. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66219. /**
  66220. * Scale the current bounding sphere by applying a scale factor
  66221. * @param factor defines the scale factor to apply
  66222. * @returns the current bounding box
  66223. */
  66224. scale(factor: number): BoundingSphere;
  66225. /**
  66226. * Gets the world matrix of the bounding box
  66227. * @returns a matrix
  66228. */
  66229. getWorldMatrix(): DeepImmutable<Matrix>;
  66230. /** @hidden */
  66231. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66232. /**
  66233. * Tests if the bounding sphere is intersecting the frustum planes
  66234. * @param frustumPlanes defines the frustum planes to test
  66235. * @returns true if there is an intersection
  66236. */
  66237. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66238. /**
  66239. * Tests if the bounding sphere center is in between the frustum planes.
  66240. * Used for optimistic fast inclusion.
  66241. * @param frustumPlanes defines the frustum planes to test
  66242. * @returns true if the sphere center is in between the frustum planes
  66243. */
  66244. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66245. /**
  66246. * Tests if a point is inside the bounding sphere
  66247. * @param point defines the point to test
  66248. * @returns true if the point is inside the bounding sphere
  66249. */
  66250. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66251. /**
  66252. * Checks if two sphere intersct
  66253. * @param sphere0 sphere 0
  66254. * @param sphere1 sphere 1
  66255. * @returns true if the speres intersect
  66256. */
  66257. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66258. }
  66259. }
  66260. declare module BABYLON {
  66261. /**
  66262. * Class used to store bounding box information
  66263. */
  66264. export class BoundingBox implements ICullable {
  66265. /**
  66266. * Gets the 8 vectors representing the bounding box in local space
  66267. */
  66268. readonly vectors: Vector3[];
  66269. /**
  66270. * Gets the center of the bounding box in local space
  66271. */
  66272. readonly center: Vector3;
  66273. /**
  66274. * Gets the center of the bounding box in world space
  66275. */
  66276. readonly centerWorld: Vector3;
  66277. /**
  66278. * Gets the extend size in local space
  66279. */
  66280. readonly extendSize: Vector3;
  66281. /**
  66282. * Gets the extend size in world space
  66283. */
  66284. readonly extendSizeWorld: Vector3;
  66285. /**
  66286. * Gets the OBB (object bounding box) directions
  66287. */
  66288. readonly directions: Vector3[];
  66289. /**
  66290. * Gets the 8 vectors representing the bounding box in world space
  66291. */
  66292. readonly vectorsWorld: Vector3[];
  66293. /**
  66294. * Gets the minimum vector in world space
  66295. */
  66296. readonly minimumWorld: Vector3;
  66297. /**
  66298. * Gets the maximum vector in world space
  66299. */
  66300. readonly maximumWorld: Vector3;
  66301. /**
  66302. * Gets the minimum vector in local space
  66303. */
  66304. readonly minimum: Vector3;
  66305. /**
  66306. * Gets the maximum vector in local space
  66307. */
  66308. readonly maximum: Vector3;
  66309. private _worldMatrix;
  66310. private static readonly TmpVector3;
  66311. /**
  66312. * @hidden
  66313. */
  66314. _tag: number;
  66315. /**
  66316. * Creates a new bounding box
  66317. * @param min defines the minimum vector (in local space)
  66318. * @param max defines the maximum vector (in local space)
  66319. * @param worldMatrix defines the new world matrix
  66320. */
  66321. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66322. /**
  66323. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66324. * @param min defines the new minimum vector (in local space)
  66325. * @param max defines the new maximum vector (in local space)
  66326. * @param worldMatrix defines the new world matrix
  66327. */
  66328. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66329. /**
  66330. * Scale the current bounding box by applying a scale factor
  66331. * @param factor defines the scale factor to apply
  66332. * @returns the current bounding box
  66333. */
  66334. scale(factor: number): BoundingBox;
  66335. /**
  66336. * Gets the world matrix of the bounding box
  66337. * @returns a matrix
  66338. */
  66339. getWorldMatrix(): DeepImmutable<Matrix>;
  66340. /** @hidden */
  66341. _update(world: DeepImmutable<Matrix>): void;
  66342. /**
  66343. * Tests if the bounding box is intersecting the frustum planes
  66344. * @param frustumPlanes defines the frustum planes to test
  66345. * @returns true if there is an intersection
  66346. */
  66347. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66348. /**
  66349. * Tests if the bounding box is entirely inside the frustum planes
  66350. * @param frustumPlanes defines the frustum planes to test
  66351. * @returns true if there is an inclusion
  66352. */
  66353. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66354. /**
  66355. * Tests if a point is inside the bounding box
  66356. * @param point defines the point to test
  66357. * @returns true if the point is inside the bounding box
  66358. */
  66359. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66360. /**
  66361. * Tests if the bounding box intersects with a bounding sphere
  66362. * @param sphere defines the sphere to test
  66363. * @returns true if there is an intersection
  66364. */
  66365. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  66366. /**
  66367. * Tests if the bounding box intersects with a box defined by a min and max vectors
  66368. * @param min defines the min vector to use
  66369. * @param max defines the max vector to use
  66370. * @returns true if there is an intersection
  66371. */
  66372. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  66373. /**
  66374. * Tests if two bounding boxes are intersections
  66375. * @param box0 defines the first box to test
  66376. * @param box1 defines the second box to test
  66377. * @returns true if there is an intersection
  66378. */
  66379. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  66380. /**
  66381. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  66382. * @param minPoint defines the minimum vector of the bounding box
  66383. * @param maxPoint defines the maximum vector of the bounding box
  66384. * @param sphereCenter defines the sphere center
  66385. * @param sphereRadius defines the sphere radius
  66386. * @returns true if there is an intersection
  66387. */
  66388. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  66389. /**
  66390. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  66391. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66392. * @param frustumPlanes defines the frustum planes to test
  66393. * @return true if there is an inclusion
  66394. */
  66395. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66396. /**
  66397. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  66398. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66399. * @param frustumPlanes defines the frustum planes to test
  66400. * @return true if there is an intersection
  66401. */
  66402. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66403. }
  66404. }
  66405. declare module BABYLON {
  66406. /** @hidden */
  66407. export class Collider {
  66408. /** Define if a collision was found */
  66409. collisionFound: boolean;
  66410. /**
  66411. * Define last intersection point in local space
  66412. */
  66413. intersectionPoint: Vector3;
  66414. /**
  66415. * Define last collided mesh
  66416. */
  66417. collidedMesh: Nullable<AbstractMesh>;
  66418. private _collisionPoint;
  66419. private _planeIntersectionPoint;
  66420. private _tempVector;
  66421. private _tempVector2;
  66422. private _tempVector3;
  66423. private _tempVector4;
  66424. private _edge;
  66425. private _baseToVertex;
  66426. private _destinationPoint;
  66427. private _slidePlaneNormal;
  66428. private _displacementVector;
  66429. /** @hidden */
  66430. _radius: Vector3;
  66431. /** @hidden */
  66432. _retry: number;
  66433. private _velocity;
  66434. private _basePoint;
  66435. private _epsilon;
  66436. /** @hidden */
  66437. _velocityWorldLength: number;
  66438. /** @hidden */
  66439. _basePointWorld: Vector3;
  66440. private _velocityWorld;
  66441. private _normalizedVelocity;
  66442. /** @hidden */
  66443. _initialVelocity: Vector3;
  66444. /** @hidden */
  66445. _initialPosition: Vector3;
  66446. private _nearestDistance;
  66447. private _collisionMask;
  66448. collisionMask: number;
  66449. /**
  66450. * Gets the plane normal used to compute the sliding response (in local space)
  66451. */
  66452. readonly slidePlaneNormal: Vector3;
  66453. /** @hidden */
  66454. _initialize(source: Vector3, dir: Vector3, e: number): void;
  66455. /** @hidden */
  66456. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  66457. /** @hidden */
  66458. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  66459. /** @hidden */
  66460. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  66461. /** @hidden */
  66462. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  66463. /** @hidden */
  66464. _getResponse(pos: Vector3, vel: Vector3): void;
  66465. }
  66466. }
  66467. declare module BABYLON {
  66468. /**
  66469. * Interface for cullable objects
  66470. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  66471. */
  66472. export interface ICullable {
  66473. /**
  66474. * Checks if the object or part of the object is in the frustum
  66475. * @param frustumPlanes Camera near/planes
  66476. * @returns true if the object is in frustum otherwise false
  66477. */
  66478. isInFrustum(frustumPlanes: Plane[]): boolean;
  66479. /**
  66480. * Checks if a cullable object (mesh...) is in the camera frustum
  66481. * Unlike isInFrustum this cheks the full bounding box
  66482. * @param frustumPlanes Camera near/planes
  66483. * @returns true if the object is in frustum otherwise false
  66484. */
  66485. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  66486. }
  66487. /**
  66488. * Info for a bounding data of a mesh
  66489. */
  66490. export class BoundingInfo implements ICullable {
  66491. /**
  66492. * Bounding box for the mesh
  66493. */
  66494. readonly boundingBox: BoundingBox;
  66495. /**
  66496. * Bounding sphere for the mesh
  66497. */
  66498. readonly boundingSphere: BoundingSphere;
  66499. private _isLocked;
  66500. private static readonly TmpVector3;
  66501. /**
  66502. * Constructs bounding info
  66503. * @param minimum min vector of the bounding box/sphere
  66504. * @param maximum max vector of the bounding box/sphere
  66505. * @param worldMatrix defines the new world matrix
  66506. */
  66507. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66508. /**
  66509. * Recreates the entire bounding info from scratch as if we call the constructor in place
  66510. * @param min defines the new minimum vector (in local space)
  66511. * @param max defines the new maximum vector (in local space)
  66512. * @param worldMatrix defines the new world matrix
  66513. */
  66514. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66515. /**
  66516. * min vector of the bounding box/sphere
  66517. */
  66518. readonly minimum: Vector3;
  66519. /**
  66520. * max vector of the bounding box/sphere
  66521. */
  66522. readonly maximum: Vector3;
  66523. /**
  66524. * If the info is locked and won't be updated to avoid perf overhead
  66525. */
  66526. isLocked: boolean;
  66527. /**
  66528. * Updates the bounding sphere and box
  66529. * @param world world matrix to be used to update
  66530. */
  66531. update(world: DeepImmutable<Matrix>): void;
  66532. /**
  66533. * Recreate the bounding info to be centered around a specific point given a specific extend.
  66534. * @param center New center of the bounding info
  66535. * @param extend New extend of the bounding info
  66536. * @returns the current bounding info
  66537. */
  66538. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  66539. /**
  66540. * Scale the current bounding info by applying a scale factor
  66541. * @param factor defines the scale factor to apply
  66542. * @returns the current bounding info
  66543. */
  66544. scale(factor: number): BoundingInfo;
  66545. /**
  66546. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  66547. * @param frustumPlanes defines the frustum to test
  66548. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  66549. * @returns true if the bounding info is in the frustum planes
  66550. */
  66551. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  66552. /**
  66553. * Gets the world distance between the min and max points of the bounding box
  66554. */
  66555. readonly diagonalLength: number;
  66556. /**
  66557. * Checks if a cullable object (mesh...) is in the camera frustum
  66558. * Unlike isInFrustum this cheks the full bounding box
  66559. * @param frustumPlanes Camera near/planes
  66560. * @returns true if the object is in frustum otherwise false
  66561. */
  66562. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66563. /** @hidden */
  66564. _checkCollision(collider: Collider): boolean;
  66565. /**
  66566. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  66567. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66568. * @param point the point to check intersection with
  66569. * @returns if the point intersects
  66570. */
  66571. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66572. /**
  66573. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  66574. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66575. * @param boundingInfo the bounding info to check intersection with
  66576. * @param precise if the intersection should be done using OBB
  66577. * @returns if the bounding info intersects
  66578. */
  66579. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  66580. }
  66581. }
  66582. declare module BABYLON {
  66583. /**
  66584. * Defines an array and its length.
  66585. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  66586. */
  66587. export interface ISmartArrayLike<T> {
  66588. /**
  66589. * The data of the array.
  66590. */
  66591. data: Array<T>;
  66592. /**
  66593. * The active length of the array.
  66594. */
  66595. length: number;
  66596. }
  66597. /**
  66598. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66599. */
  66600. export class SmartArray<T> implements ISmartArrayLike<T> {
  66601. /**
  66602. * The full set of data from the array.
  66603. */
  66604. data: Array<T>;
  66605. /**
  66606. * The active length of the array.
  66607. */
  66608. length: number;
  66609. protected _id: number;
  66610. /**
  66611. * Instantiates a Smart Array.
  66612. * @param capacity defines the default capacity of the array.
  66613. */
  66614. constructor(capacity: number);
  66615. /**
  66616. * Pushes a value at the end of the active data.
  66617. * @param value defines the object to push in the array.
  66618. */
  66619. push(value: T): void;
  66620. /**
  66621. * Iterates over the active data and apply the lambda to them.
  66622. * @param func defines the action to apply on each value.
  66623. */
  66624. forEach(func: (content: T) => void): void;
  66625. /**
  66626. * Sorts the full sets of data.
  66627. * @param compareFn defines the comparison function to apply.
  66628. */
  66629. sort(compareFn: (a: T, b: T) => number): void;
  66630. /**
  66631. * Resets the active data to an empty array.
  66632. */
  66633. reset(): void;
  66634. /**
  66635. * Releases all the data from the array as well as the array.
  66636. */
  66637. dispose(): void;
  66638. /**
  66639. * Concats the active data with a given array.
  66640. * @param array defines the data to concatenate with.
  66641. */
  66642. concat(array: any): void;
  66643. /**
  66644. * Returns the position of a value in the active data.
  66645. * @param value defines the value to find the index for
  66646. * @returns the index if found in the active data otherwise -1
  66647. */
  66648. indexOf(value: T): number;
  66649. /**
  66650. * Returns whether an element is part of the active data.
  66651. * @param value defines the value to look for
  66652. * @returns true if found in the active data otherwise false
  66653. */
  66654. contains(value: T): boolean;
  66655. private static _GlobalId;
  66656. }
  66657. /**
  66658. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66659. * The data in this array can only be present once
  66660. */
  66661. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  66662. private _duplicateId;
  66663. /**
  66664. * Pushes a value at the end of the active data.
  66665. * THIS DOES NOT PREVENT DUPPLICATE DATA
  66666. * @param value defines the object to push in the array.
  66667. */
  66668. push(value: T): void;
  66669. /**
  66670. * Pushes a value at the end of the active data.
  66671. * If the data is already present, it won t be added again
  66672. * @param value defines the object to push in the array.
  66673. * @returns true if added false if it was already present
  66674. */
  66675. pushNoDuplicate(value: T): boolean;
  66676. /**
  66677. * Resets the active data to an empty array.
  66678. */
  66679. reset(): void;
  66680. /**
  66681. * Concats the active data with a given array.
  66682. * This ensures no dupplicate will be present in the result.
  66683. * @param array defines the data to concatenate with.
  66684. */
  66685. concatWithNoDuplicate(array: any): void;
  66686. }
  66687. }
  66688. declare module BABYLON {
  66689. /**
  66690. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66691. * separate meshes. This can be use to improve performances.
  66692. * @see http://doc.babylonjs.com/how_to/multi_materials
  66693. */
  66694. export class MultiMaterial extends Material {
  66695. private _subMaterials;
  66696. /**
  66697. * Gets or Sets the list of Materials used within the multi material.
  66698. * They need to be ordered according to the submeshes order in the associated mesh
  66699. */
  66700. subMaterials: Nullable<Material>[];
  66701. /**
  66702. * Function used to align with Node.getChildren()
  66703. * @returns the list of Materials used within the multi material
  66704. */
  66705. getChildren(): Nullable<Material>[];
  66706. /**
  66707. * Instantiates a new Multi Material
  66708. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66709. * separate meshes. This can be use to improve performances.
  66710. * @see http://doc.babylonjs.com/how_to/multi_materials
  66711. * @param name Define the name in the scene
  66712. * @param scene Define the scene the material belongs to
  66713. */
  66714. constructor(name: string, scene: Scene);
  66715. private _hookArray;
  66716. /**
  66717. * Get one of the submaterial by its index in the submaterials array
  66718. * @param index The index to look the sub material at
  66719. * @returns The Material if the index has been defined
  66720. */
  66721. getSubMaterial(index: number): Nullable<Material>;
  66722. /**
  66723. * Get the list of active textures for the whole sub materials list.
  66724. * @returns All the textures that will be used during the rendering
  66725. */
  66726. getActiveTextures(): BaseTexture[];
  66727. /**
  66728. * Gets the current class name of the material e.g. "MultiMaterial"
  66729. * Mainly use in serialization.
  66730. * @returns the class name
  66731. */
  66732. getClassName(): string;
  66733. /**
  66734. * Checks if the material is ready to render the requested sub mesh
  66735. * @param mesh Define the mesh the submesh belongs to
  66736. * @param subMesh Define the sub mesh to look readyness for
  66737. * @param useInstances Define whether or not the material is used with instances
  66738. * @returns true if ready, otherwise false
  66739. */
  66740. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  66741. /**
  66742. * Clones the current material and its related sub materials
  66743. * @param name Define the name of the newly cloned material
  66744. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  66745. * @returns the cloned material
  66746. */
  66747. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  66748. /**
  66749. * Serializes the materials into a JSON representation.
  66750. * @returns the JSON representation
  66751. */
  66752. serialize(): any;
  66753. /**
  66754. * Dispose the material and release its associated resources
  66755. * @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)
  66756. * @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)
  66757. * @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)
  66758. */
  66759. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  66760. /**
  66761. * Creates a MultiMaterial from parsed MultiMaterial data.
  66762. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  66763. * @param scene defines the hosting scene
  66764. * @returns a new MultiMaterial
  66765. */
  66766. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  66767. }
  66768. }
  66769. declare module BABYLON {
  66770. /**
  66771. * Class used to represent data loading progression
  66772. */
  66773. export class SceneLoaderFlags {
  66774. private static _ForceFullSceneLoadingForIncremental;
  66775. private static _ShowLoadingScreen;
  66776. private static _CleanBoneMatrixWeights;
  66777. private static _loggingLevel;
  66778. /**
  66779. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  66780. */
  66781. static ForceFullSceneLoadingForIncremental: boolean;
  66782. /**
  66783. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  66784. */
  66785. static ShowLoadingScreen: boolean;
  66786. /**
  66787. * Defines the current logging level (while loading the scene)
  66788. * @ignorenaming
  66789. */
  66790. static loggingLevel: number;
  66791. /**
  66792. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  66793. */
  66794. static CleanBoneMatrixWeights: boolean;
  66795. }
  66796. }
  66797. declare module BABYLON {
  66798. /**
  66799. * 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.
  66800. * @see https://doc.babylonjs.com/how_to/transformnode
  66801. */
  66802. export class TransformNode extends Node {
  66803. /**
  66804. * Object will not rotate to face the camera
  66805. */
  66806. static BILLBOARDMODE_NONE: number;
  66807. /**
  66808. * Object will rotate to face the camera but only on the x axis
  66809. */
  66810. static BILLBOARDMODE_X: number;
  66811. /**
  66812. * Object will rotate to face the camera but only on the y axis
  66813. */
  66814. static BILLBOARDMODE_Y: number;
  66815. /**
  66816. * Object will rotate to face the camera but only on the z axis
  66817. */
  66818. static BILLBOARDMODE_Z: number;
  66819. /**
  66820. * Object will rotate to face the camera
  66821. */
  66822. static BILLBOARDMODE_ALL: number;
  66823. private _forward;
  66824. private _forwardInverted;
  66825. private _up;
  66826. private _right;
  66827. private _rightInverted;
  66828. private _position;
  66829. private _rotation;
  66830. private _rotationQuaternion;
  66831. protected _scaling: Vector3;
  66832. protected _isDirty: boolean;
  66833. private _transformToBoneReferal;
  66834. /**
  66835. * Set the billboard mode. Default is 0.
  66836. *
  66837. * | Value | Type | Description |
  66838. * | --- | --- | --- |
  66839. * | 0 | BILLBOARDMODE_NONE | |
  66840. * | 1 | BILLBOARDMODE_X | |
  66841. * | 2 | BILLBOARDMODE_Y | |
  66842. * | 4 | BILLBOARDMODE_Z | |
  66843. * | 7 | BILLBOARDMODE_ALL | |
  66844. *
  66845. */
  66846. billboardMode: number;
  66847. /**
  66848. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  66849. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  66850. */
  66851. preserveParentRotationForBillboard: boolean;
  66852. /**
  66853. * 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
  66854. */
  66855. scalingDeterminant: number;
  66856. /**
  66857. * Sets the distance of the object to max, often used by skybox
  66858. */
  66859. infiniteDistance: boolean;
  66860. /**
  66861. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  66862. * By default the system will update normals to compensate
  66863. */
  66864. ignoreNonUniformScaling: boolean;
  66865. /** @hidden */
  66866. _poseMatrix: Matrix;
  66867. /** @hidden */
  66868. _localMatrix: Matrix;
  66869. private _absolutePosition;
  66870. private _pivotMatrix;
  66871. private _pivotMatrixInverse;
  66872. protected _postMultiplyPivotMatrix: boolean;
  66873. private _tempMatrix;
  66874. private _tempMatrix2;
  66875. protected _isWorldMatrixFrozen: boolean;
  66876. /** @hidden */
  66877. _indexInSceneTransformNodesArray: number;
  66878. /**
  66879. * An event triggered after the world matrix is updated
  66880. */
  66881. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  66882. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  66883. /**
  66884. * Gets a string identifying the name of the class
  66885. * @returns "TransformNode" string
  66886. */
  66887. getClassName(): string;
  66888. /**
  66889. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  66890. */
  66891. position: Vector3;
  66892. /**
  66893. * 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)).
  66894. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  66895. */
  66896. rotation: Vector3;
  66897. /**
  66898. * 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)).
  66899. */
  66900. scaling: Vector3;
  66901. /**
  66902. * 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).
  66903. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  66904. */
  66905. rotationQuaternion: Nullable<Quaternion>;
  66906. /**
  66907. * The forward direction of that transform in world space.
  66908. */
  66909. readonly forward: Vector3;
  66910. /**
  66911. * The up direction of that transform in world space.
  66912. */
  66913. readonly up: Vector3;
  66914. /**
  66915. * The right direction of that transform in world space.
  66916. */
  66917. readonly right: Vector3;
  66918. /**
  66919. * Copies the parameter passed Matrix into the mesh Pose matrix.
  66920. * @param matrix the matrix to copy the pose from
  66921. * @returns this TransformNode.
  66922. */
  66923. updatePoseMatrix(matrix: Matrix): TransformNode;
  66924. /**
  66925. * Returns the mesh Pose matrix.
  66926. * @returns the pose matrix
  66927. */
  66928. getPoseMatrix(): Matrix;
  66929. /** @hidden */
  66930. _isSynchronized(): boolean;
  66931. /** @hidden */
  66932. _initCache(): void;
  66933. /**
  66934. * Flag the transform node as dirty (Forcing it to update everything)
  66935. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  66936. * @returns this transform node
  66937. */
  66938. markAsDirty(property: string): TransformNode;
  66939. /**
  66940. * Returns the current mesh absolute position.
  66941. * Returns a Vector3.
  66942. */
  66943. readonly absolutePosition: Vector3;
  66944. /**
  66945. * Sets a new matrix to apply before all other transformation
  66946. * @param matrix defines the transform matrix
  66947. * @returns the current TransformNode
  66948. */
  66949. setPreTransformMatrix(matrix: Matrix): TransformNode;
  66950. /**
  66951. * Sets a new pivot matrix to the current node
  66952. * @param matrix defines the new pivot matrix to use
  66953. * @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
  66954. * @returns the current TransformNode
  66955. */
  66956. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  66957. /**
  66958. * Returns the mesh pivot matrix.
  66959. * Default : Identity.
  66960. * @returns the matrix
  66961. */
  66962. getPivotMatrix(): Matrix;
  66963. /**
  66964. * Prevents the World matrix to be computed any longer.
  66965. * @returns the TransformNode.
  66966. */
  66967. freezeWorldMatrix(): TransformNode;
  66968. /**
  66969. * Allows back the World matrix computation.
  66970. * @returns the TransformNode.
  66971. */
  66972. unfreezeWorldMatrix(): this;
  66973. /**
  66974. * True if the World matrix has been frozen.
  66975. */
  66976. readonly isWorldMatrixFrozen: boolean;
  66977. /**
  66978. * Retuns the mesh absolute position in the World.
  66979. * @returns a Vector3.
  66980. */
  66981. getAbsolutePosition(): Vector3;
  66982. /**
  66983. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  66984. * @param absolutePosition the absolute position to set
  66985. * @returns the TransformNode.
  66986. */
  66987. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  66988. /**
  66989. * Sets the mesh position in its local space.
  66990. * @param vector3 the position to set in localspace
  66991. * @returns the TransformNode.
  66992. */
  66993. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  66994. /**
  66995. * Returns the mesh position in the local space from the current World matrix values.
  66996. * @returns a new Vector3.
  66997. */
  66998. getPositionExpressedInLocalSpace(): Vector3;
  66999. /**
  67000. * Translates the mesh along the passed Vector3 in its local space.
  67001. * @param vector3 the distance to translate in localspace
  67002. * @returns the TransformNode.
  67003. */
  67004. locallyTranslate(vector3: Vector3): TransformNode;
  67005. private static _lookAtVectorCache;
  67006. /**
  67007. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67008. * @param targetPoint the position (must be in same space as current mesh) to look at
  67009. * @param yawCor optional yaw (y-axis) correction in radians
  67010. * @param pitchCor optional pitch (x-axis) correction in radians
  67011. * @param rollCor optional roll (z-axis) correction in radians
  67012. * @param space the choosen space of the target
  67013. * @returns the TransformNode.
  67014. */
  67015. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67016. /**
  67017. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67018. * This Vector3 is expressed in the World space.
  67019. * @param localAxis axis to rotate
  67020. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67021. */
  67022. getDirection(localAxis: Vector3): Vector3;
  67023. /**
  67024. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67025. * localAxis is expressed in the mesh local space.
  67026. * result is computed in the Wordl space from the mesh World matrix.
  67027. * @param localAxis axis to rotate
  67028. * @param result the resulting transformnode
  67029. * @returns this TransformNode.
  67030. */
  67031. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67032. /**
  67033. * Sets this transform node rotation to the given local axis.
  67034. * @param localAxis the axis in local space
  67035. * @param yawCor optional yaw (y-axis) correction in radians
  67036. * @param pitchCor optional pitch (x-axis) correction in radians
  67037. * @param rollCor optional roll (z-axis) correction in radians
  67038. * @returns this TransformNode
  67039. */
  67040. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67041. /**
  67042. * Sets a new pivot point to the current node
  67043. * @param point defines the new pivot point to use
  67044. * @param space defines if the point is in world or local space (local by default)
  67045. * @returns the current TransformNode
  67046. */
  67047. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67048. /**
  67049. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67050. * @returns the pivot point
  67051. */
  67052. getPivotPoint(): Vector3;
  67053. /**
  67054. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67055. * @param result the vector3 to store the result
  67056. * @returns this TransformNode.
  67057. */
  67058. getPivotPointToRef(result: Vector3): TransformNode;
  67059. /**
  67060. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67061. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67062. */
  67063. getAbsolutePivotPoint(): Vector3;
  67064. /**
  67065. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67066. * @param result vector3 to store the result
  67067. * @returns this TransformNode.
  67068. */
  67069. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67070. /**
  67071. * Defines the passed node as the parent of the current node.
  67072. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67073. * @see https://doc.babylonjs.com/how_to/parenting
  67074. * @param node the node ot set as the parent
  67075. * @returns this TransformNode.
  67076. */
  67077. setParent(node: Nullable<Node>): TransformNode;
  67078. private _nonUniformScaling;
  67079. /**
  67080. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67081. */
  67082. readonly nonUniformScaling: boolean;
  67083. /** @hidden */
  67084. _updateNonUniformScalingState(value: boolean): boolean;
  67085. /**
  67086. * Attach the current TransformNode to another TransformNode associated with a bone
  67087. * @param bone Bone affecting the TransformNode
  67088. * @param affectedTransformNode TransformNode associated with the bone
  67089. * @returns this object
  67090. */
  67091. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67092. /**
  67093. * Detach the transform node if its associated with a bone
  67094. * @returns this object
  67095. */
  67096. detachFromBone(): TransformNode;
  67097. private static _rotationAxisCache;
  67098. /**
  67099. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67100. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67101. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67102. * The passed axis is also normalized.
  67103. * @param axis the axis to rotate around
  67104. * @param amount the amount to rotate in radians
  67105. * @param space Space to rotate in (Default: local)
  67106. * @returns the TransformNode.
  67107. */
  67108. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67109. /**
  67110. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67111. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67112. * The passed axis is also normalized. .
  67113. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67114. * @param point the point to rotate around
  67115. * @param axis the axis to rotate around
  67116. * @param amount the amount to rotate in radians
  67117. * @returns the TransformNode
  67118. */
  67119. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67120. /**
  67121. * Translates the mesh along the axis vector for the passed distance in the given space.
  67122. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67123. * @param axis the axis to translate in
  67124. * @param distance the distance to translate
  67125. * @param space Space to rotate in (Default: local)
  67126. * @returns the TransformNode.
  67127. */
  67128. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67129. /**
  67130. * Adds a rotation step to the mesh current rotation.
  67131. * x, y, z are Euler angles expressed in radians.
  67132. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67133. * This means this rotation is made in the mesh local space only.
  67134. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67135. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67136. * ```javascript
  67137. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67138. * ```
  67139. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67140. * 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.
  67141. * @param x Rotation to add
  67142. * @param y Rotation to add
  67143. * @param z Rotation to add
  67144. * @returns the TransformNode.
  67145. */
  67146. addRotation(x: number, y: number, z: number): TransformNode;
  67147. /**
  67148. * @hidden
  67149. */
  67150. protected _getEffectiveParent(): Nullable<Node>;
  67151. /**
  67152. * Computes the world matrix of the node
  67153. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67154. * @returns the world matrix
  67155. */
  67156. computeWorldMatrix(force?: boolean): Matrix;
  67157. protected _afterComputeWorldMatrix(): void;
  67158. /**
  67159. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67160. * @param func callback function to add
  67161. *
  67162. * @returns the TransformNode.
  67163. */
  67164. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67165. /**
  67166. * Removes a registered callback function.
  67167. * @param func callback function to remove
  67168. * @returns the TransformNode.
  67169. */
  67170. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67171. /**
  67172. * Gets the position of the current mesh in camera space
  67173. * @param camera defines the camera to use
  67174. * @returns a position
  67175. */
  67176. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67177. /**
  67178. * Returns the distance from the mesh to the active camera
  67179. * @param camera defines the camera to use
  67180. * @returns the distance
  67181. */
  67182. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67183. /**
  67184. * Clone the current transform node
  67185. * @param name Name of the new clone
  67186. * @param newParent New parent for the clone
  67187. * @param doNotCloneChildren Do not clone children hierarchy
  67188. * @returns the new transform node
  67189. */
  67190. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67191. /**
  67192. * Serializes the objects information.
  67193. * @param currentSerializationObject defines the object to serialize in
  67194. * @returns the serialized object
  67195. */
  67196. serialize(currentSerializationObject?: any): any;
  67197. /**
  67198. * Returns a new TransformNode object parsed from the source provided.
  67199. * @param parsedTransformNode is the source.
  67200. * @param scene the scne the object belongs to
  67201. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67202. * @returns a new TransformNode object parsed from the source provided.
  67203. */
  67204. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67205. /**
  67206. * Get all child-transformNodes of this node
  67207. * @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
  67208. * @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
  67209. * @returns an array of TransformNode
  67210. */
  67211. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67212. /**
  67213. * Releases resources associated with this transform node.
  67214. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67215. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67216. */
  67217. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67218. }
  67219. }
  67220. declare module BABYLON {
  67221. /**
  67222. * Class used to override all child animations of a given target
  67223. */
  67224. export class AnimationPropertiesOverride {
  67225. /**
  67226. * Gets or sets a value indicating if animation blending must be used
  67227. */
  67228. enableBlending: boolean;
  67229. /**
  67230. * Gets or sets the blending speed to use when enableBlending is true
  67231. */
  67232. blendingSpeed: number;
  67233. /**
  67234. * Gets or sets the default loop mode to use
  67235. */
  67236. loopMode: number;
  67237. }
  67238. }
  67239. declare module BABYLON {
  67240. /**
  67241. * Class used to store bone information
  67242. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67243. */
  67244. export class Bone extends Node {
  67245. /**
  67246. * defines the bone name
  67247. */
  67248. name: string;
  67249. private static _tmpVecs;
  67250. private static _tmpQuat;
  67251. private static _tmpMats;
  67252. /**
  67253. * Gets the list of child bones
  67254. */
  67255. children: Bone[];
  67256. /** Gets the animations associated with this bone */
  67257. animations: Animation[];
  67258. /**
  67259. * Gets or sets bone length
  67260. */
  67261. length: number;
  67262. /**
  67263. * @hidden Internal only
  67264. * Set this value to map this bone to a different index in the transform matrices
  67265. * Set this value to -1 to exclude the bone from the transform matrices
  67266. */
  67267. _index: Nullable<number>;
  67268. private _skeleton;
  67269. private _localMatrix;
  67270. private _restPose;
  67271. private _baseMatrix;
  67272. private _absoluteTransform;
  67273. private _invertedAbsoluteTransform;
  67274. private _parent;
  67275. private _scalingDeterminant;
  67276. private _worldTransform;
  67277. private _localScaling;
  67278. private _localRotation;
  67279. private _localPosition;
  67280. private _needToDecompose;
  67281. private _needToCompose;
  67282. /** @hidden */
  67283. _linkedTransformNode: Nullable<TransformNode>;
  67284. /** @hidden */
  67285. /** @hidden */
  67286. _matrix: Matrix;
  67287. /**
  67288. * Create a new bone
  67289. * @param name defines the bone name
  67290. * @param skeleton defines the parent skeleton
  67291. * @param parentBone defines the parent (can be null if the bone is the root)
  67292. * @param localMatrix defines the local matrix
  67293. * @param restPose defines the rest pose matrix
  67294. * @param baseMatrix defines the base matrix
  67295. * @param index defines index of the bone in the hiearchy
  67296. */
  67297. constructor(
  67298. /**
  67299. * defines the bone name
  67300. */
  67301. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67302. /**
  67303. * Gets the current object class name.
  67304. * @return the class name
  67305. */
  67306. getClassName(): string;
  67307. /**
  67308. * Gets the parent skeleton
  67309. * @returns a skeleton
  67310. */
  67311. getSkeleton(): Skeleton;
  67312. /**
  67313. * Gets parent bone
  67314. * @returns a bone or null if the bone is the root of the bone hierarchy
  67315. */
  67316. getParent(): Nullable<Bone>;
  67317. /**
  67318. * Returns an array containing the root bones
  67319. * @returns an array containing the root bones
  67320. */
  67321. getChildren(): Array<Bone>;
  67322. /**
  67323. * Sets the parent bone
  67324. * @param parent defines the parent (can be null if the bone is the root)
  67325. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67326. */
  67327. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67328. /**
  67329. * Gets the local matrix
  67330. * @returns a matrix
  67331. */
  67332. getLocalMatrix(): Matrix;
  67333. /**
  67334. * Gets the base matrix (initial matrix which remains unchanged)
  67335. * @returns a matrix
  67336. */
  67337. getBaseMatrix(): Matrix;
  67338. /**
  67339. * Gets the rest pose matrix
  67340. * @returns a matrix
  67341. */
  67342. getRestPose(): Matrix;
  67343. /**
  67344. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67345. */
  67346. getWorldMatrix(): Matrix;
  67347. /**
  67348. * Sets the local matrix to rest pose matrix
  67349. */
  67350. returnToRest(): void;
  67351. /**
  67352. * Gets the inverse of the absolute transform matrix.
  67353. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67354. * @returns a matrix
  67355. */
  67356. getInvertedAbsoluteTransform(): Matrix;
  67357. /**
  67358. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67359. * @returns a matrix
  67360. */
  67361. getAbsoluteTransform(): Matrix;
  67362. /**
  67363. * Links with the given transform node.
  67364. * The local matrix of this bone is copied from the transform node every frame.
  67365. * @param transformNode defines the transform node to link to
  67366. */
  67367. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  67368. /** Gets or sets current position (in local space) */
  67369. position: Vector3;
  67370. /** Gets or sets current rotation (in local space) */
  67371. rotation: Vector3;
  67372. /** Gets or sets current rotation quaternion (in local space) */
  67373. rotationQuaternion: Quaternion;
  67374. /** Gets or sets current scaling (in local space) */
  67375. scaling: Vector3;
  67376. /**
  67377. * Gets the animation properties override
  67378. */
  67379. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  67380. private _decompose;
  67381. private _compose;
  67382. /**
  67383. * Update the base and local matrices
  67384. * @param matrix defines the new base or local matrix
  67385. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67386. * @param updateLocalMatrix defines if the local matrix should be updated
  67387. */
  67388. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  67389. /** @hidden */
  67390. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  67391. /**
  67392. * Flag the bone as dirty (Forcing it to update everything)
  67393. */
  67394. markAsDirty(): void;
  67395. private _markAsDirtyAndCompose;
  67396. private _markAsDirtyAndDecompose;
  67397. /**
  67398. * Translate the bone in local or world space
  67399. * @param vec The amount to translate the bone
  67400. * @param space The space that the translation is in
  67401. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67402. */
  67403. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67404. /**
  67405. * Set the postion of the bone in local or world space
  67406. * @param position The position to set the bone
  67407. * @param space The space that the position is in
  67408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67409. */
  67410. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67411. /**
  67412. * Set the absolute position of the bone (world space)
  67413. * @param position The position to set the bone
  67414. * @param mesh The mesh that this bone is attached to
  67415. */
  67416. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  67417. /**
  67418. * Scale the bone on the x, y and z axes (in local space)
  67419. * @param x The amount to scale the bone on the x axis
  67420. * @param y The amount to scale the bone on the y axis
  67421. * @param z The amount to scale the bone on the z axis
  67422. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  67423. */
  67424. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  67425. /**
  67426. * Set the bone scaling in local space
  67427. * @param scale defines the scaling vector
  67428. */
  67429. setScale(scale: Vector3): void;
  67430. /**
  67431. * Gets the current scaling in local space
  67432. * @returns the current scaling vector
  67433. */
  67434. getScale(): Vector3;
  67435. /**
  67436. * Gets the current scaling in local space and stores it in a target vector
  67437. * @param result defines the target vector
  67438. */
  67439. getScaleToRef(result: Vector3): void;
  67440. /**
  67441. * Set the yaw, pitch, and roll of the bone in local or world space
  67442. * @param yaw The rotation of the bone on the y axis
  67443. * @param pitch The rotation of the bone on the x axis
  67444. * @param roll The rotation of the bone on the z axis
  67445. * @param space The space that the axes of rotation are in
  67446. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67447. */
  67448. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  67449. /**
  67450. * Add a rotation to the bone on an axis in local or world space
  67451. * @param axis The axis to rotate the bone on
  67452. * @param amount The amount to rotate the bone
  67453. * @param space The space that the axis is in
  67454. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67455. */
  67456. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  67457. /**
  67458. * Set the rotation of the bone to a particular axis angle in local or world space
  67459. * @param axis The axis to rotate the bone on
  67460. * @param angle The angle that the bone should be rotated to
  67461. * @param space The space that the axis is in
  67462. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67463. */
  67464. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  67465. /**
  67466. * Set the euler rotation of the bone in local of world space
  67467. * @param rotation The euler rotation that the bone should be set to
  67468. * @param space The space that the rotation is in
  67469. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67470. */
  67471. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67472. /**
  67473. * Set the quaternion rotation of the bone in local of world space
  67474. * @param quat The quaternion rotation that the bone should be set to
  67475. * @param space The space that the rotation is in
  67476. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67477. */
  67478. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  67479. /**
  67480. * Set the rotation matrix of the bone in local of world space
  67481. * @param rotMat The rotation matrix that the bone should be set to
  67482. * @param space The space that the rotation is in
  67483. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67484. */
  67485. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  67486. private _rotateWithMatrix;
  67487. private _getNegativeRotationToRef;
  67488. /**
  67489. * Get the position of the bone in local or world space
  67490. * @param space The space that the returned position is in
  67491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67492. * @returns The position of the bone
  67493. */
  67494. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67495. /**
  67496. * Copy the position of the bone to a vector3 in local or world space
  67497. * @param space The space that the returned position is in
  67498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67499. * @param result The vector3 to copy the position to
  67500. */
  67501. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  67502. /**
  67503. * Get the absolute position of the bone (world space)
  67504. * @param mesh The mesh that this bone is attached to
  67505. * @returns The absolute position of the bone
  67506. */
  67507. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  67508. /**
  67509. * Copy the absolute position of the bone (world space) to the result param
  67510. * @param mesh The mesh that this bone is attached to
  67511. * @param result The vector3 to copy the absolute position to
  67512. */
  67513. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  67514. /**
  67515. * Compute the absolute transforms of this bone and its children
  67516. */
  67517. computeAbsoluteTransforms(): void;
  67518. /**
  67519. * Get the world direction from an axis that is in the local space of the bone
  67520. * @param localAxis The local direction that is used to compute the world direction
  67521. * @param mesh The mesh that this bone is attached to
  67522. * @returns The world direction
  67523. */
  67524. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67525. /**
  67526. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  67527. * @param localAxis The local direction that is used to compute the world direction
  67528. * @param mesh The mesh that this bone is attached to
  67529. * @param result The vector3 that the world direction will be copied to
  67530. */
  67531. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67532. /**
  67533. * Get the euler rotation of the bone in local or world space
  67534. * @param space The space that the rotation should be in
  67535. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67536. * @returns The euler rotation
  67537. */
  67538. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67539. /**
  67540. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  67541. * @param space The space that the rotation should be in
  67542. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67543. * @param result The vector3 that the rotation should be copied to
  67544. */
  67545. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67546. /**
  67547. * Get the quaternion rotation of the bone in either local or world space
  67548. * @param space The space that the rotation should be in
  67549. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67550. * @returns The quaternion rotation
  67551. */
  67552. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  67553. /**
  67554. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  67555. * @param space The space that the rotation should be in
  67556. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67557. * @param result The quaternion that the rotation should be copied to
  67558. */
  67559. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  67560. /**
  67561. * Get the rotation matrix of the bone in local or world space
  67562. * @param space The space that the rotation should be in
  67563. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67564. * @returns The rotation matrix
  67565. */
  67566. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  67567. /**
  67568. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  67569. * @param space The space that the rotation should be in
  67570. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67571. * @param result The quaternion that the rotation should be copied to
  67572. */
  67573. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  67574. /**
  67575. * Get the world position of a point that is in the local space of the bone
  67576. * @param position The local position
  67577. * @param mesh The mesh that this bone is attached to
  67578. * @returns The world position
  67579. */
  67580. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67581. /**
  67582. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  67583. * @param position The local position
  67584. * @param mesh The mesh that this bone is attached to
  67585. * @param result The vector3 that the world position should be copied to
  67586. */
  67587. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67588. /**
  67589. * Get the local position of a point that is in world space
  67590. * @param position The world position
  67591. * @param mesh The mesh that this bone is attached to
  67592. * @returns The local position
  67593. */
  67594. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67595. /**
  67596. * Get the local position of a point that is in world space and copy it to the result param
  67597. * @param position The world position
  67598. * @param mesh The mesh that this bone is attached to
  67599. * @param result The vector3 that the local position should be copied to
  67600. */
  67601. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67602. }
  67603. }
  67604. declare module BABYLON {
  67605. /**
  67606. * Enum that determines the text-wrapping mode to use.
  67607. */
  67608. export enum InspectableType {
  67609. /**
  67610. * Checkbox for booleans
  67611. */
  67612. Checkbox = 0,
  67613. /**
  67614. * Sliders for numbers
  67615. */
  67616. Slider = 1,
  67617. /**
  67618. * Vector3
  67619. */
  67620. Vector3 = 2,
  67621. /**
  67622. * Quaternions
  67623. */
  67624. Quaternion = 3,
  67625. /**
  67626. * Color3
  67627. */
  67628. Color3 = 4
  67629. }
  67630. /**
  67631. * Interface used to define custom inspectable properties.
  67632. * This interface is used by the inspector to display custom property grids
  67633. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67634. */
  67635. export interface IInspectable {
  67636. /**
  67637. * Gets the label to display
  67638. */
  67639. label: string;
  67640. /**
  67641. * Gets the name of the property to edit
  67642. */
  67643. propertyName: string;
  67644. /**
  67645. * Gets the type of the editor to use
  67646. */
  67647. type: InspectableType;
  67648. /**
  67649. * Gets the minimum value of the property when using in "slider" mode
  67650. */
  67651. min?: number;
  67652. /**
  67653. * Gets the maximum value of the property when using in "slider" mode
  67654. */
  67655. max?: number;
  67656. /**
  67657. * Gets the setp to use when using in "slider" mode
  67658. */
  67659. step?: number;
  67660. }
  67661. }
  67662. declare module BABYLON {
  67663. /**
  67664. * Class for creating a cube texture
  67665. */
  67666. export class CubeTexture extends BaseTexture {
  67667. private _delayedOnLoad;
  67668. /**
  67669. * The url of the texture
  67670. */
  67671. url: string;
  67672. /**
  67673. * Gets or sets the center of the bounding box associated with the cube texture.
  67674. * It must define where the camera used to render the texture was set
  67675. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67676. */
  67677. boundingBoxPosition: Vector3;
  67678. private _boundingBoxSize;
  67679. /**
  67680. * Gets or sets the size of the bounding box associated with the cube texture
  67681. * When defined, the cubemap will switch to local mode
  67682. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  67683. * @example https://www.babylonjs-playground.com/#RNASML
  67684. */
  67685. /**
  67686. * Returns the bounding box size
  67687. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67688. */
  67689. boundingBoxSize: Vector3;
  67690. protected _rotationY: number;
  67691. /**
  67692. * Sets texture matrix rotation angle around Y axis in radians.
  67693. */
  67694. /**
  67695. * Gets texture matrix rotation angle around Y axis radians.
  67696. */
  67697. rotationY: number;
  67698. /**
  67699. * Are mip maps generated for this texture or not.
  67700. */
  67701. readonly noMipmap: boolean;
  67702. private _noMipmap;
  67703. private _files;
  67704. private _extensions;
  67705. private _textureMatrix;
  67706. private _format;
  67707. private _createPolynomials;
  67708. /** @hidden */
  67709. _prefiltered: boolean;
  67710. /**
  67711. * Creates a cube texture from an array of image urls
  67712. * @param files defines an array of image urls
  67713. * @param scene defines the hosting scene
  67714. * @param noMipmap specifies if mip maps are not used
  67715. * @returns a cube texture
  67716. */
  67717. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  67718. /**
  67719. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  67720. * @param url defines the url of the prefiltered texture
  67721. * @param scene defines the scene the texture is attached to
  67722. * @param forcedExtension defines the extension of the file if different from the url
  67723. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67724. * @return the prefiltered texture
  67725. */
  67726. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  67727. /**
  67728. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  67729. * as prefiltered data.
  67730. * @param rootUrl defines the url of the texture or the root name of the six images
  67731. * @param scene defines the scene the texture is attached to
  67732. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  67733. * @param noMipmap defines if mipmaps should be created or not
  67734. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  67735. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  67736. * @param onError defines a callback triggered in case of error during load
  67737. * @param format defines the internal format to use for the texture once loaded
  67738. * @param prefiltered defines whether or not the texture is created from prefiltered data
  67739. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  67740. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67741. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67742. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67743. * @return the cube texture
  67744. */
  67745. 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);
  67746. /**
  67747. * Get the current class name of the texture useful for serialization or dynamic coding.
  67748. * @returns "CubeTexture"
  67749. */
  67750. getClassName(): string;
  67751. /**
  67752. * Update the url (and optional buffer) of this texture if url was null during construction.
  67753. * @param url the url of the texture
  67754. * @param forcedExtension defines the extension to use
  67755. * @param onLoad callback called when the texture is loaded (defaults to null)
  67756. */
  67757. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  67758. /**
  67759. * Delays loading of the cube texture
  67760. * @param forcedExtension defines the extension to use
  67761. */
  67762. delayLoad(forcedExtension?: string): void;
  67763. /**
  67764. * Returns the reflection texture matrix
  67765. * @returns the reflection texture matrix
  67766. */
  67767. getReflectionTextureMatrix(): Matrix;
  67768. /**
  67769. * Sets the reflection texture matrix
  67770. * @param value Reflection texture matrix
  67771. */
  67772. setReflectionTextureMatrix(value: Matrix): void;
  67773. /**
  67774. * Parses text to create a cube texture
  67775. * @param parsedTexture define the serialized text to read from
  67776. * @param scene defines the hosting scene
  67777. * @param rootUrl defines the root url of the cube texture
  67778. * @returns a cube texture
  67779. */
  67780. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  67781. /**
  67782. * Makes a clone, or deep copy, of the cube texture
  67783. * @returns a new cube texture
  67784. */
  67785. clone(): CubeTexture;
  67786. }
  67787. }
  67788. declare module BABYLON {
  67789. /** @hidden */
  67790. export var postprocessVertexShader: {
  67791. name: string;
  67792. shader: string;
  67793. };
  67794. }
  67795. declare module BABYLON {
  67796. /**
  67797. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  67798. * This is the base of the follow, arc rotate cameras and Free camera
  67799. * @see http://doc.babylonjs.com/features/cameras
  67800. */
  67801. export class TargetCamera extends Camera {
  67802. private static _RigCamTransformMatrix;
  67803. private static _TargetTransformMatrix;
  67804. private static _TargetFocalPoint;
  67805. /**
  67806. * Define the current direction the camera is moving to
  67807. */
  67808. cameraDirection: Vector3;
  67809. /**
  67810. * Define the current rotation the camera is rotating to
  67811. */
  67812. cameraRotation: Vector2;
  67813. /**
  67814. * When set, the up vector of the camera will be updated by the rotation of the camera
  67815. */
  67816. updateUpVectorFromRotation: boolean;
  67817. private _tmpQuaternion;
  67818. /**
  67819. * Define the current rotation of the camera
  67820. */
  67821. rotation: Vector3;
  67822. /**
  67823. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  67824. */
  67825. rotationQuaternion: Quaternion;
  67826. /**
  67827. * Define the current speed of the camera
  67828. */
  67829. speed: number;
  67830. /**
  67831. * Add cconstraint to the camera to prevent it to move freely in all directions and
  67832. * around all axis.
  67833. */
  67834. noRotationConstraint: boolean;
  67835. /**
  67836. * Define the current target of the camera as an object or a position.
  67837. */
  67838. lockedTarget: any;
  67839. /** @hidden */
  67840. _currentTarget: Vector3;
  67841. /** @hidden */
  67842. _initialFocalDistance: number;
  67843. /** @hidden */
  67844. _viewMatrix: Matrix;
  67845. /** @hidden */
  67846. _camMatrix: Matrix;
  67847. /** @hidden */
  67848. _cameraTransformMatrix: Matrix;
  67849. /** @hidden */
  67850. _cameraRotationMatrix: Matrix;
  67851. /** @hidden */
  67852. _referencePoint: Vector3;
  67853. /** @hidden */
  67854. _transformedReferencePoint: Vector3;
  67855. protected _globalCurrentTarget: Vector3;
  67856. protected _globalCurrentUpVector: Vector3;
  67857. /** @hidden */
  67858. _reset: () => void;
  67859. private _defaultUp;
  67860. /**
  67861. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  67862. * This is the base of the follow, arc rotate cameras and Free camera
  67863. * @see http://doc.babylonjs.com/features/cameras
  67864. * @param name Defines the name of the camera in the scene
  67865. * @param position Defines the start position of the camera in the scene
  67866. * @param scene Defines the scene the camera belongs to
  67867. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  67868. */
  67869. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  67870. /**
  67871. * Gets the position in front of the camera at a given distance.
  67872. * @param distance The distance from the camera we want the position to be
  67873. * @returns the position
  67874. */
  67875. getFrontPosition(distance: number): Vector3;
  67876. /** @hidden */
  67877. _getLockedTargetPosition(): Nullable<Vector3>;
  67878. private _storedPosition;
  67879. private _storedRotation;
  67880. private _storedRotationQuaternion;
  67881. /**
  67882. * Store current camera state of the camera (fov, position, rotation, etc..)
  67883. * @returns the camera
  67884. */
  67885. storeState(): Camera;
  67886. /**
  67887. * Restored camera state. You must call storeState() first
  67888. * @returns whether it was successful or not
  67889. * @hidden
  67890. */
  67891. _restoreStateValues(): boolean;
  67892. /** @hidden */
  67893. _initCache(): void;
  67894. /** @hidden */
  67895. _updateCache(ignoreParentClass?: boolean): void;
  67896. /** @hidden */
  67897. _isSynchronizedViewMatrix(): boolean;
  67898. /** @hidden */
  67899. _computeLocalCameraSpeed(): number;
  67900. /**
  67901. * Defines the target the camera should look at.
  67902. * This will automatically adapt alpha beta and radius to fit within the new target.
  67903. * @param target Defines the new target as a Vector or a mesh
  67904. */
  67905. setTarget(target: Vector3): void;
  67906. /**
  67907. * Return the current target position of the camera. This value is expressed in local space.
  67908. * @returns the target position
  67909. */
  67910. getTarget(): Vector3;
  67911. /** @hidden */
  67912. _decideIfNeedsToMove(): boolean;
  67913. /** @hidden */
  67914. _updatePosition(): void;
  67915. /** @hidden */
  67916. _checkInputs(): void;
  67917. protected _updateCameraRotationMatrix(): void;
  67918. /**
  67919. * 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)
  67920. * @returns the current camera
  67921. */
  67922. private _rotateUpVectorWithCameraRotationMatrix;
  67923. private _cachedRotationZ;
  67924. private _cachedQuaternionRotationZ;
  67925. /** @hidden */
  67926. _getViewMatrix(): Matrix;
  67927. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  67928. /**
  67929. * @hidden
  67930. */
  67931. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  67932. /**
  67933. * @hidden
  67934. */
  67935. _updateRigCameras(): void;
  67936. private _getRigCamPositionAndTarget;
  67937. /**
  67938. * Gets the current object class name.
  67939. * @return the class name
  67940. */
  67941. getClassName(): string;
  67942. }
  67943. }
  67944. declare module BABYLON {
  67945. /**
  67946. * @ignore
  67947. * This is a list of all the different input types that are available in the application.
  67948. * Fo instance: ArcRotateCameraGamepadInput...
  67949. */
  67950. export var CameraInputTypes: {};
  67951. /**
  67952. * This is the contract to implement in order to create a new input class.
  67953. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  67954. */
  67955. export interface ICameraInput<TCamera extends Camera> {
  67956. /**
  67957. * Defines the camera the input is attached to.
  67958. */
  67959. camera: Nullable<TCamera>;
  67960. /**
  67961. * Gets the class name of the current intput.
  67962. * @returns the class name
  67963. */
  67964. getClassName(): string;
  67965. /**
  67966. * Get the friendly name associated with the input class.
  67967. * @returns the input friendly name
  67968. */
  67969. getSimpleName(): string;
  67970. /**
  67971. * Attach the input controls to a specific dom element to get the input from.
  67972. * @param element Defines the element the controls should be listened from
  67973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67974. */
  67975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67976. /**
  67977. * Detach the current controls from the specified dom element.
  67978. * @param element Defines the element to stop listening the inputs from
  67979. */
  67980. detachControl(element: Nullable<HTMLElement>): void;
  67981. /**
  67982. * Update the current camera state depending on the inputs that have been used this frame.
  67983. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67984. */
  67985. checkInputs?: () => void;
  67986. }
  67987. /**
  67988. * Represents a map of input types to input instance or input index to input instance.
  67989. */
  67990. export interface CameraInputsMap<TCamera extends Camera> {
  67991. /**
  67992. * Accessor to the input by input type.
  67993. */
  67994. [name: string]: ICameraInput<TCamera>;
  67995. /**
  67996. * Accessor to the input by input index.
  67997. */
  67998. [idx: number]: ICameraInput<TCamera>;
  67999. }
  68000. /**
  68001. * This represents the input manager used within a camera.
  68002. * It helps dealing with all the different kind of input attached to a camera.
  68003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68004. */
  68005. export class CameraInputsManager<TCamera extends Camera> {
  68006. /**
  68007. * Defines the list of inputs attahed to the camera.
  68008. */
  68009. attached: CameraInputsMap<TCamera>;
  68010. /**
  68011. * Defines the dom element the camera is collecting inputs from.
  68012. * This is null if the controls have not been attached.
  68013. */
  68014. attachedElement: Nullable<HTMLElement>;
  68015. /**
  68016. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68017. */
  68018. noPreventDefault: boolean;
  68019. /**
  68020. * Defined the camera the input manager belongs to.
  68021. */
  68022. camera: TCamera;
  68023. /**
  68024. * Update the current camera state depending on the inputs that have been used this frame.
  68025. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68026. */
  68027. checkInputs: () => void;
  68028. /**
  68029. * Instantiate a new Camera Input Manager.
  68030. * @param camera Defines the camera the input manager blongs to
  68031. */
  68032. constructor(camera: TCamera);
  68033. /**
  68034. * Add an input method to a camera
  68035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68036. * @param input camera input method
  68037. */
  68038. add(input: ICameraInput<TCamera>): void;
  68039. /**
  68040. * Remove a specific input method from a camera
  68041. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68042. * @param inputToRemove camera input method
  68043. */
  68044. remove(inputToRemove: ICameraInput<TCamera>): void;
  68045. /**
  68046. * Remove a specific input type from a camera
  68047. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68048. * @param inputType the type of the input to remove
  68049. */
  68050. removeByType(inputType: string): void;
  68051. private _addCheckInputs;
  68052. /**
  68053. * Attach the input controls to the currently attached dom element to listen the events from.
  68054. * @param input Defines the input to attach
  68055. */
  68056. attachInput(input: ICameraInput<TCamera>): void;
  68057. /**
  68058. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68059. * @param element Defines the dom element to collect the events from
  68060. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68061. */
  68062. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68063. /**
  68064. * Detach the current manager inputs controls from a specific dom element.
  68065. * @param element Defines the dom element to collect the events from
  68066. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68067. */
  68068. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68069. /**
  68070. * Rebuild the dynamic inputCheck function from the current list of
  68071. * defined inputs in the manager.
  68072. */
  68073. rebuildInputCheck(): void;
  68074. /**
  68075. * Remove all attached input methods from a camera
  68076. */
  68077. clear(): void;
  68078. /**
  68079. * Serialize the current input manager attached to a camera.
  68080. * This ensures than once parsed,
  68081. * the input associated to the camera will be identical to the current ones
  68082. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68083. */
  68084. serialize(serializedCamera: any): void;
  68085. /**
  68086. * Parses an input manager serialized JSON to restore the previous list of inputs
  68087. * and states associated to a camera.
  68088. * @param parsedCamera Defines the JSON to parse
  68089. */
  68090. parse(parsedCamera: any): void;
  68091. }
  68092. }
  68093. declare module BABYLON {
  68094. /**
  68095. * Gather the list of keyboard event types as constants.
  68096. */
  68097. export class KeyboardEventTypes {
  68098. /**
  68099. * The keydown event is fired when a key becomes active (pressed).
  68100. */
  68101. static readonly KEYDOWN: number;
  68102. /**
  68103. * The keyup event is fired when a key has been released.
  68104. */
  68105. static readonly KEYUP: number;
  68106. }
  68107. /**
  68108. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68109. */
  68110. export class KeyboardInfo {
  68111. /**
  68112. * Defines the type of event (KeyboardEventTypes)
  68113. */
  68114. type: number;
  68115. /**
  68116. * Defines the related dom event
  68117. */
  68118. event: KeyboardEvent;
  68119. /**
  68120. * Instantiates a new keyboard info.
  68121. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68122. * @param type Defines the type of event (KeyboardEventTypes)
  68123. * @param event Defines the related dom event
  68124. */
  68125. constructor(
  68126. /**
  68127. * Defines the type of event (KeyboardEventTypes)
  68128. */
  68129. type: number,
  68130. /**
  68131. * Defines the related dom event
  68132. */
  68133. event: KeyboardEvent);
  68134. }
  68135. /**
  68136. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68137. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68138. */
  68139. export class KeyboardInfoPre extends KeyboardInfo {
  68140. /**
  68141. * Defines the type of event (KeyboardEventTypes)
  68142. */
  68143. type: number;
  68144. /**
  68145. * Defines the related dom event
  68146. */
  68147. event: KeyboardEvent;
  68148. /**
  68149. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68150. */
  68151. skipOnPointerObservable: boolean;
  68152. /**
  68153. * Instantiates a new keyboard pre info.
  68154. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68155. * @param type Defines the type of event (KeyboardEventTypes)
  68156. * @param event Defines the related dom event
  68157. */
  68158. constructor(
  68159. /**
  68160. * Defines the type of event (KeyboardEventTypes)
  68161. */
  68162. type: number,
  68163. /**
  68164. * Defines the related dom event
  68165. */
  68166. event: KeyboardEvent);
  68167. }
  68168. }
  68169. declare module BABYLON {
  68170. /**
  68171. * Manage the keyboard inputs to control the movement of a free camera.
  68172. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68173. */
  68174. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68175. /**
  68176. * Defines the camera the input is attached to.
  68177. */
  68178. camera: FreeCamera;
  68179. /**
  68180. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68181. */
  68182. keysUp: number[];
  68183. /**
  68184. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68185. */
  68186. keysDown: number[];
  68187. /**
  68188. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68189. */
  68190. keysLeft: number[];
  68191. /**
  68192. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68193. */
  68194. keysRight: number[];
  68195. private _keys;
  68196. private _onCanvasBlurObserver;
  68197. private _onKeyboardObserver;
  68198. private _engine;
  68199. private _scene;
  68200. /**
  68201. * Attach the input controls to a specific dom element to get the input from.
  68202. * @param element Defines the element the controls should be listened from
  68203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68204. */
  68205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68206. /**
  68207. * Detach the current controls from the specified dom element.
  68208. * @param element Defines the element to stop listening the inputs from
  68209. */
  68210. detachControl(element: Nullable<HTMLElement>): void;
  68211. /**
  68212. * Update the current camera state depending on the inputs that have been used this frame.
  68213. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68214. */
  68215. checkInputs(): void;
  68216. /**
  68217. * Gets the class name of the current intput.
  68218. * @returns the class name
  68219. */
  68220. getClassName(): string;
  68221. /** @hidden */
  68222. _onLostFocus(): void;
  68223. /**
  68224. * Get the friendly name associated with the input class.
  68225. * @returns the input friendly name
  68226. */
  68227. getSimpleName(): string;
  68228. }
  68229. }
  68230. declare module BABYLON {
  68231. /**
  68232. * Interface describing all the common properties and methods a shadow light needs to implement.
  68233. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68234. * as well as binding the different shadow properties to the effects.
  68235. */
  68236. export interface IShadowLight extends Light {
  68237. /**
  68238. * The light id in the scene (used in scene.findLighById for instance)
  68239. */
  68240. id: string;
  68241. /**
  68242. * The position the shdow will be casted from.
  68243. */
  68244. position: Vector3;
  68245. /**
  68246. * In 2d mode (needCube being false), the direction used to cast the shadow.
  68247. */
  68248. direction: Vector3;
  68249. /**
  68250. * The transformed position. Position of the light in world space taking parenting in account.
  68251. */
  68252. transformedPosition: Vector3;
  68253. /**
  68254. * The transformed direction. Direction of the light in world space taking parenting in account.
  68255. */
  68256. transformedDirection: Vector3;
  68257. /**
  68258. * The friendly name of the light in the scene.
  68259. */
  68260. name: string;
  68261. /**
  68262. * Defines the shadow projection clipping minimum z value.
  68263. */
  68264. shadowMinZ: number;
  68265. /**
  68266. * Defines the shadow projection clipping maximum z value.
  68267. */
  68268. shadowMaxZ: number;
  68269. /**
  68270. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68271. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68272. */
  68273. computeTransformedInformation(): boolean;
  68274. /**
  68275. * Gets the scene the light belongs to.
  68276. * @returns The scene
  68277. */
  68278. getScene(): Scene;
  68279. /**
  68280. * Callback defining a custom Projection Matrix Builder.
  68281. * This can be used to override the default projection matrix computation.
  68282. */
  68283. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68284. /**
  68285. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68286. * @param matrix The materix to updated with the projection information
  68287. * @param viewMatrix The transform matrix of the light
  68288. * @param renderList The list of mesh to render in the map
  68289. * @returns The current light
  68290. */
  68291. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68292. /**
  68293. * Gets the current depth scale used in ESM.
  68294. * @returns The scale
  68295. */
  68296. getDepthScale(): number;
  68297. /**
  68298. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68299. * @returns true if a cube texture needs to be use
  68300. */
  68301. needCube(): boolean;
  68302. /**
  68303. * Detects if the projection matrix requires to be recomputed this frame.
  68304. * @returns true if it requires to be recomputed otherwise, false.
  68305. */
  68306. needProjectionMatrixCompute(): boolean;
  68307. /**
  68308. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68309. */
  68310. forceProjectionMatrixCompute(): void;
  68311. /**
  68312. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68313. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68314. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68315. */
  68316. getShadowDirection(faceIndex?: number): Vector3;
  68317. /**
  68318. * Gets the minZ used for shadow according to both the scene and the light.
  68319. * @param activeCamera The camera we are returning the min for
  68320. * @returns the depth min z
  68321. */
  68322. getDepthMinZ(activeCamera: Camera): number;
  68323. /**
  68324. * Gets the maxZ used for shadow according to both the scene and the light.
  68325. * @param activeCamera The camera we are returning the max for
  68326. * @returns the depth max z
  68327. */
  68328. getDepthMaxZ(activeCamera: Camera): number;
  68329. }
  68330. /**
  68331. * Base implementation IShadowLight
  68332. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  68333. */
  68334. export abstract class ShadowLight extends Light implements IShadowLight {
  68335. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  68336. protected _position: Vector3;
  68337. protected _setPosition(value: Vector3): void;
  68338. /**
  68339. * Sets the position the shadow will be casted from. Also use as the light position for both
  68340. * point and spot lights.
  68341. */
  68342. /**
  68343. * Sets the position the shadow will be casted from. Also use as the light position for both
  68344. * point and spot lights.
  68345. */
  68346. position: Vector3;
  68347. protected _direction: Vector3;
  68348. protected _setDirection(value: Vector3): void;
  68349. /**
  68350. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  68351. * Also use as the light direction on spot and directional lights.
  68352. */
  68353. /**
  68354. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  68355. * Also use as the light direction on spot and directional lights.
  68356. */
  68357. direction: Vector3;
  68358. private _shadowMinZ;
  68359. /**
  68360. * Gets the shadow projection clipping minimum z value.
  68361. */
  68362. /**
  68363. * Sets the shadow projection clipping minimum z value.
  68364. */
  68365. shadowMinZ: number;
  68366. private _shadowMaxZ;
  68367. /**
  68368. * Sets the shadow projection clipping maximum z value.
  68369. */
  68370. /**
  68371. * Gets the shadow projection clipping maximum z value.
  68372. */
  68373. shadowMaxZ: number;
  68374. /**
  68375. * Callback defining a custom Projection Matrix Builder.
  68376. * This can be used to override the default projection matrix computation.
  68377. */
  68378. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68379. /**
  68380. * The transformed position. Position of the light in world space taking parenting in account.
  68381. */
  68382. transformedPosition: Vector3;
  68383. /**
  68384. * The transformed direction. Direction of the light in world space taking parenting in account.
  68385. */
  68386. transformedDirection: Vector3;
  68387. private _needProjectionMatrixCompute;
  68388. /**
  68389. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68390. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68391. */
  68392. computeTransformedInformation(): boolean;
  68393. /**
  68394. * Return the depth scale used for the shadow map.
  68395. * @returns the depth scale.
  68396. */
  68397. getDepthScale(): number;
  68398. /**
  68399. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68400. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68401. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68402. */
  68403. getShadowDirection(faceIndex?: number): Vector3;
  68404. /**
  68405. * Returns the ShadowLight absolute position in the World.
  68406. * @returns the position vector in world space
  68407. */
  68408. getAbsolutePosition(): Vector3;
  68409. /**
  68410. * Sets the ShadowLight direction toward the passed target.
  68411. * @param target The point to target in local space
  68412. * @returns the updated ShadowLight direction
  68413. */
  68414. setDirectionToTarget(target: Vector3): Vector3;
  68415. /**
  68416. * Returns the light rotation in euler definition.
  68417. * @returns the x y z rotation in local space.
  68418. */
  68419. getRotation(): Vector3;
  68420. /**
  68421. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68422. * @returns true if a cube texture needs to be use
  68423. */
  68424. needCube(): boolean;
  68425. /**
  68426. * Detects if the projection matrix requires to be recomputed this frame.
  68427. * @returns true if it requires to be recomputed otherwise, false.
  68428. */
  68429. needProjectionMatrixCompute(): boolean;
  68430. /**
  68431. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68432. */
  68433. forceProjectionMatrixCompute(): void;
  68434. /** @hidden */
  68435. _initCache(): void;
  68436. /** @hidden */
  68437. _isSynchronized(): boolean;
  68438. /**
  68439. * Computes the world matrix of the node
  68440. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  68441. * @returns the world matrix
  68442. */
  68443. computeWorldMatrix(force?: boolean): Matrix;
  68444. /**
  68445. * Gets the minZ used for shadow according to both the scene and the light.
  68446. * @param activeCamera The camera we are returning the min for
  68447. * @returns the depth min z
  68448. */
  68449. getDepthMinZ(activeCamera: Camera): number;
  68450. /**
  68451. * Gets the maxZ used for shadow according to both the scene and the light.
  68452. * @param activeCamera The camera we are returning the max for
  68453. * @returns the depth max z
  68454. */
  68455. getDepthMaxZ(activeCamera: Camera): number;
  68456. /**
  68457. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68458. * @param matrix The materix to updated with the projection information
  68459. * @param viewMatrix The transform matrix of the light
  68460. * @param renderList The list of mesh to render in the map
  68461. * @returns The current light
  68462. */
  68463. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68464. }
  68465. }
  68466. declare module BABYLON {
  68467. /**
  68468. * "Static Class" containing the most commonly used helper while dealing with material for
  68469. * rendering purpose.
  68470. *
  68471. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  68472. *
  68473. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  68474. */
  68475. export class MaterialHelper {
  68476. /**
  68477. * Bind the current view position to an effect.
  68478. * @param effect The effect to be bound
  68479. * @param scene The scene the eyes position is used from
  68480. */
  68481. static BindEyePosition(effect: Effect, scene: Scene): void;
  68482. /**
  68483. * Helps preparing the defines values about the UVs in used in the effect.
  68484. * UVs are shared as much as we can accross channels in the shaders.
  68485. * @param texture The texture we are preparing the UVs for
  68486. * @param defines The defines to update
  68487. * @param key The channel key "diffuse", "specular"... used in the shader
  68488. */
  68489. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  68490. /**
  68491. * Binds a texture matrix value to its corrsponding uniform
  68492. * @param texture The texture to bind the matrix for
  68493. * @param uniformBuffer The uniform buffer receivin the data
  68494. * @param key The channel key "diffuse", "specular"... used in the shader
  68495. */
  68496. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  68497. /**
  68498. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  68499. * @param mesh defines the current mesh
  68500. * @param scene defines the current scene
  68501. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  68502. * @param pointsCloud defines if point cloud rendering has to be turned on
  68503. * @param fogEnabled defines if fog has to be turned on
  68504. * @param alphaTest defines if alpha testing has to be turned on
  68505. * @param defines defines the current list of defines
  68506. */
  68507. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  68508. /**
  68509. * Helper used to prepare the list of defines associated with frame values for shader compilation
  68510. * @param scene defines the current scene
  68511. * @param engine defines the current engine
  68512. * @param defines specifies the list of active defines
  68513. * @param useInstances defines if instances have to be turned on
  68514. * @param useClipPlane defines if clip plane have to be turned on
  68515. */
  68516. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  68517. /**
  68518. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  68519. * @param mesh The mesh containing the geometry data we will draw
  68520. * @param defines The defines to update
  68521. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  68522. * @param useBones Precise whether bones should be used or not (override mesh info)
  68523. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  68524. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  68525. * @returns false if defines are considered not dirty and have not been checked
  68526. */
  68527. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  68528. /**
  68529. * Prepares the defines related to multiview
  68530. * @param scene The scene we are intending to draw
  68531. * @param defines The defines to update
  68532. */
  68533. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  68534. /**
  68535. * Prepares the defines related to the light information passed in parameter
  68536. * @param scene The scene we are intending to draw
  68537. * @param mesh The mesh the effect is compiling for
  68538. * @param defines The defines to update
  68539. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  68540. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  68541. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  68542. * @returns true if normals will be required for the rest of the effect
  68543. */
  68544. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  68545. /**
  68546. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  68547. * that won t be acctive due to defines being turned off.
  68548. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  68549. * @param samplersList The samplers list
  68550. * @param defines The defines helping in the list generation
  68551. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  68552. */
  68553. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  68554. /**
  68555. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  68556. * @param defines The defines to update while falling back
  68557. * @param fallbacks The authorized effect fallbacks
  68558. * @param maxSimultaneousLights The maximum number of lights allowed
  68559. * @param rank the current rank of the Effect
  68560. * @returns The newly affected rank
  68561. */
  68562. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  68563. /**
  68564. * Prepares the list of attributes required for morph targets according to the effect defines.
  68565. * @param attribs The current list of supported attribs
  68566. * @param mesh The mesh to prepare the morph targets attributes for
  68567. * @param defines The current Defines of the effect
  68568. */
  68569. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  68570. /**
  68571. * Prepares the list of attributes required for bones according to the effect defines.
  68572. * @param attribs The current list of supported attribs
  68573. * @param mesh The mesh to prepare the bones attributes for
  68574. * @param defines The current Defines of the effect
  68575. * @param fallbacks The current efffect fallback strategy
  68576. */
  68577. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  68578. /**
  68579. * Prepares the list of attributes required for instances according to the effect defines.
  68580. * @param attribs The current list of supported attribs
  68581. * @param defines The current Defines of the effect
  68582. */
  68583. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  68584. /**
  68585. * Binds the light shadow information to the effect for the given mesh.
  68586. * @param light The light containing the generator
  68587. * @param scene The scene the lights belongs to
  68588. * @param mesh The mesh we are binding the information to render
  68589. * @param lightIndex The light index in the effect used to render the mesh
  68590. * @param effect The effect we are binding the data to
  68591. */
  68592. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  68593. /**
  68594. * Binds the light information to the effect.
  68595. * @param light The light containing the generator
  68596. * @param effect The effect we are binding the data to
  68597. * @param lightIndex The light index in the effect used to render
  68598. */
  68599. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  68600. /**
  68601. * Binds the lights information from the scene to the effect for the given mesh.
  68602. * @param scene The scene the lights belongs to
  68603. * @param mesh The mesh we are binding the information to render
  68604. * @param effect The effect we are binding the data to
  68605. * @param defines The generated defines for the effect
  68606. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  68607. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  68608. */
  68609. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  68610. private static _tempFogColor;
  68611. /**
  68612. * Binds the fog information from the scene to the effect for the given mesh.
  68613. * @param scene The scene the lights belongs to
  68614. * @param mesh The mesh we are binding the information to render
  68615. * @param effect The effect we are binding the data to
  68616. * @param linearSpace Defines if the fog effect is applied in linear space
  68617. */
  68618. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  68619. /**
  68620. * Binds the bones information from the mesh to the effect.
  68621. * @param mesh The mesh we are binding the information to render
  68622. * @param effect The effect we are binding the data to
  68623. */
  68624. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  68625. /**
  68626. * Binds the morph targets information from the mesh to the effect.
  68627. * @param abstractMesh The mesh we are binding the information to render
  68628. * @param effect The effect we are binding the data to
  68629. */
  68630. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  68631. /**
  68632. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  68633. * @param defines The generated defines used in the effect
  68634. * @param effect The effect we are binding the data to
  68635. * @param scene The scene we are willing to render with logarithmic scale for
  68636. */
  68637. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  68638. /**
  68639. * Binds the clip plane information from the scene to the effect.
  68640. * @param scene The scene the clip plane information are extracted from
  68641. * @param effect The effect we are binding the data to
  68642. */
  68643. static BindClipPlane(effect: Effect, scene: Scene): void;
  68644. }
  68645. }
  68646. declare module BABYLON {
  68647. /** @hidden */
  68648. export var kernelBlurVaryingDeclaration: {
  68649. name: string;
  68650. shader: string;
  68651. };
  68652. }
  68653. declare module BABYLON {
  68654. /** @hidden */
  68655. export var kernelBlurFragment: {
  68656. name: string;
  68657. shader: string;
  68658. };
  68659. }
  68660. declare module BABYLON {
  68661. /** @hidden */
  68662. export var kernelBlurFragment2: {
  68663. name: string;
  68664. shader: string;
  68665. };
  68666. }
  68667. declare module BABYLON {
  68668. /** @hidden */
  68669. export var kernelBlurPixelShader: {
  68670. name: string;
  68671. shader: string;
  68672. };
  68673. }
  68674. declare module BABYLON {
  68675. /** @hidden */
  68676. export var kernelBlurVertex: {
  68677. name: string;
  68678. shader: string;
  68679. };
  68680. }
  68681. declare module BABYLON {
  68682. /** @hidden */
  68683. export var kernelBlurVertexShader: {
  68684. name: string;
  68685. shader: string;
  68686. };
  68687. }
  68688. declare module BABYLON {
  68689. /**
  68690. * The Blur Post Process which blurs an image based on a kernel and direction.
  68691. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  68692. */
  68693. export class BlurPostProcess extends PostProcess {
  68694. /** The direction in which to blur the image. */
  68695. direction: Vector2;
  68696. private blockCompilation;
  68697. protected _kernel: number;
  68698. protected _idealKernel: number;
  68699. protected _packedFloat: boolean;
  68700. private _staticDefines;
  68701. /**
  68702. * Sets the length in pixels of the blur sample region
  68703. */
  68704. /**
  68705. * Gets the length in pixels of the blur sample region
  68706. */
  68707. kernel: number;
  68708. /**
  68709. * Sets wether or not the blur needs to unpack/repack floats
  68710. */
  68711. /**
  68712. * Gets wether or not the blur is unpacking/repacking floats
  68713. */
  68714. packedFloat: boolean;
  68715. /**
  68716. * Creates a new instance BlurPostProcess
  68717. * @param name The name of the effect.
  68718. * @param direction The direction in which to blur the image.
  68719. * @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.
  68720. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  68721. * @param camera The camera to apply the render pass to.
  68722. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68723. * @param engine The engine which the post process will be applied. (default: current engine)
  68724. * @param reusable If the post process can be reused on the same frame. (default: false)
  68725. * @param textureType Type of textures used when performing the post process. (default: 0)
  68726. * @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)
  68727. */
  68728. constructor(name: string,
  68729. /** The direction in which to blur the image. */
  68730. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  68731. /**
  68732. * Updates the effect with the current post process compile time values and recompiles the shader.
  68733. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68734. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68735. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68736. * @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
  68737. * @param onCompiled Called when the shader has been compiled.
  68738. * @param onError Called if there is an error when compiling a shader.
  68739. */
  68740. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68741. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68742. /**
  68743. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  68744. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  68745. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  68746. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  68747. * The gaps between physical kernels are compensated for in the weighting of the samples
  68748. * @param idealKernel Ideal blur kernel.
  68749. * @return Nearest best kernel.
  68750. */
  68751. protected _nearestBestKernel(idealKernel: number): number;
  68752. /**
  68753. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  68754. * @param x The point on the Gaussian distribution to sample.
  68755. * @return the value of the Gaussian function at x.
  68756. */
  68757. protected _gaussianWeight(x: number): number;
  68758. /**
  68759. * Generates a string that can be used as a floating point number in GLSL.
  68760. * @param x Value to print.
  68761. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  68762. * @return GLSL float string.
  68763. */
  68764. protected _glslFloat(x: number, decimalFigures?: number): string;
  68765. }
  68766. }
  68767. declare module BABYLON {
  68768. /** @hidden */
  68769. export var shadowMapPixelShader: {
  68770. name: string;
  68771. shader: string;
  68772. };
  68773. }
  68774. declare module BABYLON {
  68775. /** @hidden */
  68776. export var bonesDeclaration: {
  68777. name: string;
  68778. shader: string;
  68779. };
  68780. }
  68781. declare module BABYLON {
  68782. /** @hidden */
  68783. export var morphTargetsVertexGlobalDeclaration: {
  68784. name: string;
  68785. shader: string;
  68786. };
  68787. }
  68788. declare module BABYLON {
  68789. /** @hidden */
  68790. export var morphTargetsVertexDeclaration: {
  68791. name: string;
  68792. shader: string;
  68793. };
  68794. }
  68795. declare module BABYLON {
  68796. /** @hidden */
  68797. export var instancesDeclaration: {
  68798. name: string;
  68799. shader: string;
  68800. };
  68801. }
  68802. declare module BABYLON {
  68803. /** @hidden */
  68804. export var helperFunctions: {
  68805. name: string;
  68806. shader: string;
  68807. };
  68808. }
  68809. declare module BABYLON {
  68810. /** @hidden */
  68811. export var morphTargetsVertex: {
  68812. name: string;
  68813. shader: string;
  68814. };
  68815. }
  68816. declare module BABYLON {
  68817. /** @hidden */
  68818. export var instancesVertex: {
  68819. name: string;
  68820. shader: string;
  68821. };
  68822. }
  68823. declare module BABYLON {
  68824. /** @hidden */
  68825. export var bonesVertex: {
  68826. name: string;
  68827. shader: string;
  68828. };
  68829. }
  68830. declare module BABYLON {
  68831. /** @hidden */
  68832. export var shadowMapVertexShader: {
  68833. name: string;
  68834. shader: string;
  68835. };
  68836. }
  68837. declare module BABYLON {
  68838. /** @hidden */
  68839. export var depthBoxBlurPixelShader: {
  68840. name: string;
  68841. shader: string;
  68842. };
  68843. }
  68844. declare module BABYLON {
  68845. /**
  68846. * Defines the options associated with the creation of a custom shader for a shadow generator.
  68847. */
  68848. export interface ICustomShaderOptions {
  68849. /**
  68850. * Gets or sets the custom shader name to use
  68851. */
  68852. shaderName: string;
  68853. /**
  68854. * The list of attribute names used in the shader
  68855. */
  68856. attributes?: string[];
  68857. /**
  68858. * The list of unifrom names used in the shader
  68859. */
  68860. uniforms?: string[];
  68861. /**
  68862. * The list of sampler names used in the shader
  68863. */
  68864. samplers?: string[];
  68865. /**
  68866. * The list of defines used in the shader
  68867. */
  68868. defines?: string[];
  68869. }
  68870. /**
  68871. * Interface to implement to create a shadow generator compatible with BJS.
  68872. */
  68873. export interface IShadowGenerator {
  68874. /**
  68875. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68876. * @returns The render target texture if present otherwise, null
  68877. */
  68878. getShadowMap(): Nullable<RenderTargetTexture>;
  68879. /**
  68880. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68881. * @returns The render target texture if the shadow map is present otherwise, null
  68882. */
  68883. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68884. /**
  68885. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68886. * @param subMesh The submesh we want to render in the shadow map
  68887. * @param useInstances Defines wether will draw in the map using instances
  68888. * @returns true if ready otherwise, false
  68889. */
  68890. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68891. /**
  68892. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68893. * @param defines Defines of the material we want to update
  68894. * @param lightIndex Index of the light in the enabled light list of the material
  68895. */
  68896. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  68897. /**
  68898. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68899. * defined in the generator but impacting the effect).
  68900. * It implies the unifroms available on the materials are the standard BJS ones.
  68901. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68902. * @param effect The effect we are binfing the information for
  68903. */
  68904. bindShadowLight(lightIndex: string, effect: Effect): void;
  68905. /**
  68906. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68907. * (eq to shadow prjection matrix * light transform matrix)
  68908. * @returns The transform matrix used to create the shadow map
  68909. */
  68910. getTransformMatrix(): Matrix;
  68911. /**
  68912. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68913. * Cube and 2D textures for instance.
  68914. */
  68915. recreateShadowMap(): void;
  68916. /**
  68917. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68918. * @param onCompiled Callback triggered at the and of the effects compilation
  68919. * @param options Sets of optional options forcing the compilation with different modes
  68920. */
  68921. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68922. useInstances: boolean;
  68923. }>): void;
  68924. /**
  68925. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68926. * @param options Sets of optional options forcing the compilation with different modes
  68927. * @returns A promise that resolves when the compilation completes
  68928. */
  68929. forceCompilationAsync(options?: Partial<{
  68930. useInstances: boolean;
  68931. }>): Promise<void>;
  68932. /**
  68933. * Serializes the shadow generator setup to a json object.
  68934. * @returns The serialized JSON object
  68935. */
  68936. serialize(): any;
  68937. /**
  68938. * Disposes the Shadow map and related Textures and effects.
  68939. */
  68940. dispose(): void;
  68941. }
  68942. /**
  68943. * Default implementation IShadowGenerator.
  68944. * This is the main object responsible of generating shadows in the framework.
  68945. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  68946. */
  68947. export class ShadowGenerator implements IShadowGenerator {
  68948. /**
  68949. * Shadow generator mode None: no filtering applied.
  68950. */
  68951. static readonly FILTER_NONE: number;
  68952. /**
  68953. * Shadow generator mode ESM: Exponential Shadow Mapping.
  68954. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68955. */
  68956. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  68957. /**
  68958. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  68959. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  68960. */
  68961. static readonly FILTER_POISSONSAMPLING: number;
  68962. /**
  68963. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  68964. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68965. */
  68966. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  68967. /**
  68968. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  68969. * edge artifacts on steep falloff.
  68970. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68971. */
  68972. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  68973. /**
  68974. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  68975. * edge artifacts on steep falloff.
  68976. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68977. */
  68978. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  68979. /**
  68980. * Shadow generator mode PCF: Percentage Closer Filtering
  68981. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68982. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  68983. */
  68984. static readonly FILTER_PCF: number;
  68985. /**
  68986. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  68987. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68988. * Contact Hardening
  68989. */
  68990. static readonly FILTER_PCSS: number;
  68991. /**
  68992. * Reserved for PCF and PCSS
  68993. * Highest Quality.
  68994. *
  68995. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  68996. *
  68997. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  68998. */
  68999. static readonly QUALITY_HIGH: number;
  69000. /**
  69001. * Reserved for PCF and PCSS
  69002. * Good tradeoff for quality/perf cross devices
  69003. *
  69004. * Execute PCF on a 3*3 kernel.
  69005. *
  69006. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69007. */
  69008. static readonly QUALITY_MEDIUM: number;
  69009. /**
  69010. * Reserved for PCF and PCSS
  69011. * The lowest quality but the fastest.
  69012. *
  69013. * Execute PCF on a 1*1 kernel.
  69014. *
  69015. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69016. */
  69017. static readonly QUALITY_LOW: number;
  69018. /** Gets or sets the custom shader name to use */
  69019. customShaderOptions: ICustomShaderOptions;
  69020. /**
  69021. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69022. */
  69023. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69024. /**
  69025. * Observable triggered before a mesh is rendered in the shadow map.
  69026. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69027. */
  69028. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69029. private _bias;
  69030. /**
  69031. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69032. */
  69033. /**
  69034. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69035. */
  69036. bias: number;
  69037. private _normalBias;
  69038. /**
  69039. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69040. */
  69041. /**
  69042. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69043. */
  69044. normalBias: number;
  69045. private _blurBoxOffset;
  69046. /**
  69047. * Gets the blur box offset: offset applied during the blur pass.
  69048. * Only useful if useKernelBlur = false
  69049. */
  69050. /**
  69051. * Sets the blur box offset: offset applied during the blur pass.
  69052. * Only useful if useKernelBlur = false
  69053. */
  69054. blurBoxOffset: number;
  69055. private _blurScale;
  69056. /**
  69057. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69058. * 2 means half of the size.
  69059. */
  69060. /**
  69061. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69062. * 2 means half of the size.
  69063. */
  69064. blurScale: number;
  69065. private _blurKernel;
  69066. /**
  69067. * Gets the blur kernel: kernel size of the blur pass.
  69068. * Only useful if useKernelBlur = true
  69069. */
  69070. /**
  69071. * Sets the blur kernel: kernel size of the blur pass.
  69072. * Only useful if useKernelBlur = true
  69073. */
  69074. blurKernel: number;
  69075. private _useKernelBlur;
  69076. /**
  69077. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69078. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69079. */
  69080. /**
  69081. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69082. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69083. */
  69084. useKernelBlur: boolean;
  69085. private _depthScale;
  69086. /**
  69087. * Gets the depth scale used in ESM mode.
  69088. */
  69089. /**
  69090. * Sets the depth scale used in ESM mode.
  69091. * This can override the scale stored on the light.
  69092. */
  69093. depthScale: number;
  69094. private _filter;
  69095. /**
  69096. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69097. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69098. */
  69099. /**
  69100. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69101. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69102. */
  69103. filter: number;
  69104. /**
  69105. * Gets if the current filter is set to Poisson Sampling.
  69106. */
  69107. /**
  69108. * Sets the current filter to Poisson Sampling.
  69109. */
  69110. usePoissonSampling: boolean;
  69111. /**
  69112. * Gets if the current filter is set to ESM.
  69113. */
  69114. /**
  69115. * Sets the current filter is to ESM.
  69116. */
  69117. useExponentialShadowMap: boolean;
  69118. /**
  69119. * Gets if the current filter is set to filtered ESM.
  69120. */
  69121. /**
  69122. * Gets if the current filter is set to filtered ESM.
  69123. */
  69124. useBlurExponentialShadowMap: boolean;
  69125. /**
  69126. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69127. * exponential to prevent steep falloff artifacts).
  69128. */
  69129. /**
  69130. * Sets the current filter to "close ESM" (using the inverse of the
  69131. * exponential to prevent steep falloff artifacts).
  69132. */
  69133. useCloseExponentialShadowMap: boolean;
  69134. /**
  69135. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69136. * exponential to prevent steep falloff artifacts).
  69137. */
  69138. /**
  69139. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69140. * exponential to prevent steep falloff artifacts).
  69141. */
  69142. useBlurCloseExponentialShadowMap: boolean;
  69143. /**
  69144. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69145. */
  69146. /**
  69147. * Sets the current filter to "PCF" (percentage closer filtering).
  69148. */
  69149. usePercentageCloserFiltering: boolean;
  69150. private _filteringQuality;
  69151. /**
  69152. * Gets the PCF or PCSS Quality.
  69153. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69154. */
  69155. /**
  69156. * Sets the PCF or PCSS Quality.
  69157. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69158. */
  69159. filteringQuality: number;
  69160. /**
  69161. * Gets if the current filter is set to "PCSS" (contact hardening).
  69162. */
  69163. /**
  69164. * Sets the current filter to "PCSS" (contact hardening).
  69165. */
  69166. useContactHardeningShadow: boolean;
  69167. private _contactHardeningLightSizeUVRatio;
  69168. /**
  69169. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69170. * Using a ratio helps keeping shape stability independently of the map size.
  69171. *
  69172. * It does not account for the light projection as it was having too much
  69173. * instability during the light setup or during light position changes.
  69174. *
  69175. * Only valid if useContactHardeningShadow is true.
  69176. */
  69177. /**
  69178. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69179. * Using a ratio helps keeping shape stability independently of the map size.
  69180. *
  69181. * It does not account for the light projection as it was having too much
  69182. * instability during the light setup or during light position changes.
  69183. *
  69184. * Only valid if useContactHardeningShadow is true.
  69185. */
  69186. contactHardeningLightSizeUVRatio: number;
  69187. private _darkness;
  69188. /**
  69189. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69190. * 0 means strongest and 1 would means no shadow.
  69191. * @returns the darkness.
  69192. */
  69193. getDarkness(): number;
  69194. /**
  69195. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69196. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69197. * @returns the shadow generator allowing fluent coding.
  69198. */
  69199. setDarkness(darkness: number): ShadowGenerator;
  69200. private _transparencyShadow;
  69201. /**
  69202. * Sets the ability to have transparent shadow (boolean).
  69203. * @param transparent True if transparent else False
  69204. * @returns the shadow generator allowing fluent coding
  69205. */
  69206. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69207. private _shadowMap;
  69208. private _shadowMap2;
  69209. /**
  69210. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69211. * @returns The render target texture if present otherwise, null
  69212. */
  69213. getShadowMap(): Nullable<RenderTargetTexture>;
  69214. /**
  69215. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69216. * @returns The render target texture if the shadow map is present otherwise, null
  69217. */
  69218. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69219. /**
  69220. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69221. * @param mesh Mesh to add
  69222. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69223. * @returns the Shadow Generator itself
  69224. */
  69225. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69226. /**
  69227. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69228. * @param mesh Mesh to remove
  69229. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69230. * @returns the Shadow Generator itself
  69231. */
  69232. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69233. /**
  69234. * Controls the extent to which the shadows fade out at the edge of the frustum
  69235. * Used only by directionals and spots
  69236. */
  69237. frustumEdgeFalloff: number;
  69238. private _light;
  69239. /**
  69240. * Returns the associated light object.
  69241. * @returns the light generating the shadow
  69242. */
  69243. getLight(): IShadowLight;
  69244. /**
  69245. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  69246. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  69247. * It might on the other hand introduce peter panning.
  69248. */
  69249. forceBackFacesOnly: boolean;
  69250. private _scene;
  69251. private _lightDirection;
  69252. private _effect;
  69253. private _viewMatrix;
  69254. private _projectionMatrix;
  69255. private _transformMatrix;
  69256. private _cachedPosition;
  69257. private _cachedDirection;
  69258. private _cachedDefines;
  69259. private _currentRenderID;
  69260. private _boxBlurPostprocess;
  69261. private _kernelBlurXPostprocess;
  69262. private _kernelBlurYPostprocess;
  69263. private _blurPostProcesses;
  69264. private _mapSize;
  69265. private _currentFaceIndex;
  69266. private _currentFaceIndexCache;
  69267. private _textureType;
  69268. private _defaultTextureMatrix;
  69269. /** @hidden */
  69270. static _SceneComponentInitialization: (scene: Scene) => void;
  69271. /**
  69272. * Creates a ShadowGenerator object.
  69273. * A ShadowGenerator is the required tool to use the shadows.
  69274. * Each light casting shadows needs to use its own ShadowGenerator.
  69275. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  69276. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  69277. * @param light The light object generating the shadows.
  69278. * @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.
  69279. */
  69280. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  69281. private _initializeGenerator;
  69282. private _initializeShadowMap;
  69283. private _initializeBlurRTTAndPostProcesses;
  69284. private _renderForShadowMap;
  69285. private _renderSubMeshForShadowMap;
  69286. private _applyFilterValues;
  69287. /**
  69288. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69289. * @param onCompiled Callback triggered at the and of the effects compilation
  69290. * @param options Sets of optional options forcing the compilation with different modes
  69291. */
  69292. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69293. useInstances: boolean;
  69294. }>): void;
  69295. /**
  69296. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69297. * @param options Sets of optional options forcing the compilation with different modes
  69298. * @returns A promise that resolves when the compilation completes
  69299. */
  69300. forceCompilationAsync(options?: Partial<{
  69301. useInstances: boolean;
  69302. }>): Promise<void>;
  69303. /**
  69304. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69305. * @param subMesh The submesh we want to render in the shadow map
  69306. * @param useInstances Defines wether will draw in the map using instances
  69307. * @returns true if ready otherwise, false
  69308. */
  69309. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69310. /**
  69311. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69312. * @param defines Defines of the material we want to update
  69313. * @param lightIndex Index of the light in the enabled light list of the material
  69314. */
  69315. prepareDefines(defines: any, lightIndex: number): void;
  69316. /**
  69317. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69318. * defined in the generator but impacting the effect).
  69319. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69320. * @param effect The effect we are binfing the information for
  69321. */
  69322. bindShadowLight(lightIndex: string, effect: Effect): void;
  69323. /**
  69324. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69325. * (eq to shadow prjection matrix * light transform matrix)
  69326. * @returns The transform matrix used to create the shadow map
  69327. */
  69328. getTransformMatrix(): Matrix;
  69329. /**
  69330. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69331. * Cube and 2D textures for instance.
  69332. */
  69333. recreateShadowMap(): void;
  69334. private _disposeBlurPostProcesses;
  69335. private _disposeRTTandPostProcesses;
  69336. /**
  69337. * Disposes the ShadowGenerator.
  69338. * Returns nothing.
  69339. */
  69340. dispose(): void;
  69341. /**
  69342. * Serializes the shadow generator setup to a json object.
  69343. * @returns The serialized JSON object
  69344. */
  69345. serialize(): any;
  69346. /**
  69347. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  69348. * @param parsedShadowGenerator The JSON object to parse
  69349. * @param scene The scene to create the shadow map for
  69350. * @returns The parsed shadow generator
  69351. */
  69352. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  69353. }
  69354. }
  69355. declare module BABYLON {
  69356. /**
  69357. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  69358. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  69359. * 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.
  69360. */
  69361. export abstract class Light extends Node {
  69362. /**
  69363. * Falloff Default: light is falling off following the material specification:
  69364. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  69365. */
  69366. static readonly FALLOFF_DEFAULT: number;
  69367. /**
  69368. * Falloff Physical: light is falling off following the inverse squared distance law.
  69369. */
  69370. static readonly FALLOFF_PHYSICAL: number;
  69371. /**
  69372. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  69373. * to enhance interoperability with other engines.
  69374. */
  69375. static readonly FALLOFF_GLTF: number;
  69376. /**
  69377. * Falloff Standard: light is falling off like in the standard material
  69378. * to enhance interoperability with other materials.
  69379. */
  69380. static readonly FALLOFF_STANDARD: number;
  69381. /**
  69382. * If every light affecting the material is in this lightmapMode,
  69383. * material.lightmapTexture adds or multiplies
  69384. * (depends on material.useLightmapAsShadowmap)
  69385. * after every other light calculations.
  69386. */
  69387. static readonly LIGHTMAP_DEFAULT: number;
  69388. /**
  69389. * material.lightmapTexture as only diffuse lighting from this light
  69390. * adds only specular lighting from this light
  69391. * adds dynamic shadows
  69392. */
  69393. static readonly LIGHTMAP_SPECULAR: number;
  69394. /**
  69395. * material.lightmapTexture as only lighting
  69396. * no light calculation from this light
  69397. * only adds dynamic shadows from this light
  69398. */
  69399. static readonly LIGHTMAP_SHADOWSONLY: number;
  69400. /**
  69401. * Each light type uses the default quantity according to its type:
  69402. * point/spot lights use luminous intensity
  69403. * directional lights use illuminance
  69404. */
  69405. static readonly INTENSITYMODE_AUTOMATIC: number;
  69406. /**
  69407. * lumen (lm)
  69408. */
  69409. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  69410. /**
  69411. * candela (lm/sr)
  69412. */
  69413. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  69414. /**
  69415. * lux (lm/m^2)
  69416. */
  69417. static readonly INTENSITYMODE_ILLUMINANCE: number;
  69418. /**
  69419. * nit (cd/m^2)
  69420. */
  69421. static readonly INTENSITYMODE_LUMINANCE: number;
  69422. /**
  69423. * Light type const id of the point light.
  69424. */
  69425. static readonly LIGHTTYPEID_POINTLIGHT: number;
  69426. /**
  69427. * Light type const id of the directional light.
  69428. */
  69429. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  69430. /**
  69431. * Light type const id of the spot light.
  69432. */
  69433. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  69434. /**
  69435. * Light type const id of the hemispheric light.
  69436. */
  69437. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  69438. /**
  69439. * Diffuse gives the basic color to an object.
  69440. */
  69441. diffuse: Color3;
  69442. /**
  69443. * Specular produces a highlight color on an object.
  69444. * Note: This is note affecting PBR materials.
  69445. */
  69446. specular: Color3;
  69447. /**
  69448. * Defines the falloff type for this light. This lets overrriding how punctual light are
  69449. * falling off base on range or angle.
  69450. * This can be set to any values in Light.FALLOFF_x.
  69451. *
  69452. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  69453. * other types of materials.
  69454. */
  69455. falloffType: number;
  69456. /**
  69457. * Strength of the light.
  69458. * Note: By default it is define in the framework own unit.
  69459. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  69460. */
  69461. intensity: number;
  69462. private _range;
  69463. protected _inverseSquaredRange: number;
  69464. /**
  69465. * Defines how far from the source the light is impacting in scene units.
  69466. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69467. */
  69468. /**
  69469. * Defines how far from the source the light is impacting in scene units.
  69470. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69471. */
  69472. range: number;
  69473. /**
  69474. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  69475. * of light.
  69476. */
  69477. private _photometricScale;
  69478. private _intensityMode;
  69479. /**
  69480. * Gets the photometric scale used to interpret the intensity.
  69481. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69482. */
  69483. /**
  69484. * Sets the photometric scale used to interpret the intensity.
  69485. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69486. */
  69487. intensityMode: number;
  69488. private _radius;
  69489. /**
  69490. * Gets the light radius used by PBR Materials to simulate soft area lights.
  69491. */
  69492. /**
  69493. * sets the light radius used by PBR Materials to simulate soft area lights.
  69494. */
  69495. radius: number;
  69496. private _renderPriority;
  69497. /**
  69498. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  69499. * exceeding the number allowed of the materials.
  69500. */
  69501. renderPriority: number;
  69502. private _shadowEnabled;
  69503. /**
  69504. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69505. * the current shadow generator.
  69506. */
  69507. /**
  69508. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69509. * the current shadow generator.
  69510. */
  69511. shadowEnabled: boolean;
  69512. private _includedOnlyMeshes;
  69513. /**
  69514. * Gets the only meshes impacted by this light.
  69515. */
  69516. /**
  69517. * Sets the only meshes impacted by this light.
  69518. */
  69519. includedOnlyMeshes: AbstractMesh[];
  69520. private _excludedMeshes;
  69521. /**
  69522. * Gets the meshes not impacted by this light.
  69523. */
  69524. /**
  69525. * Sets the meshes not impacted by this light.
  69526. */
  69527. excludedMeshes: AbstractMesh[];
  69528. private _excludeWithLayerMask;
  69529. /**
  69530. * Gets the layer id use to find what meshes are not impacted by the light.
  69531. * Inactive if 0
  69532. */
  69533. /**
  69534. * Sets the layer id use to find what meshes are not impacted by the light.
  69535. * Inactive if 0
  69536. */
  69537. excludeWithLayerMask: number;
  69538. private _includeOnlyWithLayerMask;
  69539. /**
  69540. * Gets the layer id use to find what meshes are impacted by the light.
  69541. * Inactive if 0
  69542. */
  69543. /**
  69544. * Sets the layer id use to find what meshes are impacted by the light.
  69545. * Inactive if 0
  69546. */
  69547. includeOnlyWithLayerMask: number;
  69548. private _lightmapMode;
  69549. /**
  69550. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69551. */
  69552. /**
  69553. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69554. */
  69555. lightmapMode: number;
  69556. /**
  69557. * Shadow generator associted to the light.
  69558. * @hidden Internal use only.
  69559. */
  69560. _shadowGenerator: Nullable<IShadowGenerator>;
  69561. /**
  69562. * @hidden Internal use only.
  69563. */
  69564. _excludedMeshesIds: string[];
  69565. /**
  69566. * @hidden Internal use only.
  69567. */
  69568. _includedOnlyMeshesIds: string[];
  69569. /**
  69570. * The current light unifom buffer.
  69571. * @hidden Internal use only.
  69572. */
  69573. _uniformBuffer: UniformBuffer;
  69574. /**
  69575. * Creates a Light object in the scene.
  69576. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69577. * @param name The firendly name of the light
  69578. * @param scene The scene the light belongs too
  69579. */
  69580. constructor(name: string, scene: Scene);
  69581. protected abstract _buildUniformLayout(): void;
  69582. /**
  69583. * Sets the passed Effect "effect" with the Light information.
  69584. * @param effect The effect to update
  69585. * @param lightIndex The index of the light in the effect to update
  69586. * @returns The light
  69587. */
  69588. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  69589. /**
  69590. * Returns the string "Light".
  69591. * @returns the class name
  69592. */
  69593. getClassName(): string;
  69594. /** @hidden */
  69595. readonly _isLight: boolean;
  69596. /**
  69597. * Converts the light information to a readable string for debug purpose.
  69598. * @param fullDetails Supports for multiple levels of logging within scene loading
  69599. * @returns the human readable light info
  69600. */
  69601. toString(fullDetails?: boolean): string;
  69602. /** @hidden */
  69603. protected _syncParentEnabledState(): void;
  69604. /**
  69605. * Set the enabled state of this node.
  69606. * @param value - the new enabled state
  69607. */
  69608. setEnabled(value: boolean): void;
  69609. /**
  69610. * Returns the Light associated shadow generator if any.
  69611. * @return the associated shadow generator.
  69612. */
  69613. getShadowGenerator(): Nullable<IShadowGenerator>;
  69614. /**
  69615. * Returns a Vector3, the absolute light position in the World.
  69616. * @returns the world space position of the light
  69617. */
  69618. getAbsolutePosition(): Vector3;
  69619. /**
  69620. * Specifies if the light will affect the passed mesh.
  69621. * @param mesh The mesh to test against the light
  69622. * @return true the mesh is affected otherwise, false.
  69623. */
  69624. canAffectMesh(mesh: AbstractMesh): boolean;
  69625. /**
  69626. * Sort function to order lights for rendering.
  69627. * @param a First Light object to compare to second.
  69628. * @param b Second Light object to compare first.
  69629. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  69630. */
  69631. static CompareLightsPriority(a: Light, b: Light): number;
  69632. /**
  69633. * Releases resources associated with this node.
  69634. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  69635. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  69636. */
  69637. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  69638. /**
  69639. * Returns the light type ID (integer).
  69640. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69641. */
  69642. getTypeID(): number;
  69643. /**
  69644. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  69645. * @returns the scaled intensity in intensity mode unit
  69646. */
  69647. getScaledIntensity(): number;
  69648. /**
  69649. * Returns a new Light object, named "name", from the current one.
  69650. * @param name The name of the cloned light
  69651. * @returns the new created light
  69652. */
  69653. clone(name: string): Nullable<Light>;
  69654. /**
  69655. * Serializes the current light into a Serialization object.
  69656. * @returns the serialized object.
  69657. */
  69658. serialize(): any;
  69659. /**
  69660. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  69661. * This new light is named "name" and added to the passed scene.
  69662. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  69663. * @param name The friendly name of the light
  69664. * @param scene The scene the new light will belong to
  69665. * @returns the constructor function
  69666. */
  69667. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  69668. /**
  69669. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  69670. * @param parsedLight The JSON representation of the light
  69671. * @param scene The scene to create the parsed light in
  69672. * @returns the created light after parsing
  69673. */
  69674. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  69675. private _hookArrayForExcluded;
  69676. private _hookArrayForIncludedOnly;
  69677. private _resyncMeshes;
  69678. /**
  69679. * Forces the meshes to update their light related information in their rendering used effects
  69680. * @hidden Internal Use Only
  69681. */
  69682. _markMeshesAsLightDirty(): void;
  69683. /**
  69684. * Recomputes the cached photometric scale if needed.
  69685. */
  69686. private _computePhotometricScale;
  69687. /**
  69688. * Returns the Photometric Scale according to the light type and intensity mode.
  69689. */
  69690. private _getPhotometricScale;
  69691. /**
  69692. * Reorder the light in the scene according to their defined priority.
  69693. * @hidden Internal Use Only
  69694. */
  69695. _reorderLightsInScene(): void;
  69696. /**
  69697. * Prepares the list of defines specific to the light type.
  69698. * @param defines the list of defines
  69699. * @param lightIndex defines the index of the light for the effect
  69700. */
  69701. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69702. }
  69703. }
  69704. declare module BABYLON {
  69705. /**
  69706. * Interface used to define Action
  69707. */
  69708. export interface IAction {
  69709. /**
  69710. * Trigger for the action
  69711. */
  69712. trigger: number;
  69713. /** Options of the trigger */
  69714. triggerOptions: any;
  69715. /**
  69716. * Gets the trigger parameters
  69717. * @returns the trigger parameters
  69718. */
  69719. getTriggerParameter(): any;
  69720. /**
  69721. * Internal only - executes current action event
  69722. * @hidden
  69723. */
  69724. _executeCurrent(evt?: ActionEvent): void;
  69725. /**
  69726. * Serialize placeholder for child classes
  69727. * @param parent of child
  69728. * @returns the serialized object
  69729. */
  69730. serialize(parent: any): any;
  69731. /**
  69732. * Internal only
  69733. * @hidden
  69734. */
  69735. _prepare(): void;
  69736. /**
  69737. * Internal only - manager for action
  69738. * @hidden
  69739. */
  69740. _actionManager: AbstractActionManager;
  69741. }
  69742. /**
  69743. * The action to be carried out following a trigger
  69744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  69745. */
  69746. export class Action implements IAction {
  69747. /** the trigger, with or without parameters, for the action */
  69748. triggerOptions: any;
  69749. /**
  69750. * Trigger for the action
  69751. */
  69752. trigger: number;
  69753. /**
  69754. * Internal only - manager for action
  69755. * @hidden
  69756. */
  69757. _actionManager: ActionManager;
  69758. private _nextActiveAction;
  69759. private _child;
  69760. private _condition?;
  69761. private _triggerParameter;
  69762. /**
  69763. * An event triggered prior to action being executed.
  69764. */
  69765. onBeforeExecuteObservable: Observable<Action>;
  69766. /**
  69767. * Creates a new Action
  69768. * @param triggerOptions the trigger, with or without parameters, for the action
  69769. * @param condition an optional determinant of action
  69770. */
  69771. constructor(
  69772. /** the trigger, with or without parameters, for the action */
  69773. triggerOptions: any, condition?: Condition);
  69774. /**
  69775. * Internal only
  69776. * @hidden
  69777. */
  69778. _prepare(): void;
  69779. /**
  69780. * Gets the trigger parameters
  69781. * @returns the trigger parameters
  69782. */
  69783. getTriggerParameter(): any;
  69784. /**
  69785. * Internal only - executes current action event
  69786. * @hidden
  69787. */
  69788. _executeCurrent(evt?: ActionEvent): void;
  69789. /**
  69790. * Execute placeholder for child classes
  69791. * @param evt optional action event
  69792. */
  69793. execute(evt?: ActionEvent): void;
  69794. /**
  69795. * Skips to next active action
  69796. */
  69797. skipToNextActiveAction(): void;
  69798. /**
  69799. * Adds action to chain of actions, may be a DoNothingAction
  69800. * @param action defines the next action to execute
  69801. * @returns The action passed in
  69802. * @see https://www.babylonjs-playground.com/#1T30HR#0
  69803. */
  69804. then(action: Action): Action;
  69805. /**
  69806. * Internal only
  69807. * @hidden
  69808. */
  69809. _getProperty(propertyPath: string): string;
  69810. /**
  69811. * Internal only
  69812. * @hidden
  69813. */
  69814. _getEffectiveTarget(target: any, propertyPath: string): any;
  69815. /**
  69816. * Serialize placeholder for child classes
  69817. * @param parent of child
  69818. * @returns the serialized object
  69819. */
  69820. serialize(parent: any): any;
  69821. /**
  69822. * Internal only called by serialize
  69823. * @hidden
  69824. */
  69825. protected _serialize(serializedAction: any, parent?: any): any;
  69826. /**
  69827. * Internal only
  69828. * @hidden
  69829. */
  69830. static _SerializeValueAsString: (value: any) => string;
  69831. /**
  69832. * Internal only
  69833. * @hidden
  69834. */
  69835. static _GetTargetProperty: (target: Scene | Node) => {
  69836. name: string;
  69837. targetType: string;
  69838. value: string;
  69839. };
  69840. }
  69841. }
  69842. declare module BABYLON {
  69843. /**
  69844. * A Condition applied to an Action
  69845. */
  69846. export class Condition {
  69847. /**
  69848. * Internal only - manager for action
  69849. * @hidden
  69850. */
  69851. _actionManager: ActionManager;
  69852. /**
  69853. * Internal only
  69854. * @hidden
  69855. */
  69856. _evaluationId: number;
  69857. /**
  69858. * Internal only
  69859. * @hidden
  69860. */
  69861. _currentResult: boolean;
  69862. /**
  69863. * Creates a new Condition
  69864. * @param actionManager the manager of the action the condition is applied to
  69865. */
  69866. constructor(actionManager: ActionManager);
  69867. /**
  69868. * Check if the current condition is valid
  69869. * @returns a boolean
  69870. */
  69871. isValid(): boolean;
  69872. /**
  69873. * Internal only
  69874. * @hidden
  69875. */
  69876. _getProperty(propertyPath: string): string;
  69877. /**
  69878. * Internal only
  69879. * @hidden
  69880. */
  69881. _getEffectiveTarget(target: any, propertyPath: string): any;
  69882. /**
  69883. * Serialize placeholder for child classes
  69884. * @returns the serialized object
  69885. */
  69886. serialize(): any;
  69887. /**
  69888. * Internal only
  69889. * @hidden
  69890. */
  69891. protected _serialize(serializedCondition: any): any;
  69892. }
  69893. /**
  69894. * Defines specific conditional operators as extensions of Condition
  69895. */
  69896. export class ValueCondition extends Condition {
  69897. /** path to specify the property of the target the conditional operator uses */
  69898. propertyPath: string;
  69899. /** the value compared by the conditional operator against the current value of the property */
  69900. value: any;
  69901. /** the conditional operator, default ValueCondition.IsEqual */
  69902. operator: number;
  69903. /**
  69904. * Internal only
  69905. * @hidden
  69906. */
  69907. private static _IsEqual;
  69908. /**
  69909. * Internal only
  69910. * @hidden
  69911. */
  69912. private static _IsDifferent;
  69913. /**
  69914. * Internal only
  69915. * @hidden
  69916. */
  69917. private static _IsGreater;
  69918. /**
  69919. * Internal only
  69920. * @hidden
  69921. */
  69922. private static _IsLesser;
  69923. /**
  69924. * returns the number for IsEqual
  69925. */
  69926. static readonly IsEqual: number;
  69927. /**
  69928. * Returns the number for IsDifferent
  69929. */
  69930. static readonly IsDifferent: number;
  69931. /**
  69932. * Returns the number for IsGreater
  69933. */
  69934. static readonly IsGreater: number;
  69935. /**
  69936. * Returns the number for IsLesser
  69937. */
  69938. static readonly IsLesser: number;
  69939. /**
  69940. * Internal only The action manager for the condition
  69941. * @hidden
  69942. */
  69943. _actionManager: ActionManager;
  69944. /**
  69945. * Internal only
  69946. * @hidden
  69947. */
  69948. private _target;
  69949. /**
  69950. * Internal only
  69951. * @hidden
  69952. */
  69953. private _effectiveTarget;
  69954. /**
  69955. * Internal only
  69956. * @hidden
  69957. */
  69958. private _property;
  69959. /**
  69960. * Creates a new ValueCondition
  69961. * @param actionManager manager for the action the condition applies to
  69962. * @param target for the action
  69963. * @param propertyPath path to specify the property of the target the conditional operator uses
  69964. * @param value the value compared by the conditional operator against the current value of the property
  69965. * @param operator the conditional operator, default ValueCondition.IsEqual
  69966. */
  69967. constructor(actionManager: ActionManager, target: any,
  69968. /** path to specify the property of the target the conditional operator uses */
  69969. propertyPath: string,
  69970. /** the value compared by the conditional operator against the current value of the property */
  69971. value: any,
  69972. /** the conditional operator, default ValueCondition.IsEqual */
  69973. operator?: number);
  69974. /**
  69975. * Compares the given value with the property value for the specified conditional operator
  69976. * @returns the result of the comparison
  69977. */
  69978. isValid(): boolean;
  69979. /**
  69980. * Serialize the ValueCondition into a JSON compatible object
  69981. * @returns serialization object
  69982. */
  69983. serialize(): any;
  69984. /**
  69985. * Gets the name of the conditional operator for the ValueCondition
  69986. * @param operator the conditional operator
  69987. * @returns the name
  69988. */
  69989. static GetOperatorName(operator: number): string;
  69990. }
  69991. /**
  69992. * Defines a predicate condition as an extension of Condition
  69993. */
  69994. export class PredicateCondition extends Condition {
  69995. /** defines the predicate function used to validate the condition */
  69996. predicate: () => boolean;
  69997. /**
  69998. * Internal only - manager for action
  69999. * @hidden
  70000. */
  70001. _actionManager: ActionManager;
  70002. /**
  70003. * Creates a new PredicateCondition
  70004. * @param actionManager manager for the action the condition applies to
  70005. * @param predicate defines the predicate function used to validate the condition
  70006. */
  70007. constructor(actionManager: ActionManager,
  70008. /** defines the predicate function used to validate the condition */
  70009. predicate: () => boolean);
  70010. /**
  70011. * @returns the validity of the predicate condition
  70012. */
  70013. isValid(): boolean;
  70014. }
  70015. /**
  70016. * Defines a state condition as an extension of Condition
  70017. */
  70018. export class StateCondition extends Condition {
  70019. /** Value to compare with target state */
  70020. value: string;
  70021. /**
  70022. * Internal only - manager for action
  70023. * @hidden
  70024. */
  70025. _actionManager: ActionManager;
  70026. /**
  70027. * Internal only
  70028. * @hidden
  70029. */
  70030. private _target;
  70031. /**
  70032. * Creates a new StateCondition
  70033. * @param actionManager manager for the action the condition applies to
  70034. * @param target of the condition
  70035. * @param value to compare with target state
  70036. */
  70037. constructor(actionManager: ActionManager, target: any,
  70038. /** Value to compare with target state */
  70039. value: string);
  70040. /**
  70041. * Gets a boolean indicating if the current condition is met
  70042. * @returns the validity of the state
  70043. */
  70044. isValid(): boolean;
  70045. /**
  70046. * Serialize the StateCondition into a JSON compatible object
  70047. * @returns serialization object
  70048. */
  70049. serialize(): any;
  70050. }
  70051. }
  70052. declare module BABYLON {
  70053. /**
  70054. * This defines an action responsible to toggle a boolean once triggered.
  70055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70056. */
  70057. export class SwitchBooleanAction extends Action {
  70058. /**
  70059. * The path to the boolean property in the target object
  70060. */
  70061. propertyPath: string;
  70062. private _target;
  70063. private _effectiveTarget;
  70064. private _property;
  70065. /**
  70066. * Instantiate the action
  70067. * @param triggerOptions defines the trigger options
  70068. * @param target defines the object containing the boolean
  70069. * @param propertyPath defines the path to the boolean property in the target object
  70070. * @param condition defines the trigger related conditions
  70071. */
  70072. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70073. /** @hidden */
  70074. _prepare(): void;
  70075. /**
  70076. * Execute the action toggle the boolean value.
  70077. */
  70078. execute(): void;
  70079. /**
  70080. * Serializes the actions and its related information.
  70081. * @param parent defines the object to serialize in
  70082. * @returns the serialized object
  70083. */
  70084. serialize(parent: any): any;
  70085. }
  70086. /**
  70087. * This defines an action responsible to set a the state field of the target
  70088. * to a desired value once triggered.
  70089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70090. */
  70091. export class SetStateAction extends Action {
  70092. /**
  70093. * The value to store in the state field.
  70094. */
  70095. value: string;
  70096. private _target;
  70097. /**
  70098. * Instantiate the action
  70099. * @param triggerOptions defines the trigger options
  70100. * @param target defines the object containing the state property
  70101. * @param value defines the value to store in the state field
  70102. * @param condition defines the trigger related conditions
  70103. */
  70104. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70105. /**
  70106. * Execute the action and store the value on the target state property.
  70107. */
  70108. execute(): void;
  70109. /**
  70110. * Serializes the actions and its related information.
  70111. * @param parent defines the object to serialize in
  70112. * @returns the serialized object
  70113. */
  70114. serialize(parent: any): any;
  70115. }
  70116. /**
  70117. * This defines an action responsible to set a property of the target
  70118. * to a desired value once triggered.
  70119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70120. */
  70121. export class SetValueAction extends Action {
  70122. /**
  70123. * The path of the property to set in the target.
  70124. */
  70125. propertyPath: string;
  70126. /**
  70127. * The value to set in the property
  70128. */
  70129. value: any;
  70130. private _target;
  70131. private _effectiveTarget;
  70132. private _property;
  70133. /**
  70134. * Instantiate the action
  70135. * @param triggerOptions defines the trigger options
  70136. * @param target defines the object containing the property
  70137. * @param propertyPath defines the path of the property to set in the target
  70138. * @param value defines the value to set in the property
  70139. * @param condition defines the trigger related conditions
  70140. */
  70141. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70142. /** @hidden */
  70143. _prepare(): void;
  70144. /**
  70145. * Execute the action and set the targetted property to the desired value.
  70146. */
  70147. execute(): void;
  70148. /**
  70149. * Serializes the actions and its related information.
  70150. * @param parent defines the object to serialize in
  70151. * @returns the serialized object
  70152. */
  70153. serialize(parent: any): any;
  70154. }
  70155. /**
  70156. * This defines an action responsible to increment the target value
  70157. * to a desired value once triggered.
  70158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70159. */
  70160. export class IncrementValueAction extends Action {
  70161. /**
  70162. * The path of the property to increment in the target.
  70163. */
  70164. propertyPath: string;
  70165. /**
  70166. * The value we should increment the property by.
  70167. */
  70168. value: any;
  70169. private _target;
  70170. private _effectiveTarget;
  70171. private _property;
  70172. /**
  70173. * Instantiate the action
  70174. * @param triggerOptions defines the trigger options
  70175. * @param target defines the object containing the property
  70176. * @param propertyPath defines the path of the property to increment in the target
  70177. * @param value defines the value value we should increment the property by
  70178. * @param condition defines the trigger related conditions
  70179. */
  70180. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70181. /** @hidden */
  70182. _prepare(): void;
  70183. /**
  70184. * Execute the action and increment the target of the value amount.
  70185. */
  70186. execute(): void;
  70187. /**
  70188. * Serializes the actions and its related information.
  70189. * @param parent defines the object to serialize in
  70190. * @returns the serialized object
  70191. */
  70192. serialize(parent: any): any;
  70193. }
  70194. /**
  70195. * This defines an action responsible to start an animation once triggered.
  70196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70197. */
  70198. export class PlayAnimationAction extends Action {
  70199. /**
  70200. * Where the animation should start (animation frame)
  70201. */
  70202. from: number;
  70203. /**
  70204. * Where the animation should stop (animation frame)
  70205. */
  70206. to: number;
  70207. /**
  70208. * Define if the animation should loop or stop after the first play.
  70209. */
  70210. loop?: boolean;
  70211. private _target;
  70212. /**
  70213. * Instantiate the action
  70214. * @param triggerOptions defines the trigger options
  70215. * @param target defines the target animation or animation name
  70216. * @param from defines from where the animation should start (animation frame)
  70217. * @param end defines where the animation should stop (animation frame)
  70218. * @param loop defines if the animation should loop or stop after the first play
  70219. * @param condition defines the trigger related conditions
  70220. */
  70221. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70222. /** @hidden */
  70223. _prepare(): void;
  70224. /**
  70225. * Execute the action and play the animation.
  70226. */
  70227. execute(): void;
  70228. /**
  70229. * Serializes the actions and its related information.
  70230. * @param parent defines the object to serialize in
  70231. * @returns the serialized object
  70232. */
  70233. serialize(parent: any): any;
  70234. }
  70235. /**
  70236. * This defines an action responsible to stop an animation once triggered.
  70237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70238. */
  70239. export class StopAnimationAction extends Action {
  70240. private _target;
  70241. /**
  70242. * Instantiate the action
  70243. * @param triggerOptions defines the trigger options
  70244. * @param target defines the target animation or animation name
  70245. * @param condition defines the trigger related conditions
  70246. */
  70247. constructor(triggerOptions: any, target: any, condition?: Condition);
  70248. /** @hidden */
  70249. _prepare(): void;
  70250. /**
  70251. * Execute the action and stop the animation.
  70252. */
  70253. execute(): void;
  70254. /**
  70255. * Serializes the actions and its related information.
  70256. * @param parent defines the object to serialize in
  70257. * @returns the serialized object
  70258. */
  70259. serialize(parent: any): any;
  70260. }
  70261. /**
  70262. * This defines an action responsible that does nothing once triggered.
  70263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70264. */
  70265. export class DoNothingAction extends Action {
  70266. /**
  70267. * Instantiate the action
  70268. * @param triggerOptions defines the trigger options
  70269. * @param condition defines the trigger related conditions
  70270. */
  70271. constructor(triggerOptions?: any, condition?: Condition);
  70272. /**
  70273. * Execute the action and do nothing.
  70274. */
  70275. execute(): void;
  70276. /**
  70277. * Serializes the actions and its related information.
  70278. * @param parent defines the object to serialize in
  70279. * @returns the serialized object
  70280. */
  70281. serialize(parent: any): any;
  70282. }
  70283. /**
  70284. * This defines an action responsible to trigger several actions once triggered.
  70285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70286. */
  70287. export class CombineAction extends Action {
  70288. /**
  70289. * The list of aggregated animations to run.
  70290. */
  70291. children: Action[];
  70292. /**
  70293. * Instantiate the action
  70294. * @param triggerOptions defines the trigger options
  70295. * @param children defines the list of aggregated animations to run
  70296. * @param condition defines the trigger related conditions
  70297. */
  70298. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  70299. /** @hidden */
  70300. _prepare(): void;
  70301. /**
  70302. * Execute the action and executes all the aggregated actions.
  70303. */
  70304. execute(evt: ActionEvent): void;
  70305. /**
  70306. * Serializes the actions and its related information.
  70307. * @param parent defines the object to serialize in
  70308. * @returns the serialized object
  70309. */
  70310. serialize(parent: any): any;
  70311. }
  70312. /**
  70313. * This defines an action responsible to run code (external event) once triggered.
  70314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70315. */
  70316. export class ExecuteCodeAction extends Action {
  70317. /**
  70318. * The callback function to run.
  70319. */
  70320. func: (evt: ActionEvent) => void;
  70321. /**
  70322. * Instantiate the action
  70323. * @param triggerOptions defines the trigger options
  70324. * @param func defines the callback function to run
  70325. * @param condition defines the trigger related conditions
  70326. */
  70327. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  70328. /**
  70329. * Execute the action and run the attached code.
  70330. */
  70331. execute(evt: ActionEvent): void;
  70332. }
  70333. /**
  70334. * This defines an action responsible to set the parent property of the target once triggered.
  70335. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70336. */
  70337. export class SetParentAction extends Action {
  70338. private _parent;
  70339. private _target;
  70340. /**
  70341. * Instantiate the action
  70342. * @param triggerOptions defines the trigger options
  70343. * @param target defines the target containing the parent property
  70344. * @param parent defines from where the animation should start (animation frame)
  70345. * @param condition defines the trigger related conditions
  70346. */
  70347. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  70348. /** @hidden */
  70349. _prepare(): void;
  70350. /**
  70351. * Execute the action and set the parent property.
  70352. */
  70353. execute(): void;
  70354. /**
  70355. * Serializes the actions and its related information.
  70356. * @param parent defines the object to serialize in
  70357. * @returns the serialized object
  70358. */
  70359. serialize(parent: any): any;
  70360. }
  70361. }
  70362. declare module BABYLON {
  70363. /**
  70364. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  70365. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  70366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70367. */
  70368. export class ActionManager extends AbstractActionManager {
  70369. /**
  70370. * Nothing
  70371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70372. */
  70373. static readonly NothingTrigger: number;
  70374. /**
  70375. * On pick
  70376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70377. */
  70378. static readonly OnPickTrigger: number;
  70379. /**
  70380. * On left pick
  70381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70382. */
  70383. static readonly OnLeftPickTrigger: number;
  70384. /**
  70385. * On right pick
  70386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70387. */
  70388. static readonly OnRightPickTrigger: number;
  70389. /**
  70390. * On center pick
  70391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70392. */
  70393. static readonly OnCenterPickTrigger: number;
  70394. /**
  70395. * On pick down
  70396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70397. */
  70398. static readonly OnPickDownTrigger: number;
  70399. /**
  70400. * On double pick
  70401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70402. */
  70403. static readonly OnDoublePickTrigger: number;
  70404. /**
  70405. * On pick up
  70406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70407. */
  70408. static readonly OnPickUpTrigger: number;
  70409. /**
  70410. * On pick out.
  70411. * This trigger will only be raised if you also declared a OnPickDown
  70412. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70413. */
  70414. static readonly OnPickOutTrigger: number;
  70415. /**
  70416. * On long press
  70417. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70418. */
  70419. static readonly OnLongPressTrigger: number;
  70420. /**
  70421. * On pointer over
  70422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70423. */
  70424. static readonly OnPointerOverTrigger: number;
  70425. /**
  70426. * On pointer out
  70427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70428. */
  70429. static readonly OnPointerOutTrigger: number;
  70430. /**
  70431. * On every frame
  70432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70433. */
  70434. static readonly OnEveryFrameTrigger: number;
  70435. /**
  70436. * On intersection enter
  70437. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70438. */
  70439. static readonly OnIntersectionEnterTrigger: number;
  70440. /**
  70441. * On intersection exit
  70442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70443. */
  70444. static readonly OnIntersectionExitTrigger: number;
  70445. /**
  70446. * On key down
  70447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70448. */
  70449. static readonly OnKeyDownTrigger: number;
  70450. /**
  70451. * On key up
  70452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70453. */
  70454. static readonly OnKeyUpTrigger: number;
  70455. private _scene;
  70456. /**
  70457. * Creates a new action manager
  70458. * @param scene defines the hosting scene
  70459. */
  70460. constructor(scene: Scene);
  70461. /**
  70462. * Releases all associated resources
  70463. */
  70464. dispose(): void;
  70465. /**
  70466. * Gets hosting scene
  70467. * @returns the hosting scene
  70468. */
  70469. getScene(): Scene;
  70470. /**
  70471. * Does this action manager handles actions of any of the given triggers
  70472. * @param triggers defines the triggers to be tested
  70473. * @return a boolean indicating whether one (or more) of the triggers is handled
  70474. */
  70475. hasSpecificTriggers(triggers: number[]): boolean;
  70476. /**
  70477. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  70478. * speed.
  70479. * @param triggerA defines the trigger to be tested
  70480. * @param triggerB defines the trigger to be tested
  70481. * @return a boolean indicating whether one (or more) of the triggers is handled
  70482. */
  70483. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  70484. /**
  70485. * Does this action manager handles actions of a given trigger
  70486. * @param trigger defines the trigger to be tested
  70487. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  70488. * @return whether the trigger is handled
  70489. */
  70490. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  70491. /**
  70492. * Does this action manager has pointer triggers
  70493. */
  70494. readonly hasPointerTriggers: boolean;
  70495. /**
  70496. * Does this action manager has pick triggers
  70497. */
  70498. readonly hasPickTriggers: boolean;
  70499. /**
  70500. * Registers an action to this action manager
  70501. * @param action defines the action to be registered
  70502. * @return the action amended (prepared) after registration
  70503. */
  70504. registerAction(action: IAction): Nullable<IAction>;
  70505. /**
  70506. * Unregisters an action to this action manager
  70507. * @param action defines the action to be unregistered
  70508. * @return a boolean indicating whether the action has been unregistered
  70509. */
  70510. unregisterAction(action: IAction): Boolean;
  70511. /**
  70512. * Process a specific trigger
  70513. * @param trigger defines the trigger to process
  70514. * @param evt defines the event details to be processed
  70515. */
  70516. processTrigger(trigger: number, evt?: IActionEvent): void;
  70517. /** @hidden */
  70518. _getEffectiveTarget(target: any, propertyPath: string): any;
  70519. /** @hidden */
  70520. _getProperty(propertyPath: string): string;
  70521. /**
  70522. * Serialize this manager to a JSON object
  70523. * @param name defines the property name to store this manager
  70524. * @returns a JSON representation of this manager
  70525. */
  70526. serialize(name: string): any;
  70527. /**
  70528. * Creates a new ActionManager from a JSON data
  70529. * @param parsedActions defines the JSON data to read from
  70530. * @param object defines the hosting mesh
  70531. * @param scene defines the hosting scene
  70532. */
  70533. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  70534. /**
  70535. * Get a trigger name by index
  70536. * @param trigger defines the trigger index
  70537. * @returns a trigger name
  70538. */
  70539. static GetTriggerName(trigger: number): string;
  70540. }
  70541. }
  70542. declare module BABYLON {
  70543. /**
  70544. * Class representing a ray with position and direction
  70545. */
  70546. export class Ray {
  70547. /** origin point */
  70548. origin: Vector3;
  70549. /** direction */
  70550. direction: Vector3;
  70551. /** length of the ray */
  70552. length: number;
  70553. private static readonly TmpVector3;
  70554. private _tmpRay;
  70555. /**
  70556. * Creates a new ray
  70557. * @param origin origin point
  70558. * @param direction direction
  70559. * @param length length of the ray
  70560. */
  70561. constructor(
  70562. /** origin point */
  70563. origin: Vector3,
  70564. /** direction */
  70565. direction: Vector3,
  70566. /** length of the ray */
  70567. length?: number);
  70568. /**
  70569. * Checks if the ray intersects a box
  70570. * @param minimum bound of the box
  70571. * @param maximum bound of the box
  70572. * @param intersectionTreshold extra extend to be added to the box in all direction
  70573. * @returns if the box was hit
  70574. */
  70575. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  70576. /**
  70577. * Checks if the ray intersects a box
  70578. * @param box the bounding box to check
  70579. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  70580. * @returns if the box was hit
  70581. */
  70582. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  70583. /**
  70584. * If the ray hits a sphere
  70585. * @param sphere the bounding sphere to check
  70586. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  70587. * @returns true if it hits the sphere
  70588. */
  70589. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  70590. /**
  70591. * If the ray hits a triange
  70592. * @param vertex0 triangle vertex
  70593. * @param vertex1 triangle vertex
  70594. * @param vertex2 triangle vertex
  70595. * @returns intersection information if hit
  70596. */
  70597. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  70598. /**
  70599. * Checks if ray intersects a plane
  70600. * @param plane the plane to check
  70601. * @returns the distance away it was hit
  70602. */
  70603. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  70604. /**
  70605. * Checks if ray intersects a mesh
  70606. * @param mesh the mesh to check
  70607. * @param fastCheck if only the bounding box should checked
  70608. * @returns picking info of the intersecton
  70609. */
  70610. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  70611. /**
  70612. * Checks if ray intersects a mesh
  70613. * @param meshes the meshes to check
  70614. * @param fastCheck if only the bounding box should checked
  70615. * @param results array to store result in
  70616. * @returns Array of picking infos
  70617. */
  70618. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  70619. private _comparePickingInfo;
  70620. private static smallnum;
  70621. private static rayl;
  70622. /**
  70623. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  70624. * @param sega the first point of the segment to test the intersection against
  70625. * @param segb the second point of the segment to test the intersection against
  70626. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  70627. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  70628. */
  70629. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  70630. /**
  70631. * Update the ray from viewport position
  70632. * @param x position
  70633. * @param y y position
  70634. * @param viewportWidth viewport width
  70635. * @param viewportHeight viewport height
  70636. * @param world world matrix
  70637. * @param view view matrix
  70638. * @param projection projection matrix
  70639. * @returns this ray updated
  70640. */
  70641. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70642. /**
  70643. * Creates a ray with origin and direction of 0,0,0
  70644. * @returns the new ray
  70645. */
  70646. static Zero(): Ray;
  70647. /**
  70648. * Creates a new ray from screen space and viewport
  70649. * @param x position
  70650. * @param y y position
  70651. * @param viewportWidth viewport width
  70652. * @param viewportHeight viewport height
  70653. * @param world world matrix
  70654. * @param view view matrix
  70655. * @param projection projection matrix
  70656. * @returns new ray
  70657. */
  70658. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70659. /**
  70660. * 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
  70661. * transformed to the given world matrix.
  70662. * @param origin The origin point
  70663. * @param end The end point
  70664. * @param world a matrix to transform the ray to. Default is the identity matrix.
  70665. * @returns the new ray
  70666. */
  70667. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  70668. /**
  70669. * Transforms a ray by a matrix
  70670. * @param ray ray to transform
  70671. * @param matrix matrix to apply
  70672. * @returns the resulting new ray
  70673. */
  70674. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  70675. /**
  70676. * Transforms a ray by a matrix
  70677. * @param ray ray to transform
  70678. * @param matrix matrix to apply
  70679. * @param result ray to store result in
  70680. */
  70681. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  70682. /**
  70683. * Unproject a ray from screen space to object space
  70684. * @param sourceX defines the screen space x coordinate to use
  70685. * @param sourceY defines the screen space y coordinate to use
  70686. * @param viewportWidth defines the current width of the viewport
  70687. * @param viewportHeight defines the current height of the viewport
  70688. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70689. * @param view defines the view matrix to use
  70690. * @param projection defines the projection matrix to use
  70691. */
  70692. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  70693. }
  70694. /**
  70695. * Type used to define predicate used to select faces when a mesh intersection is detected
  70696. */
  70697. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  70698. interface Scene {
  70699. /** @hidden */
  70700. _tempPickingRay: Nullable<Ray>;
  70701. /** @hidden */
  70702. _cachedRayForTransform: Ray;
  70703. /** @hidden */
  70704. _pickWithRayInverseMatrix: Matrix;
  70705. /** @hidden */
  70706. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  70707. /** @hidden */
  70708. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  70709. }
  70710. }
  70711. declare module BABYLON {
  70712. /**
  70713. * Groups all the scene component constants in one place to ease maintenance.
  70714. * @hidden
  70715. */
  70716. export class SceneComponentConstants {
  70717. static readonly NAME_EFFECTLAYER: string;
  70718. static readonly NAME_LAYER: string;
  70719. static readonly NAME_LENSFLARESYSTEM: string;
  70720. static readonly NAME_BOUNDINGBOXRENDERER: string;
  70721. static readonly NAME_PARTICLESYSTEM: string;
  70722. static readonly NAME_GAMEPAD: string;
  70723. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  70724. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  70725. static readonly NAME_DEPTHRENDERER: string;
  70726. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  70727. static readonly NAME_SPRITE: string;
  70728. static readonly NAME_OUTLINERENDERER: string;
  70729. static readonly NAME_PROCEDURALTEXTURE: string;
  70730. static readonly NAME_SHADOWGENERATOR: string;
  70731. static readonly NAME_OCTREE: string;
  70732. static readonly NAME_PHYSICSENGINE: string;
  70733. static readonly NAME_AUDIO: string;
  70734. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  70735. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70736. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  70737. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70738. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  70739. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  70740. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  70741. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  70742. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  70743. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  70744. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  70745. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  70746. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  70747. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  70748. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  70749. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  70750. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  70751. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  70752. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  70753. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  70754. static readonly STEP_AFTERRENDER_AUDIO: number;
  70755. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  70756. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  70757. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  70758. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  70759. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  70760. static readonly STEP_POINTERMOVE_SPRITE: number;
  70761. static readonly STEP_POINTERDOWN_SPRITE: number;
  70762. static readonly STEP_POINTERUP_SPRITE: number;
  70763. }
  70764. /**
  70765. * This represents a scene component.
  70766. *
  70767. * This is used to decouple the dependency the scene is having on the different workloads like
  70768. * layers, post processes...
  70769. */
  70770. export interface ISceneComponent {
  70771. /**
  70772. * The name of the component. Each component must have a unique name.
  70773. */
  70774. name: string;
  70775. /**
  70776. * The scene the component belongs to.
  70777. */
  70778. scene: Scene;
  70779. /**
  70780. * Register the component to one instance of a scene.
  70781. */
  70782. register(): void;
  70783. /**
  70784. * Rebuilds the elements related to this component in case of
  70785. * context lost for instance.
  70786. */
  70787. rebuild(): void;
  70788. /**
  70789. * Disposes the component and the associated ressources.
  70790. */
  70791. dispose(): void;
  70792. }
  70793. /**
  70794. * This represents a SERIALIZABLE scene component.
  70795. *
  70796. * This extends Scene Component to add Serialization methods on top.
  70797. */
  70798. export interface ISceneSerializableComponent extends ISceneComponent {
  70799. /**
  70800. * Adds all the element from the container to the scene
  70801. * @param container the container holding the elements
  70802. */
  70803. addFromContainer(container: AbstractScene): void;
  70804. /**
  70805. * Removes all the elements in the container from the scene
  70806. * @param container contains the elements to remove
  70807. * @param dispose if the removed element should be disposed (default: false)
  70808. */
  70809. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  70810. /**
  70811. * Serializes the component data to the specified json object
  70812. * @param serializationObject The object to serialize to
  70813. */
  70814. serialize(serializationObject: any): void;
  70815. }
  70816. /**
  70817. * Strong typing of a Mesh related stage step action
  70818. */
  70819. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  70820. /**
  70821. * Strong typing of a Evaluate Sub Mesh related stage step action
  70822. */
  70823. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  70824. /**
  70825. * Strong typing of a Active Mesh related stage step action
  70826. */
  70827. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  70828. /**
  70829. * Strong typing of a Camera related stage step action
  70830. */
  70831. export type CameraStageAction = (camera: Camera) => void;
  70832. /**
  70833. * Strong typing of a Render Target related stage step action
  70834. */
  70835. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  70836. /**
  70837. * Strong typing of a RenderingGroup related stage step action
  70838. */
  70839. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  70840. /**
  70841. * Strong typing of a Mesh Render related stage step action
  70842. */
  70843. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  70844. /**
  70845. * Strong typing of a simple stage step action
  70846. */
  70847. export type SimpleStageAction = () => void;
  70848. /**
  70849. * Strong typing of a render target action.
  70850. */
  70851. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  70852. /**
  70853. * Strong typing of a pointer move action.
  70854. */
  70855. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  70856. /**
  70857. * Strong typing of a pointer up/down action.
  70858. */
  70859. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  70860. /**
  70861. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  70862. * @hidden
  70863. */
  70864. export class Stage<T extends Function> extends Array<{
  70865. index: number;
  70866. component: ISceneComponent;
  70867. action: T;
  70868. }> {
  70869. /**
  70870. * Hide ctor from the rest of the world.
  70871. * @param items The items to add.
  70872. */
  70873. private constructor();
  70874. /**
  70875. * Creates a new Stage.
  70876. * @returns A new instance of a Stage
  70877. */
  70878. static Create<T extends Function>(): Stage<T>;
  70879. /**
  70880. * Registers a step in an ordered way in the targeted stage.
  70881. * @param index Defines the position to register the step in
  70882. * @param component Defines the component attached to the step
  70883. * @param action Defines the action to launch during the step
  70884. */
  70885. registerStep(index: number, component: ISceneComponent, action: T): void;
  70886. /**
  70887. * Clears all the steps from the stage.
  70888. */
  70889. clear(): void;
  70890. }
  70891. }
  70892. declare module BABYLON {
  70893. interface Scene {
  70894. /** @hidden */
  70895. _pointerOverSprite: Nullable<Sprite>;
  70896. /** @hidden */
  70897. _pickedDownSprite: Nullable<Sprite>;
  70898. /** @hidden */
  70899. _tempSpritePickingRay: Nullable<Ray>;
  70900. /**
  70901. * All of the sprite managers added to this scene
  70902. * @see http://doc.babylonjs.com/babylon101/sprites
  70903. */
  70904. spriteManagers: Array<ISpriteManager>;
  70905. /**
  70906. * An event triggered when sprites rendering is about to start
  70907. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70908. */
  70909. onBeforeSpritesRenderingObservable: Observable<Scene>;
  70910. /**
  70911. * An event triggered when sprites rendering is done
  70912. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70913. */
  70914. onAfterSpritesRenderingObservable: Observable<Scene>;
  70915. /** @hidden */
  70916. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70917. /** Launch a ray to try to pick a sprite in the scene
  70918. * @param x position on screen
  70919. * @param y position on screen
  70920. * @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
  70921. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70922. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  70923. * @returns a PickingInfo
  70924. */
  70925. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70926. /** Use the given ray to pick a sprite in the scene
  70927. * @param ray The ray (in world space) to use to pick meshes
  70928. * @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
  70929. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70930. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  70931. * @returns a PickingInfo
  70932. */
  70933. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70934. /**
  70935. * Force the sprite under the pointer
  70936. * @param sprite defines the sprite to use
  70937. */
  70938. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  70939. /**
  70940. * Gets the sprite under the pointer
  70941. * @returns a Sprite or null if no sprite is under the pointer
  70942. */
  70943. getPointerOverSprite(): Nullable<Sprite>;
  70944. }
  70945. /**
  70946. * Defines the sprite scene component responsible to manage sprites
  70947. * in a given scene.
  70948. */
  70949. export class SpriteSceneComponent implements ISceneComponent {
  70950. /**
  70951. * The component name helpfull to identify the component in the list of scene components.
  70952. */
  70953. readonly name: string;
  70954. /**
  70955. * The scene the component belongs to.
  70956. */
  70957. scene: Scene;
  70958. /** @hidden */
  70959. private _spritePredicate;
  70960. /**
  70961. * Creates a new instance of the component for the given scene
  70962. * @param scene Defines the scene to register the component in
  70963. */
  70964. constructor(scene: Scene);
  70965. /**
  70966. * Registers the component in a given scene
  70967. */
  70968. register(): void;
  70969. /**
  70970. * Rebuilds the elements related to this component in case of
  70971. * context lost for instance.
  70972. */
  70973. rebuild(): void;
  70974. /**
  70975. * Disposes the component and the associated ressources.
  70976. */
  70977. dispose(): void;
  70978. private _pickSpriteButKeepRay;
  70979. private _pointerMove;
  70980. private _pointerDown;
  70981. private _pointerUp;
  70982. }
  70983. }
  70984. declare module BABYLON {
  70985. /** @hidden */
  70986. export var fogFragmentDeclaration: {
  70987. name: string;
  70988. shader: string;
  70989. };
  70990. }
  70991. declare module BABYLON {
  70992. /** @hidden */
  70993. export var fogFragment: {
  70994. name: string;
  70995. shader: string;
  70996. };
  70997. }
  70998. declare module BABYLON {
  70999. /** @hidden */
  71000. export var spritesPixelShader: {
  71001. name: string;
  71002. shader: string;
  71003. };
  71004. }
  71005. declare module BABYLON {
  71006. /** @hidden */
  71007. export var fogVertexDeclaration: {
  71008. name: string;
  71009. shader: string;
  71010. };
  71011. }
  71012. declare module BABYLON {
  71013. /** @hidden */
  71014. export var spritesVertexShader: {
  71015. name: string;
  71016. shader: string;
  71017. };
  71018. }
  71019. declare module BABYLON {
  71020. /**
  71021. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71022. */
  71023. export interface ISpriteManager extends IDisposable {
  71024. /**
  71025. * Restricts the camera to viewing objects with the same layerMask.
  71026. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71027. */
  71028. layerMask: number;
  71029. /**
  71030. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71031. */
  71032. isPickable: boolean;
  71033. /**
  71034. * Specifies the rendering group id for this mesh (0 by default)
  71035. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71036. */
  71037. renderingGroupId: number;
  71038. /**
  71039. * Defines the list of sprites managed by the manager.
  71040. */
  71041. sprites: Array<Sprite>;
  71042. /**
  71043. * Tests the intersection of a sprite with a specific ray.
  71044. * @param ray The ray we are sending to test the collision
  71045. * @param camera The camera space we are sending rays in
  71046. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71047. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71048. * @returns picking info or null.
  71049. */
  71050. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71051. /**
  71052. * Renders the list of sprites on screen.
  71053. */
  71054. render(): void;
  71055. }
  71056. /**
  71057. * Class used to manage multiple sprites on the same spritesheet
  71058. * @see http://doc.babylonjs.com/babylon101/sprites
  71059. */
  71060. export class SpriteManager implements ISpriteManager {
  71061. /** defines the manager's name */
  71062. name: string;
  71063. /** Gets the list of sprites */
  71064. sprites: Sprite[];
  71065. /** Gets or sets the rendering group id (0 by default) */
  71066. renderingGroupId: number;
  71067. /** Gets or sets camera layer mask */
  71068. layerMask: number;
  71069. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71070. fogEnabled: boolean;
  71071. /** Gets or sets a boolean indicating if the sprites are pickable */
  71072. isPickable: boolean;
  71073. /** Defines the default width of a cell in the spritesheet */
  71074. cellWidth: number;
  71075. /** Defines the default height of a cell in the spritesheet */
  71076. cellHeight: number;
  71077. /**
  71078. * An event triggered when the manager is disposed.
  71079. */
  71080. onDisposeObservable: Observable<SpriteManager>;
  71081. private _onDisposeObserver;
  71082. /**
  71083. * Callback called when the manager is disposed
  71084. */
  71085. onDispose: () => void;
  71086. private _capacity;
  71087. private _spriteTexture;
  71088. private _epsilon;
  71089. private _scene;
  71090. private _vertexData;
  71091. private _buffer;
  71092. private _vertexBuffers;
  71093. private _indexBuffer;
  71094. private _effectBase;
  71095. private _effectFog;
  71096. /**
  71097. * Gets or sets the spritesheet texture
  71098. */
  71099. texture: Texture;
  71100. /**
  71101. * Creates a new sprite manager
  71102. * @param name defines the manager's name
  71103. * @param imgUrl defines the sprite sheet url
  71104. * @param capacity defines the maximum allowed number of sprites
  71105. * @param cellSize defines the size of a sprite cell
  71106. * @param scene defines the hosting scene
  71107. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71108. * @param samplingMode defines the smapling mode to use with spritesheet
  71109. */
  71110. constructor(
  71111. /** defines the manager's name */
  71112. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71113. private _appendSpriteVertex;
  71114. /**
  71115. * Intersects the sprites with a ray
  71116. * @param ray defines the ray to intersect with
  71117. * @param camera defines the current active camera
  71118. * @param predicate defines a predicate used to select candidate sprites
  71119. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71120. * @returns null if no hit or a PickingInfo
  71121. */
  71122. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71123. /**
  71124. * Render all child sprites
  71125. */
  71126. render(): void;
  71127. /**
  71128. * Release associated resources
  71129. */
  71130. dispose(): void;
  71131. }
  71132. }
  71133. declare module BABYLON {
  71134. /**
  71135. * Class used to represent a sprite
  71136. * @see http://doc.babylonjs.com/babylon101/sprites
  71137. */
  71138. export class Sprite {
  71139. /** defines the name */
  71140. name: string;
  71141. /** Gets or sets the current world position */
  71142. position: Vector3;
  71143. /** Gets or sets the main color */
  71144. color: Color4;
  71145. /** Gets or sets the width */
  71146. width: number;
  71147. /** Gets or sets the height */
  71148. height: number;
  71149. /** Gets or sets rotation angle */
  71150. angle: number;
  71151. /** Gets or sets the cell index in the sprite sheet */
  71152. cellIndex: number;
  71153. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71154. invertU: number;
  71155. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71156. invertV: number;
  71157. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71158. disposeWhenFinishedAnimating: boolean;
  71159. /** Gets the list of attached animations */
  71160. animations: Animation[];
  71161. /** Gets or sets a boolean indicating if the sprite can be picked */
  71162. isPickable: boolean;
  71163. /**
  71164. * Gets or sets the associated action manager
  71165. */
  71166. actionManager: Nullable<ActionManager>;
  71167. private _animationStarted;
  71168. private _loopAnimation;
  71169. private _fromIndex;
  71170. private _toIndex;
  71171. private _delay;
  71172. private _direction;
  71173. private _manager;
  71174. private _time;
  71175. private _onAnimationEnd;
  71176. /**
  71177. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71178. */
  71179. isVisible: boolean;
  71180. /**
  71181. * Gets or sets the sprite size
  71182. */
  71183. size: number;
  71184. /**
  71185. * Creates a new Sprite
  71186. * @param name defines the name
  71187. * @param manager defines the manager
  71188. */
  71189. constructor(
  71190. /** defines the name */
  71191. name: string, manager: ISpriteManager);
  71192. /**
  71193. * Starts an animation
  71194. * @param from defines the initial key
  71195. * @param to defines the end key
  71196. * @param loop defines if the animation must loop
  71197. * @param delay defines the start delay (in ms)
  71198. * @param onAnimationEnd defines a callback to call when animation ends
  71199. */
  71200. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71201. /** Stops current animation (if any) */
  71202. stopAnimation(): void;
  71203. /** @hidden */
  71204. _animate(deltaTime: number): void;
  71205. /** Release associated resources */
  71206. dispose(): void;
  71207. }
  71208. }
  71209. declare module BABYLON {
  71210. /**
  71211. * Information about the result of picking within a scene
  71212. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71213. */
  71214. export class PickingInfo {
  71215. /** @hidden */
  71216. _pickingUnavailable: boolean;
  71217. /**
  71218. * If the pick collided with an object
  71219. */
  71220. hit: boolean;
  71221. /**
  71222. * Distance away where the pick collided
  71223. */
  71224. distance: number;
  71225. /**
  71226. * The location of pick collision
  71227. */
  71228. pickedPoint: Nullable<Vector3>;
  71229. /**
  71230. * The mesh corresponding the the pick collision
  71231. */
  71232. pickedMesh: Nullable<AbstractMesh>;
  71233. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  71234. bu: number;
  71235. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  71236. bv: number;
  71237. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  71238. faceId: number;
  71239. /** Id of the the submesh that was picked */
  71240. subMeshId: number;
  71241. /** If a sprite was picked, this will be the sprite the pick collided with */
  71242. pickedSprite: Nullable<Sprite>;
  71243. /**
  71244. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  71245. */
  71246. originMesh: Nullable<AbstractMesh>;
  71247. /**
  71248. * The ray that was used to perform the picking.
  71249. */
  71250. ray: Nullable<Ray>;
  71251. /**
  71252. * Gets the normal correspodning to the face the pick collided with
  71253. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  71254. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  71255. * @returns The normal correspodning to the face the pick collided with
  71256. */
  71257. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  71258. /**
  71259. * Gets the texture coordinates of where the pick occured
  71260. * @returns the vector containing the coordnates of the texture
  71261. */
  71262. getTextureCoordinates(): Nullable<Vector2>;
  71263. }
  71264. }
  71265. declare module BABYLON {
  71266. /**
  71267. * Gather the list of pointer event types as constants.
  71268. */
  71269. export class PointerEventTypes {
  71270. /**
  71271. * 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.
  71272. */
  71273. static readonly POINTERDOWN: number;
  71274. /**
  71275. * The pointerup event is fired when a pointer is no longer active.
  71276. */
  71277. static readonly POINTERUP: number;
  71278. /**
  71279. * The pointermove event is fired when a pointer changes coordinates.
  71280. */
  71281. static readonly POINTERMOVE: number;
  71282. /**
  71283. * The pointerwheel event is fired when a mouse wheel has been rotated.
  71284. */
  71285. static readonly POINTERWHEEL: number;
  71286. /**
  71287. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  71288. */
  71289. static readonly POINTERPICK: number;
  71290. /**
  71291. * The pointertap event is fired when a the object has been touched and released without drag.
  71292. */
  71293. static readonly POINTERTAP: number;
  71294. /**
  71295. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  71296. */
  71297. static readonly POINTERDOUBLETAP: number;
  71298. }
  71299. /**
  71300. * Base class of pointer info types.
  71301. */
  71302. export class PointerInfoBase {
  71303. /**
  71304. * Defines the type of event (PointerEventTypes)
  71305. */
  71306. type: number;
  71307. /**
  71308. * Defines the related dom event
  71309. */
  71310. event: PointerEvent | MouseWheelEvent;
  71311. /**
  71312. * Instantiates the base class of pointers info.
  71313. * @param type Defines the type of event (PointerEventTypes)
  71314. * @param event Defines the related dom event
  71315. */
  71316. constructor(
  71317. /**
  71318. * Defines the type of event (PointerEventTypes)
  71319. */
  71320. type: number,
  71321. /**
  71322. * Defines the related dom event
  71323. */
  71324. event: PointerEvent | MouseWheelEvent);
  71325. }
  71326. /**
  71327. * This class is used to store pointer related info for the onPrePointerObservable event.
  71328. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  71329. */
  71330. export class PointerInfoPre extends PointerInfoBase {
  71331. /**
  71332. * Ray from a pointer if availible (eg. 6dof controller)
  71333. */
  71334. ray: Nullable<Ray>;
  71335. /**
  71336. * Defines the local position of the pointer on the canvas.
  71337. */
  71338. localPosition: Vector2;
  71339. /**
  71340. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  71341. */
  71342. skipOnPointerObservable: boolean;
  71343. /**
  71344. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  71345. * @param type Defines the type of event (PointerEventTypes)
  71346. * @param event Defines the related dom event
  71347. * @param localX Defines the local x coordinates of the pointer when the event occured
  71348. * @param localY Defines the local y coordinates of the pointer when the event occured
  71349. */
  71350. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  71351. }
  71352. /**
  71353. * This type contains all the data related to a pointer event in Babylon.js.
  71354. * 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.
  71355. */
  71356. export class PointerInfo extends PointerInfoBase {
  71357. /**
  71358. * Defines the picking info associated to the info (if any)\
  71359. */
  71360. pickInfo: Nullable<PickingInfo>;
  71361. /**
  71362. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  71363. * @param type Defines the type of event (PointerEventTypes)
  71364. * @param event Defines the related dom event
  71365. * @param pickInfo Defines the picking info associated to the info (if any)\
  71366. */
  71367. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  71368. /**
  71369. * Defines the picking info associated to the info (if any)\
  71370. */
  71371. pickInfo: Nullable<PickingInfo>);
  71372. }
  71373. /**
  71374. * Data relating to a touch event on the screen.
  71375. */
  71376. export interface PointerTouch {
  71377. /**
  71378. * X coordinate of touch.
  71379. */
  71380. x: number;
  71381. /**
  71382. * Y coordinate of touch.
  71383. */
  71384. y: number;
  71385. /**
  71386. * Id of touch. Unique for each finger.
  71387. */
  71388. pointerId: number;
  71389. /**
  71390. * Event type passed from DOM.
  71391. */
  71392. type: any;
  71393. }
  71394. }
  71395. declare module BABYLON {
  71396. /**
  71397. * Manage the mouse inputs to control the movement of a free camera.
  71398. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71399. */
  71400. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  71401. /**
  71402. * Define if touch is enabled in the mouse input
  71403. */
  71404. touchEnabled: boolean;
  71405. /**
  71406. * Defines the camera the input is attached to.
  71407. */
  71408. camera: FreeCamera;
  71409. /**
  71410. * Defines the buttons associated with the input to handle camera move.
  71411. */
  71412. buttons: number[];
  71413. /**
  71414. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  71415. */
  71416. angularSensibility: number;
  71417. private _pointerInput;
  71418. private _onMouseMove;
  71419. private _observer;
  71420. private previousPosition;
  71421. /**
  71422. * Observable for when a pointer move event occurs containing the move offset
  71423. */
  71424. onPointerMovedObservable: Observable<{
  71425. offsetX: number;
  71426. offsetY: number;
  71427. }>;
  71428. /**
  71429. * @hidden
  71430. * If the camera should be rotated automatically based on pointer movement
  71431. */
  71432. _allowCameraRotation: boolean;
  71433. /**
  71434. * Manage the mouse inputs to control the movement of a free camera.
  71435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71436. * @param touchEnabled Defines if touch is enabled or not
  71437. */
  71438. constructor(
  71439. /**
  71440. * Define if touch is enabled in the mouse input
  71441. */
  71442. touchEnabled?: boolean);
  71443. /**
  71444. * Attach the input controls to a specific dom element to get the input from.
  71445. * @param element Defines the element the controls should be listened from
  71446. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71447. */
  71448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71449. /**
  71450. * Called on JS contextmenu event.
  71451. * Override this method to provide functionality.
  71452. */
  71453. protected onContextMenu(evt: PointerEvent): void;
  71454. /**
  71455. * Detach the current controls from the specified dom element.
  71456. * @param element Defines the element to stop listening the inputs from
  71457. */
  71458. detachControl(element: Nullable<HTMLElement>): void;
  71459. /**
  71460. * Gets the class name of the current intput.
  71461. * @returns the class name
  71462. */
  71463. getClassName(): string;
  71464. /**
  71465. * Get the friendly name associated with the input class.
  71466. * @returns the input friendly name
  71467. */
  71468. getSimpleName(): string;
  71469. }
  71470. }
  71471. declare module BABYLON {
  71472. /**
  71473. * Manage the touch inputs to control the movement of a free camera.
  71474. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71475. */
  71476. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  71477. /**
  71478. * Defines the camera the input is attached to.
  71479. */
  71480. camera: FreeCamera;
  71481. /**
  71482. * Defines the touch sensibility for rotation.
  71483. * The higher the faster.
  71484. */
  71485. touchAngularSensibility: number;
  71486. /**
  71487. * Defines the touch sensibility for move.
  71488. * The higher the faster.
  71489. */
  71490. touchMoveSensibility: number;
  71491. private _offsetX;
  71492. private _offsetY;
  71493. private _pointerPressed;
  71494. private _pointerInput;
  71495. private _observer;
  71496. private _onLostFocus;
  71497. /**
  71498. * Attach the input controls to a specific dom element to get the input from.
  71499. * @param element Defines the element the controls should be listened from
  71500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71501. */
  71502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71503. /**
  71504. * Detach the current controls from the specified dom element.
  71505. * @param element Defines the element to stop listening the inputs from
  71506. */
  71507. detachControl(element: Nullable<HTMLElement>): void;
  71508. /**
  71509. * Update the current camera state depending on the inputs that have been used this frame.
  71510. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71511. */
  71512. checkInputs(): void;
  71513. /**
  71514. * Gets the class name of the current intput.
  71515. * @returns the class name
  71516. */
  71517. getClassName(): string;
  71518. /**
  71519. * Get the friendly name associated with the input class.
  71520. * @returns the input friendly name
  71521. */
  71522. getSimpleName(): string;
  71523. }
  71524. }
  71525. declare module BABYLON {
  71526. /**
  71527. * Default Inputs manager for the FreeCamera.
  71528. * It groups all the default supported inputs for ease of use.
  71529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71530. */
  71531. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  71532. /**
  71533. * @hidden
  71534. */
  71535. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  71536. /**
  71537. * @hidden
  71538. */
  71539. _mouseInput: Nullable<FreeCameraMouseInput>;
  71540. /**
  71541. * Instantiates a new FreeCameraInputsManager.
  71542. * @param camera Defines the camera the inputs belong to
  71543. */
  71544. constructor(camera: FreeCamera);
  71545. /**
  71546. * Add keyboard input support to the input manager.
  71547. * @returns the current input manager
  71548. */
  71549. addKeyboard(): FreeCameraInputsManager;
  71550. /**
  71551. * Add mouse input support to the input manager.
  71552. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  71553. * @returns the current input manager
  71554. */
  71555. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  71556. /**
  71557. * Removes the mouse input support from the manager
  71558. * @returns the current input manager
  71559. */
  71560. removeMouse(): FreeCameraInputsManager;
  71561. /**
  71562. * Add touch input support to the input manager.
  71563. * @returns the current input manager
  71564. */
  71565. addTouch(): FreeCameraInputsManager;
  71566. }
  71567. }
  71568. declare module BABYLON {
  71569. /**
  71570. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71571. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  71572. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71573. */
  71574. export class FreeCamera extends TargetCamera {
  71575. /**
  71576. * Define the collision ellipsoid of the camera.
  71577. * This is helpful to simulate a camera body like the player body around the camera
  71578. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  71579. */
  71580. ellipsoid: Vector3;
  71581. /**
  71582. * Define an offset for the position of the ellipsoid around the camera.
  71583. * This can be helpful to determine the center of the body near the gravity center of the body
  71584. * instead of its head.
  71585. */
  71586. ellipsoidOffset: Vector3;
  71587. /**
  71588. * Enable or disable collisions of the camera with the rest of the scene objects.
  71589. */
  71590. checkCollisions: boolean;
  71591. /**
  71592. * Enable or disable gravity on the camera.
  71593. */
  71594. applyGravity: boolean;
  71595. /**
  71596. * Define the input manager associated to the camera.
  71597. */
  71598. inputs: FreeCameraInputsManager;
  71599. /**
  71600. * Gets the input sensibility for a mouse input. (default is 2000.0)
  71601. * Higher values reduce sensitivity.
  71602. */
  71603. /**
  71604. * Sets the input sensibility for a mouse input. (default is 2000.0)
  71605. * Higher values reduce sensitivity.
  71606. */
  71607. angularSensibility: number;
  71608. /**
  71609. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71610. */
  71611. keysUp: number[];
  71612. /**
  71613. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71614. */
  71615. keysDown: number[];
  71616. /**
  71617. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71618. */
  71619. keysLeft: number[];
  71620. /**
  71621. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71622. */
  71623. keysRight: number[];
  71624. /**
  71625. * Event raised when the camera collide with a mesh in the scene.
  71626. */
  71627. onCollide: (collidedMesh: AbstractMesh) => void;
  71628. private _collider;
  71629. private _needMoveForGravity;
  71630. private _oldPosition;
  71631. private _diffPosition;
  71632. private _newPosition;
  71633. /** @hidden */
  71634. _localDirection: Vector3;
  71635. /** @hidden */
  71636. _transformedDirection: Vector3;
  71637. /**
  71638. * Instantiates a Free Camera.
  71639. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71640. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  71641. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71642. * @param name Define the name of the camera in the scene
  71643. * @param position Define the start position of the camera in the scene
  71644. * @param scene Define the scene the camera belongs to
  71645. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  71646. */
  71647. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  71648. /**
  71649. * Attached controls to the current camera.
  71650. * @param element Defines the element the controls should be listened from
  71651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71652. */
  71653. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71654. /**
  71655. * Detach the current controls from the camera.
  71656. * The camera will stop reacting to inputs.
  71657. * @param element Defines the element to stop listening the inputs from
  71658. */
  71659. detachControl(element: HTMLElement): void;
  71660. private _collisionMask;
  71661. /**
  71662. * Define a collision mask to limit the list of object the camera can collide with
  71663. */
  71664. collisionMask: number;
  71665. /** @hidden */
  71666. _collideWithWorld(displacement: Vector3): void;
  71667. private _onCollisionPositionChange;
  71668. /** @hidden */
  71669. _checkInputs(): void;
  71670. /** @hidden */
  71671. _decideIfNeedsToMove(): boolean;
  71672. /** @hidden */
  71673. _updatePosition(): void;
  71674. /**
  71675. * Destroy the camera and release the current resources hold by it.
  71676. */
  71677. dispose(): void;
  71678. /**
  71679. * Gets the current object class name.
  71680. * @return the class name
  71681. */
  71682. getClassName(): string;
  71683. }
  71684. }
  71685. declare module BABYLON {
  71686. /**
  71687. * Represents a gamepad control stick position
  71688. */
  71689. export class StickValues {
  71690. /**
  71691. * The x component of the control stick
  71692. */
  71693. x: number;
  71694. /**
  71695. * The y component of the control stick
  71696. */
  71697. y: number;
  71698. /**
  71699. * Initializes the gamepad x and y control stick values
  71700. * @param x The x component of the gamepad control stick value
  71701. * @param y The y component of the gamepad control stick value
  71702. */
  71703. constructor(
  71704. /**
  71705. * The x component of the control stick
  71706. */
  71707. x: number,
  71708. /**
  71709. * The y component of the control stick
  71710. */
  71711. y: number);
  71712. }
  71713. /**
  71714. * An interface which manages callbacks for gamepad button changes
  71715. */
  71716. export interface GamepadButtonChanges {
  71717. /**
  71718. * Called when a gamepad has been changed
  71719. */
  71720. changed: boolean;
  71721. /**
  71722. * Called when a gamepad press event has been triggered
  71723. */
  71724. pressChanged: boolean;
  71725. /**
  71726. * Called when a touch event has been triggered
  71727. */
  71728. touchChanged: boolean;
  71729. /**
  71730. * Called when a value has changed
  71731. */
  71732. valueChanged: boolean;
  71733. }
  71734. /**
  71735. * Represents a gamepad
  71736. */
  71737. export class Gamepad {
  71738. /**
  71739. * The id of the gamepad
  71740. */
  71741. id: string;
  71742. /**
  71743. * The index of the gamepad
  71744. */
  71745. index: number;
  71746. /**
  71747. * The browser gamepad
  71748. */
  71749. browserGamepad: any;
  71750. /**
  71751. * Specifies what type of gamepad this represents
  71752. */
  71753. type: number;
  71754. private _leftStick;
  71755. private _rightStick;
  71756. /** @hidden */
  71757. _isConnected: boolean;
  71758. private _leftStickAxisX;
  71759. private _leftStickAxisY;
  71760. private _rightStickAxisX;
  71761. private _rightStickAxisY;
  71762. /**
  71763. * Triggered when the left control stick has been changed
  71764. */
  71765. private _onleftstickchanged;
  71766. /**
  71767. * Triggered when the right control stick has been changed
  71768. */
  71769. private _onrightstickchanged;
  71770. /**
  71771. * Represents a gamepad controller
  71772. */
  71773. static GAMEPAD: number;
  71774. /**
  71775. * Represents a generic controller
  71776. */
  71777. static GENERIC: number;
  71778. /**
  71779. * Represents an XBox controller
  71780. */
  71781. static XBOX: number;
  71782. /**
  71783. * Represents a pose-enabled controller
  71784. */
  71785. static POSE_ENABLED: number;
  71786. /**
  71787. * Specifies whether the left control stick should be Y-inverted
  71788. */
  71789. protected _invertLeftStickY: boolean;
  71790. /**
  71791. * Specifies if the gamepad has been connected
  71792. */
  71793. readonly isConnected: boolean;
  71794. /**
  71795. * Initializes the gamepad
  71796. * @param id The id of the gamepad
  71797. * @param index The index of the gamepad
  71798. * @param browserGamepad The browser gamepad
  71799. * @param leftStickX The x component of the left joystick
  71800. * @param leftStickY The y component of the left joystick
  71801. * @param rightStickX The x component of the right joystick
  71802. * @param rightStickY The y component of the right joystick
  71803. */
  71804. constructor(
  71805. /**
  71806. * The id of the gamepad
  71807. */
  71808. id: string,
  71809. /**
  71810. * The index of the gamepad
  71811. */
  71812. index: number,
  71813. /**
  71814. * The browser gamepad
  71815. */
  71816. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  71817. /**
  71818. * Callback triggered when the left joystick has changed
  71819. * @param callback
  71820. */
  71821. onleftstickchanged(callback: (values: StickValues) => void): void;
  71822. /**
  71823. * Callback triggered when the right joystick has changed
  71824. * @param callback
  71825. */
  71826. onrightstickchanged(callback: (values: StickValues) => void): void;
  71827. /**
  71828. * Gets the left joystick
  71829. */
  71830. /**
  71831. * Sets the left joystick values
  71832. */
  71833. leftStick: StickValues;
  71834. /**
  71835. * Gets the right joystick
  71836. */
  71837. /**
  71838. * Sets the right joystick value
  71839. */
  71840. rightStick: StickValues;
  71841. /**
  71842. * Updates the gamepad joystick positions
  71843. */
  71844. update(): void;
  71845. /**
  71846. * Disposes the gamepad
  71847. */
  71848. dispose(): void;
  71849. }
  71850. /**
  71851. * Represents a generic gamepad
  71852. */
  71853. export class GenericPad extends Gamepad {
  71854. private _buttons;
  71855. private _onbuttondown;
  71856. private _onbuttonup;
  71857. /**
  71858. * Observable triggered when a button has been pressed
  71859. */
  71860. onButtonDownObservable: Observable<number>;
  71861. /**
  71862. * Observable triggered when a button has been released
  71863. */
  71864. onButtonUpObservable: Observable<number>;
  71865. /**
  71866. * Callback triggered when a button has been pressed
  71867. * @param callback Called when a button has been pressed
  71868. */
  71869. onbuttondown(callback: (buttonPressed: number) => void): void;
  71870. /**
  71871. * Callback triggered when a button has been released
  71872. * @param callback Called when a button has been released
  71873. */
  71874. onbuttonup(callback: (buttonReleased: number) => void): void;
  71875. /**
  71876. * Initializes the generic gamepad
  71877. * @param id The id of the generic gamepad
  71878. * @param index The index of the generic gamepad
  71879. * @param browserGamepad The browser gamepad
  71880. */
  71881. constructor(id: string, index: number, browserGamepad: any);
  71882. private _setButtonValue;
  71883. /**
  71884. * Updates the generic gamepad
  71885. */
  71886. update(): void;
  71887. /**
  71888. * Disposes the generic gamepad
  71889. */
  71890. dispose(): void;
  71891. }
  71892. }
  71893. declare module BABYLON {
  71894. /**
  71895. * Defines the types of pose enabled controllers that are supported
  71896. */
  71897. export enum PoseEnabledControllerType {
  71898. /**
  71899. * HTC Vive
  71900. */
  71901. VIVE = 0,
  71902. /**
  71903. * Oculus Rift
  71904. */
  71905. OCULUS = 1,
  71906. /**
  71907. * Windows mixed reality
  71908. */
  71909. WINDOWS = 2,
  71910. /**
  71911. * Samsung gear VR
  71912. */
  71913. GEAR_VR = 3,
  71914. /**
  71915. * Google Daydream
  71916. */
  71917. DAYDREAM = 4,
  71918. /**
  71919. * Generic
  71920. */
  71921. GENERIC = 5
  71922. }
  71923. /**
  71924. * Defines the MutableGamepadButton interface for the state of a gamepad button
  71925. */
  71926. export interface MutableGamepadButton {
  71927. /**
  71928. * Value of the button/trigger
  71929. */
  71930. value: number;
  71931. /**
  71932. * If the button/trigger is currently touched
  71933. */
  71934. touched: boolean;
  71935. /**
  71936. * If the button/trigger is currently pressed
  71937. */
  71938. pressed: boolean;
  71939. }
  71940. /**
  71941. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  71942. * @hidden
  71943. */
  71944. export interface ExtendedGamepadButton extends GamepadButton {
  71945. /**
  71946. * If the button/trigger is currently pressed
  71947. */
  71948. readonly pressed: boolean;
  71949. /**
  71950. * If the button/trigger is currently touched
  71951. */
  71952. readonly touched: boolean;
  71953. /**
  71954. * Value of the button/trigger
  71955. */
  71956. readonly value: number;
  71957. }
  71958. /** @hidden */
  71959. export interface _GamePadFactory {
  71960. /**
  71961. * Returns wether or not the current gamepad can be created for this type of controller.
  71962. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71963. * @returns true if it can be created, otherwise false
  71964. */
  71965. canCreate(gamepadInfo: any): boolean;
  71966. /**
  71967. * Creates a new instance of the Gamepad.
  71968. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71969. * @returns the new gamepad instance
  71970. */
  71971. create(gamepadInfo: any): Gamepad;
  71972. }
  71973. /**
  71974. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71975. */
  71976. export class PoseEnabledControllerHelper {
  71977. /** @hidden */
  71978. static _ControllerFactories: _GamePadFactory[];
  71979. /** @hidden */
  71980. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  71981. /**
  71982. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71983. * @param vrGamepad the gamepad to initialized
  71984. * @returns a vr controller of the type the gamepad identified as
  71985. */
  71986. static InitiateController(vrGamepad: any): Gamepad;
  71987. }
  71988. /**
  71989. * Defines the PoseEnabledController object that contains state of a vr capable controller
  71990. */
  71991. export class PoseEnabledController extends Gamepad implements PoseControlled {
  71992. private _deviceRoomPosition;
  71993. private _deviceRoomRotationQuaternion;
  71994. /**
  71995. * The device position in babylon space
  71996. */
  71997. devicePosition: Vector3;
  71998. /**
  71999. * The device rotation in babylon space
  72000. */
  72001. deviceRotationQuaternion: Quaternion;
  72002. /**
  72003. * The scale factor of the device in babylon space
  72004. */
  72005. deviceScaleFactor: number;
  72006. /**
  72007. * (Likely devicePosition should be used instead) The device position in its room space
  72008. */
  72009. position: Vector3;
  72010. /**
  72011. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72012. */
  72013. rotationQuaternion: Quaternion;
  72014. /**
  72015. * The type of controller (Eg. Windows mixed reality)
  72016. */
  72017. controllerType: PoseEnabledControllerType;
  72018. protected _calculatedPosition: Vector3;
  72019. private _calculatedRotation;
  72020. /**
  72021. * The raw pose from the device
  72022. */
  72023. rawPose: DevicePose;
  72024. private _trackPosition;
  72025. private _maxRotationDistFromHeadset;
  72026. private _draggedRoomRotation;
  72027. /**
  72028. * @hidden
  72029. */
  72030. _disableTrackPosition(fixedPosition: Vector3): void;
  72031. /**
  72032. * Internal, the mesh attached to the controller
  72033. * @hidden
  72034. */
  72035. _mesh: Nullable<AbstractMesh>;
  72036. private _poseControlledCamera;
  72037. private _leftHandSystemQuaternion;
  72038. /**
  72039. * Internal, matrix used to convert room space to babylon space
  72040. * @hidden
  72041. */
  72042. _deviceToWorld: Matrix;
  72043. /**
  72044. * Node to be used when casting a ray from the controller
  72045. * @hidden
  72046. */
  72047. _pointingPoseNode: Nullable<TransformNode>;
  72048. /**
  72049. * Name of the child mesh that can be used to cast a ray from the controller
  72050. */
  72051. static readonly POINTING_POSE: string;
  72052. /**
  72053. * Creates a new PoseEnabledController from a gamepad
  72054. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72055. */
  72056. constructor(browserGamepad: any);
  72057. private _workingMatrix;
  72058. /**
  72059. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72060. */
  72061. update(): void;
  72062. /**
  72063. * Updates only the pose device and mesh without doing any button event checking
  72064. */
  72065. protected _updatePoseAndMesh(): void;
  72066. /**
  72067. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72068. * @param poseData raw pose fromthe device
  72069. */
  72070. updateFromDevice(poseData: DevicePose): void;
  72071. /**
  72072. * @hidden
  72073. */
  72074. _meshAttachedObservable: Observable<AbstractMesh>;
  72075. /**
  72076. * Attaches a mesh to the controller
  72077. * @param mesh the mesh to be attached
  72078. */
  72079. attachToMesh(mesh: AbstractMesh): void;
  72080. /**
  72081. * Attaches the controllers mesh to a camera
  72082. * @param camera the camera the mesh should be attached to
  72083. */
  72084. attachToPoseControlledCamera(camera: TargetCamera): void;
  72085. /**
  72086. * Disposes of the controller
  72087. */
  72088. dispose(): void;
  72089. /**
  72090. * The mesh that is attached to the controller
  72091. */
  72092. readonly mesh: Nullable<AbstractMesh>;
  72093. /**
  72094. * Gets the ray of the controller in the direction the controller is pointing
  72095. * @param length the length the resulting ray should be
  72096. * @returns a ray in the direction the controller is pointing
  72097. */
  72098. getForwardRay(length?: number): Ray;
  72099. }
  72100. }
  72101. declare module BABYLON {
  72102. /**
  72103. * Defines the WebVRController object that represents controllers tracked in 3D space
  72104. */
  72105. export abstract class WebVRController extends PoseEnabledController {
  72106. /**
  72107. * Internal, the default controller model for the controller
  72108. */
  72109. protected _defaultModel: AbstractMesh;
  72110. /**
  72111. * Fired when the trigger state has changed
  72112. */
  72113. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72114. /**
  72115. * Fired when the main button state has changed
  72116. */
  72117. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72118. /**
  72119. * Fired when the secondary button state has changed
  72120. */
  72121. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72122. /**
  72123. * Fired when the pad state has changed
  72124. */
  72125. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72126. /**
  72127. * Fired when controllers stick values have changed
  72128. */
  72129. onPadValuesChangedObservable: Observable<StickValues>;
  72130. /**
  72131. * Array of button availible on the controller
  72132. */
  72133. protected _buttons: Array<MutableGamepadButton>;
  72134. private _onButtonStateChange;
  72135. /**
  72136. * Fired when a controller button's state has changed
  72137. * @param callback the callback containing the button that was modified
  72138. */
  72139. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72140. /**
  72141. * X and Y axis corrisponding to the controllers joystick
  72142. */
  72143. pad: StickValues;
  72144. /**
  72145. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72146. */
  72147. hand: string;
  72148. /**
  72149. * The default controller model for the controller
  72150. */
  72151. readonly defaultModel: AbstractMesh;
  72152. /**
  72153. * Creates a new WebVRController from a gamepad
  72154. * @param vrGamepad the gamepad that the WebVRController should be created from
  72155. */
  72156. constructor(vrGamepad: any);
  72157. /**
  72158. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72159. */
  72160. update(): void;
  72161. /**
  72162. * Function to be called when a button is modified
  72163. */
  72164. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72165. /**
  72166. * Loads a mesh and attaches it to the controller
  72167. * @param scene the scene the mesh should be added to
  72168. * @param meshLoaded callback for when the mesh has been loaded
  72169. */
  72170. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72171. private _setButtonValue;
  72172. private _changes;
  72173. private _checkChanges;
  72174. /**
  72175. * Disposes of th webVRCOntroller
  72176. */
  72177. dispose(): void;
  72178. }
  72179. }
  72180. declare module BABYLON {
  72181. /**
  72182. * The HemisphericLight simulates the ambient environment light,
  72183. * so the passed direction is the light reflection direction, not the incoming direction.
  72184. */
  72185. export class HemisphericLight extends Light {
  72186. /**
  72187. * The groundColor is the light in the opposite direction to the one specified during creation.
  72188. * 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.
  72189. */
  72190. groundColor: Color3;
  72191. /**
  72192. * The light reflection direction, not the incoming direction.
  72193. */
  72194. direction: Vector3;
  72195. /**
  72196. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72197. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72198. * The HemisphericLight can't cast shadows.
  72199. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72200. * @param name The friendly name of the light
  72201. * @param direction The direction of the light reflection
  72202. * @param scene The scene the light belongs to
  72203. */
  72204. constructor(name: string, direction: Vector3, scene: Scene);
  72205. protected _buildUniformLayout(): void;
  72206. /**
  72207. * Returns the string "HemisphericLight".
  72208. * @return The class name
  72209. */
  72210. getClassName(): string;
  72211. /**
  72212. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72213. * Returns the updated direction.
  72214. * @param target The target the direction should point to
  72215. * @return The computed direction
  72216. */
  72217. setDirectionToTarget(target: Vector3): Vector3;
  72218. /**
  72219. * Returns the shadow generator associated to the light.
  72220. * @returns Always null for hemispheric lights because it does not support shadows.
  72221. */
  72222. getShadowGenerator(): Nullable<IShadowGenerator>;
  72223. /**
  72224. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72225. * @param effect The effect to update
  72226. * @param lightIndex The index of the light in the effect to update
  72227. * @returns The hemispheric light
  72228. */
  72229. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72230. /**
  72231. * Computes the world matrix of the node
  72232. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72233. * @param useWasUpdatedFlag defines a reserved property
  72234. * @returns the world matrix
  72235. */
  72236. computeWorldMatrix(): Matrix;
  72237. /**
  72238. * Returns the integer 3.
  72239. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72240. */
  72241. getTypeID(): number;
  72242. /**
  72243. * Prepares the list of defines specific to the light type.
  72244. * @param defines the list of defines
  72245. * @param lightIndex defines the index of the light for the effect
  72246. */
  72247. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72248. }
  72249. }
  72250. declare module BABYLON {
  72251. /** @hidden */
  72252. export var vrMultiviewToSingleviewPixelShader: {
  72253. name: string;
  72254. shader: string;
  72255. };
  72256. }
  72257. declare module BABYLON {
  72258. /**
  72259. * Renders to multiple views with a single draw call
  72260. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  72261. */
  72262. export class MultiviewRenderTarget extends RenderTargetTexture {
  72263. /**
  72264. * Creates a multiview render target
  72265. * @param scene scene used with the render target
  72266. * @param size the size of the render target (used for each view)
  72267. */
  72268. constructor(scene: Scene, size?: number | {
  72269. width: number;
  72270. height: number;
  72271. } | {
  72272. ratio: number;
  72273. });
  72274. /**
  72275. * @hidden
  72276. * @param faceIndex the face index, if its a cube texture
  72277. */
  72278. _bindFrameBuffer(faceIndex?: number): void;
  72279. /**
  72280. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  72281. * @returns the view count
  72282. */
  72283. getViewCount(): number;
  72284. }
  72285. }
  72286. declare module BABYLON {
  72287. interface Engine {
  72288. /**
  72289. * Creates a new multiview render target
  72290. * @param width defines the width of the texture
  72291. * @param height defines the height of the texture
  72292. * @returns the created multiview texture
  72293. */
  72294. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  72295. /**
  72296. * Binds a multiview framebuffer to be drawn to
  72297. * @param multiviewTexture texture to bind
  72298. */
  72299. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  72300. }
  72301. interface Camera {
  72302. /**
  72303. * @hidden
  72304. * 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)
  72305. */
  72306. _useMultiviewToSingleView: boolean;
  72307. /**
  72308. * @hidden
  72309. * 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)
  72310. */
  72311. _multiviewTexture: Nullable<RenderTargetTexture>;
  72312. /**
  72313. * @hidden
  72314. * ensures the multiview texture of the camera exists and has the specified width/height
  72315. * @param width height to set on the multiview texture
  72316. * @param height width to set on the multiview texture
  72317. */
  72318. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  72319. }
  72320. interface Scene {
  72321. /** @hidden */
  72322. _transformMatrixR: Matrix;
  72323. /** @hidden */
  72324. _multiviewSceneUbo: Nullable<UniformBuffer>;
  72325. /** @hidden */
  72326. _createMultiviewUbo(): void;
  72327. /** @hidden */
  72328. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  72329. /** @hidden */
  72330. _renderMultiviewToSingleView(camera: Camera): void;
  72331. }
  72332. }
  72333. declare module BABYLON {
  72334. /**
  72335. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  72336. * This will not be used for webXR as it supports displaying texture arrays directly
  72337. */
  72338. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  72339. /**
  72340. * Initializes a VRMultiviewToSingleview
  72341. * @param name name of the post process
  72342. * @param camera camera to be applied to
  72343. * @param scaleFactor scaling factor to the size of the output texture
  72344. */
  72345. constructor(name: string, camera: Camera, scaleFactor: number);
  72346. }
  72347. }
  72348. declare module BABYLON {
  72349. /**
  72350. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  72351. * IMPORTANT!! The data is right-hand data.
  72352. * @export
  72353. * @interface DevicePose
  72354. */
  72355. export interface DevicePose {
  72356. /**
  72357. * The position of the device, values in array are [x,y,z].
  72358. */
  72359. readonly position: Nullable<Float32Array>;
  72360. /**
  72361. * The linearVelocity of the device, values in array are [x,y,z].
  72362. */
  72363. readonly linearVelocity: Nullable<Float32Array>;
  72364. /**
  72365. * The linearAcceleration of the device, values in array are [x,y,z].
  72366. */
  72367. readonly linearAcceleration: Nullable<Float32Array>;
  72368. /**
  72369. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  72370. */
  72371. readonly orientation: Nullable<Float32Array>;
  72372. /**
  72373. * The angularVelocity of the device, values in array are [x,y,z].
  72374. */
  72375. readonly angularVelocity: Nullable<Float32Array>;
  72376. /**
  72377. * The angularAcceleration of the device, values in array are [x,y,z].
  72378. */
  72379. readonly angularAcceleration: Nullable<Float32Array>;
  72380. }
  72381. /**
  72382. * Interface representing a pose controlled object in Babylon.
  72383. * A pose controlled object has both regular pose values as well as pose values
  72384. * from an external device such as a VR head mounted display
  72385. */
  72386. export interface PoseControlled {
  72387. /**
  72388. * The position of the object in babylon space.
  72389. */
  72390. position: Vector3;
  72391. /**
  72392. * The rotation quaternion of the object in babylon space.
  72393. */
  72394. rotationQuaternion: Quaternion;
  72395. /**
  72396. * The position of the device in babylon space.
  72397. */
  72398. devicePosition?: Vector3;
  72399. /**
  72400. * The rotation quaternion of the device in babylon space.
  72401. */
  72402. deviceRotationQuaternion: Quaternion;
  72403. /**
  72404. * The raw pose coming from the device.
  72405. */
  72406. rawPose: Nullable<DevicePose>;
  72407. /**
  72408. * The scale of the device to be used when translating from device space to babylon space.
  72409. */
  72410. deviceScaleFactor: number;
  72411. /**
  72412. * Updates the poseControlled values based on the input device pose.
  72413. * @param poseData the pose data to update the object with
  72414. */
  72415. updateFromDevice(poseData: DevicePose): void;
  72416. }
  72417. /**
  72418. * Set of options to customize the webVRCamera
  72419. */
  72420. export interface WebVROptions {
  72421. /**
  72422. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  72423. */
  72424. trackPosition?: boolean;
  72425. /**
  72426. * Sets the scale of the vrDevice in babylon space. (default: 1)
  72427. */
  72428. positionScale?: number;
  72429. /**
  72430. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  72431. */
  72432. displayName?: string;
  72433. /**
  72434. * Should the native controller meshes be initialized. (default: true)
  72435. */
  72436. controllerMeshes?: boolean;
  72437. /**
  72438. * Creating a default HemiLight only on controllers. (default: true)
  72439. */
  72440. defaultLightingOnControllers?: boolean;
  72441. /**
  72442. * If you don't want to use the default VR button of the helper. (default: false)
  72443. */
  72444. useCustomVRButton?: boolean;
  72445. /**
  72446. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  72447. */
  72448. customVRButton?: HTMLButtonElement;
  72449. /**
  72450. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  72451. */
  72452. rayLength?: number;
  72453. /**
  72454. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  72455. */
  72456. defaultHeight?: number;
  72457. /**
  72458. * If multiview should be used if availible (default: false)
  72459. */
  72460. useMultiview?: boolean;
  72461. }
  72462. /**
  72463. * This represents a WebVR camera.
  72464. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  72465. * @example http://doc.babylonjs.com/how_to/webvr_camera
  72466. */
  72467. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  72468. private webVROptions;
  72469. /**
  72470. * @hidden
  72471. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  72472. */
  72473. _vrDevice: any;
  72474. /**
  72475. * The rawPose of the vrDevice.
  72476. */
  72477. rawPose: Nullable<DevicePose>;
  72478. private _onVREnabled;
  72479. private _specsVersion;
  72480. private _attached;
  72481. private _frameData;
  72482. protected _descendants: Array<Node>;
  72483. private _deviceRoomPosition;
  72484. /** @hidden */
  72485. _deviceRoomRotationQuaternion: Quaternion;
  72486. private _standingMatrix;
  72487. /**
  72488. * Represents device position in babylon space.
  72489. */
  72490. devicePosition: Vector3;
  72491. /**
  72492. * Represents device rotation in babylon space.
  72493. */
  72494. deviceRotationQuaternion: Quaternion;
  72495. /**
  72496. * The scale of the device to be used when translating from device space to babylon space.
  72497. */
  72498. deviceScaleFactor: number;
  72499. private _deviceToWorld;
  72500. private _worldToDevice;
  72501. /**
  72502. * References to the webVR controllers for the vrDevice.
  72503. */
  72504. controllers: Array<WebVRController>;
  72505. /**
  72506. * Emits an event when a controller is attached.
  72507. */
  72508. onControllersAttachedObservable: Observable<WebVRController[]>;
  72509. /**
  72510. * Emits an event when a controller's mesh has been loaded;
  72511. */
  72512. onControllerMeshLoadedObservable: Observable<WebVRController>;
  72513. /**
  72514. * Emits an event when the HMD's pose has been updated.
  72515. */
  72516. onPoseUpdatedFromDeviceObservable: Observable<any>;
  72517. private _poseSet;
  72518. /**
  72519. * If the rig cameras be used as parent instead of this camera.
  72520. */
  72521. rigParenting: boolean;
  72522. private _lightOnControllers;
  72523. private _defaultHeight?;
  72524. /**
  72525. * Instantiates a WebVRFreeCamera.
  72526. * @param name The name of the WebVRFreeCamera
  72527. * @param position The starting anchor position for the camera
  72528. * @param scene The scene the camera belongs to
  72529. * @param webVROptions a set of customizable options for the webVRCamera
  72530. */
  72531. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  72532. /**
  72533. * Gets the device distance from the ground in meters.
  72534. * @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.
  72535. */
  72536. deviceDistanceToRoomGround(): number;
  72537. /**
  72538. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72539. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  72540. */
  72541. useStandingMatrix(callback?: (bool: boolean) => void): void;
  72542. /**
  72543. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72544. * @returns A promise with a boolean set to if the standing matrix is supported.
  72545. */
  72546. useStandingMatrixAsync(): Promise<boolean>;
  72547. /**
  72548. * Disposes the camera
  72549. */
  72550. dispose(): void;
  72551. /**
  72552. * Gets a vrController by name.
  72553. * @param name The name of the controller to retreive
  72554. * @returns the controller matching the name specified or null if not found
  72555. */
  72556. getControllerByName(name: string): Nullable<WebVRController>;
  72557. private _leftController;
  72558. /**
  72559. * The controller corrisponding to the users left hand.
  72560. */
  72561. readonly leftController: Nullable<WebVRController>;
  72562. private _rightController;
  72563. /**
  72564. * The controller corrisponding to the users right hand.
  72565. */
  72566. readonly rightController: Nullable<WebVRController>;
  72567. /**
  72568. * Casts a ray forward from the vrCamera's gaze.
  72569. * @param length Length of the ray (default: 100)
  72570. * @returns the ray corrisponding to the gaze
  72571. */
  72572. getForwardRay(length?: number): Ray;
  72573. /**
  72574. * @hidden
  72575. * Updates the camera based on device's frame data
  72576. */
  72577. _checkInputs(): void;
  72578. /**
  72579. * Updates the poseControlled values based on the input device pose.
  72580. * @param poseData Pose coming from the device
  72581. */
  72582. updateFromDevice(poseData: DevicePose): void;
  72583. private _htmlElementAttached;
  72584. private _detachIfAttached;
  72585. /**
  72586. * WebVR's attach control will start broadcasting frames to the device.
  72587. * Note that in certain browsers (chrome for example) this function must be called
  72588. * within a user-interaction callback. Example:
  72589. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  72590. *
  72591. * @param element html element to attach the vrDevice to
  72592. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  72593. */
  72594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72595. /**
  72596. * Detaches the camera from the html element and disables VR
  72597. *
  72598. * @param element html element to detach from
  72599. */
  72600. detachControl(element: HTMLElement): void;
  72601. /**
  72602. * @returns the name of this class
  72603. */
  72604. getClassName(): string;
  72605. /**
  72606. * Calls resetPose on the vrDisplay
  72607. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  72608. */
  72609. resetToCurrentRotation(): void;
  72610. /**
  72611. * @hidden
  72612. * Updates the rig cameras (left and right eye)
  72613. */
  72614. _updateRigCameras(): void;
  72615. private _workingVector;
  72616. private _oneVector;
  72617. private _workingMatrix;
  72618. private updateCacheCalled;
  72619. private _correctPositionIfNotTrackPosition;
  72620. /**
  72621. * @hidden
  72622. * Updates the cached values of the camera
  72623. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  72624. */
  72625. _updateCache(ignoreParentClass?: boolean): void;
  72626. /**
  72627. * @hidden
  72628. * Get current device position in babylon world
  72629. */
  72630. _computeDevicePosition(): void;
  72631. /**
  72632. * Updates the current device position and rotation in the babylon world
  72633. */
  72634. update(): void;
  72635. /**
  72636. * @hidden
  72637. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  72638. * @returns an identity matrix
  72639. */
  72640. _getViewMatrix(): Matrix;
  72641. private _tmpMatrix;
  72642. /**
  72643. * This function is called by the two RIG cameras.
  72644. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  72645. * @hidden
  72646. */
  72647. _getWebVRViewMatrix(): Matrix;
  72648. /** @hidden */
  72649. _getWebVRProjectionMatrix(): Matrix;
  72650. private _onGamepadConnectedObserver;
  72651. private _onGamepadDisconnectedObserver;
  72652. private _updateCacheWhenTrackingDisabledObserver;
  72653. /**
  72654. * Initializes the controllers and their meshes
  72655. */
  72656. initControllers(): void;
  72657. }
  72658. }
  72659. declare module BABYLON {
  72660. /**
  72661. * Size options for a post process
  72662. */
  72663. export type PostProcessOptions = {
  72664. width: number;
  72665. height: number;
  72666. };
  72667. /**
  72668. * PostProcess can be used to apply a shader to a texture after it has been rendered
  72669. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72670. */
  72671. export class PostProcess {
  72672. /** Name of the PostProcess. */
  72673. name: string;
  72674. /**
  72675. * Gets or sets the unique id of the post process
  72676. */
  72677. uniqueId: number;
  72678. /**
  72679. * Width of the texture to apply the post process on
  72680. */
  72681. width: number;
  72682. /**
  72683. * Height of the texture to apply the post process on
  72684. */
  72685. height: number;
  72686. /**
  72687. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  72688. * @hidden
  72689. */
  72690. _outputTexture: Nullable<InternalTexture>;
  72691. /**
  72692. * Sampling mode used by the shader
  72693. * See https://doc.babylonjs.com/classes/3.1/texture
  72694. */
  72695. renderTargetSamplingMode: number;
  72696. /**
  72697. * Clear color to use when screen clearing
  72698. */
  72699. clearColor: Color4;
  72700. /**
  72701. * If the buffer needs to be cleared before applying the post process. (default: true)
  72702. * Should be set to false if shader will overwrite all previous pixels.
  72703. */
  72704. autoClear: boolean;
  72705. /**
  72706. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  72707. */
  72708. alphaMode: number;
  72709. /**
  72710. * Sets the setAlphaBlendConstants of the babylon engine
  72711. */
  72712. alphaConstants: Color4;
  72713. /**
  72714. * Animations to be used for the post processing
  72715. */
  72716. animations: Animation[];
  72717. /**
  72718. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  72719. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  72720. */
  72721. enablePixelPerfectMode: boolean;
  72722. /**
  72723. * Force the postprocess to be applied without taking in account viewport
  72724. */
  72725. forceFullscreenViewport: boolean;
  72726. /**
  72727. * List of inspectable custom properties (used by the Inspector)
  72728. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72729. */
  72730. inspectableCustomProperties: IInspectable[];
  72731. /**
  72732. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  72733. *
  72734. * | Value | Type | Description |
  72735. * | ----- | ----------------------------------- | ----------- |
  72736. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  72737. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  72738. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  72739. *
  72740. */
  72741. scaleMode: number;
  72742. /**
  72743. * Force textures to be a power of two (default: false)
  72744. */
  72745. alwaysForcePOT: boolean;
  72746. private _samples;
  72747. /**
  72748. * Number of sample textures (default: 1)
  72749. */
  72750. samples: number;
  72751. /**
  72752. * Modify the scale of the post process to be the same as the viewport (default: false)
  72753. */
  72754. adaptScaleToCurrentViewport: boolean;
  72755. private _camera;
  72756. private _scene;
  72757. private _engine;
  72758. private _options;
  72759. private _reusable;
  72760. private _textureType;
  72761. /**
  72762. * Smart array of input and output textures for the post process.
  72763. * @hidden
  72764. */
  72765. _textures: SmartArray<InternalTexture>;
  72766. /**
  72767. * The index in _textures that corresponds to the output texture.
  72768. * @hidden
  72769. */
  72770. _currentRenderTextureInd: number;
  72771. private _effect;
  72772. private _samplers;
  72773. private _fragmentUrl;
  72774. private _vertexUrl;
  72775. private _parameters;
  72776. private _scaleRatio;
  72777. protected _indexParameters: any;
  72778. private _shareOutputWithPostProcess;
  72779. private _texelSize;
  72780. private _forcedOutputTexture;
  72781. /**
  72782. * Returns the fragment url or shader name used in the post process.
  72783. * @returns the fragment url or name in the shader store.
  72784. */
  72785. getEffectName(): string;
  72786. /**
  72787. * An event triggered when the postprocess is activated.
  72788. */
  72789. onActivateObservable: Observable<Camera>;
  72790. private _onActivateObserver;
  72791. /**
  72792. * A function that is added to the onActivateObservable
  72793. */
  72794. onActivate: Nullable<(camera: Camera) => void>;
  72795. /**
  72796. * An event triggered when the postprocess changes its size.
  72797. */
  72798. onSizeChangedObservable: Observable<PostProcess>;
  72799. private _onSizeChangedObserver;
  72800. /**
  72801. * A function that is added to the onSizeChangedObservable
  72802. */
  72803. onSizeChanged: (postProcess: PostProcess) => void;
  72804. /**
  72805. * An event triggered when the postprocess applies its effect.
  72806. */
  72807. onApplyObservable: Observable<Effect>;
  72808. private _onApplyObserver;
  72809. /**
  72810. * A function that is added to the onApplyObservable
  72811. */
  72812. onApply: (effect: Effect) => void;
  72813. /**
  72814. * An event triggered before rendering the postprocess
  72815. */
  72816. onBeforeRenderObservable: Observable<Effect>;
  72817. private _onBeforeRenderObserver;
  72818. /**
  72819. * A function that is added to the onBeforeRenderObservable
  72820. */
  72821. onBeforeRender: (effect: Effect) => void;
  72822. /**
  72823. * An event triggered after rendering the postprocess
  72824. */
  72825. onAfterRenderObservable: Observable<Effect>;
  72826. private _onAfterRenderObserver;
  72827. /**
  72828. * A function that is added to the onAfterRenderObservable
  72829. */
  72830. onAfterRender: (efect: Effect) => void;
  72831. /**
  72832. * 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
  72833. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  72834. */
  72835. inputTexture: InternalTexture;
  72836. /**
  72837. * Gets the camera which post process is applied to.
  72838. * @returns The camera the post process is applied to.
  72839. */
  72840. getCamera(): Camera;
  72841. /**
  72842. * Gets the texel size of the postprocess.
  72843. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  72844. */
  72845. readonly texelSize: Vector2;
  72846. /**
  72847. * Creates a new instance PostProcess
  72848. * @param name The name of the PostProcess.
  72849. * @param fragmentUrl The url of the fragment shader to be used.
  72850. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  72851. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  72852. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  72853. * @param camera The camera to apply the render pass to.
  72854. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72855. * @param engine The engine which the post process will be applied. (default: current engine)
  72856. * @param reusable If the post process can be reused on the same frame. (default: false)
  72857. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  72858. * @param textureType Type of textures used when performing the post process. (default: 0)
  72859. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  72860. * @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
  72861. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  72862. */
  72863. constructor(
  72864. /** Name of the PostProcess. */
  72865. 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);
  72866. /**
  72867. * Gets a string idenfifying the name of the class
  72868. * @returns "PostProcess" string
  72869. */
  72870. getClassName(): string;
  72871. /**
  72872. * Gets the engine which this post process belongs to.
  72873. * @returns The engine the post process was enabled with.
  72874. */
  72875. getEngine(): Engine;
  72876. /**
  72877. * The effect that is created when initializing the post process.
  72878. * @returns The created effect corrisponding the the postprocess.
  72879. */
  72880. getEffect(): Effect;
  72881. /**
  72882. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  72883. * @param postProcess The post process to share the output with.
  72884. * @returns This post process.
  72885. */
  72886. shareOutputWith(postProcess: PostProcess): PostProcess;
  72887. /**
  72888. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  72889. * This should be called if the post process that shares output with this post process is disabled/disposed.
  72890. */
  72891. useOwnOutput(): void;
  72892. /**
  72893. * Updates the effect with the current post process compile time values and recompiles the shader.
  72894. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72895. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72896. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72897. * @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
  72898. * @param onCompiled Called when the shader has been compiled.
  72899. * @param onError Called if there is an error when compiling a shader.
  72900. */
  72901. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72902. /**
  72903. * The post process is reusable if it can be used multiple times within one frame.
  72904. * @returns If the post process is reusable
  72905. */
  72906. isReusable(): boolean;
  72907. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  72908. markTextureDirty(): void;
  72909. /**
  72910. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  72911. * 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.
  72912. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  72913. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  72914. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  72915. * @returns The target texture that was bound to be written to.
  72916. */
  72917. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  72918. /**
  72919. * If the post process is supported.
  72920. */
  72921. readonly isSupported: boolean;
  72922. /**
  72923. * The aspect ratio of the output texture.
  72924. */
  72925. readonly aspectRatio: number;
  72926. /**
  72927. * Get a value indicating if the post-process is ready to be used
  72928. * @returns true if the post-process is ready (shader is compiled)
  72929. */
  72930. isReady(): boolean;
  72931. /**
  72932. * Binds all textures and uniforms to the shader, this will be run on every pass.
  72933. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  72934. */
  72935. apply(): Nullable<Effect>;
  72936. private _disposeTextures;
  72937. /**
  72938. * Disposes the post process.
  72939. * @param camera The camera to dispose the post process on.
  72940. */
  72941. dispose(camera?: Camera): void;
  72942. }
  72943. }
  72944. declare module BABYLON {
  72945. /**
  72946. * PostProcessManager is used to manage one or more post processes or post process pipelines
  72947. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72948. */
  72949. export class PostProcessManager {
  72950. private _scene;
  72951. private _indexBuffer;
  72952. private _vertexBuffers;
  72953. /**
  72954. * Creates a new instance PostProcess
  72955. * @param scene The scene that the post process is associated with.
  72956. */
  72957. constructor(scene: Scene);
  72958. private _prepareBuffers;
  72959. private _buildIndexBuffer;
  72960. /**
  72961. * Rebuilds the vertex buffers of the manager.
  72962. * @hidden
  72963. */
  72964. _rebuild(): void;
  72965. /**
  72966. * Prepares a frame to be run through a post process.
  72967. * @param sourceTexture The input texture to the post procesess. (default: null)
  72968. * @param postProcesses An array of post processes to be run. (default: null)
  72969. * @returns True if the post processes were able to be run.
  72970. * @hidden
  72971. */
  72972. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  72973. /**
  72974. * Manually render a set of post processes to a texture.
  72975. * @param postProcesses An array of post processes to be run.
  72976. * @param targetTexture The target texture to render to.
  72977. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  72978. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  72979. * @param lodLevel defines which lod of the texture to render to
  72980. */
  72981. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  72982. /**
  72983. * Finalize the result of the output of the postprocesses.
  72984. * @param doNotPresent If true the result will not be displayed to the screen.
  72985. * @param targetTexture The target texture to render to.
  72986. * @param faceIndex The index of the face to bind the target texture to.
  72987. * @param postProcesses The array of post processes to render.
  72988. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  72989. * @hidden
  72990. */
  72991. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  72992. /**
  72993. * Disposes of the post process manager.
  72994. */
  72995. dispose(): void;
  72996. }
  72997. }
  72998. declare module BABYLON {
  72999. interface AbstractScene {
  73000. /**
  73001. * The list of layers (background and foreground) of the scene
  73002. */
  73003. layers: Array<Layer>;
  73004. }
  73005. /**
  73006. * Defines the layer scene component responsible to manage any layers
  73007. * in a given scene.
  73008. */
  73009. export class LayerSceneComponent implements ISceneComponent {
  73010. /**
  73011. * The component name helpfull to identify the component in the list of scene components.
  73012. */
  73013. readonly name: string;
  73014. /**
  73015. * The scene the component belongs to.
  73016. */
  73017. scene: Scene;
  73018. private _engine;
  73019. /**
  73020. * Creates a new instance of the component for the given scene
  73021. * @param scene Defines the scene to register the component in
  73022. */
  73023. constructor(scene: Scene);
  73024. /**
  73025. * Registers the component in a given scene
  73026. */
  73027. register(): void;
  73028. /**
  73029. * Rebuilds the elements related to this component in case of
  73030. * context lost for instance.
  73031. */
  73032. rebuild(): void;
  73033. /**
  73034. * Disposes the component and the associated ressources.
  73035. */
  73036. dispose(): void;
  73037. private _draw;
  73038. private _drawCameraPredicate;
  73039. private _drawCameraBackground;
  73040. private _drawCameraForeground;
  73041. private _drawRenderTargetPredicate;
  73042. private _drawRenderTargetBackground;
  73043. private _drawRenderTargetForeground;
  73044. }
  73045. }
  73046. declare module BABYLON {
  73047. /** @hidden */
  73048. export var layerPixelShader: {
  73049. name: string;
  73050. shader: string;
  73051. };
  73052. }
  73053. declare module BABYLON {
  73054. /** @hidden */
  73055. export var layerVertexShader: {
  73056. name: string;
  73057. shader: string;
  73058. };
  73059. }
  73060. declare module BABYLON {
  73061. /**
  73062. * This represents a full screen 2d layer.
  73063. * This can be useful to display a picture in the background of your scene for instance.
  73064. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73065. */
  73066. export class Layer {
  73067. /**
  73068. * Define the name of the layer.
  73069. */
  73070. name: string;
  73071. /**
  73072. * Define the texture the layer should display.
  73073. */
  73074. texture: Nullable<Texture>;
  73075. /**
  73076. * Is the layer in background or foreground.
  73077. */
  73078. isBackground: boolean;
  73079. /**
  73080. * Define the color of the layer (instead of texture).
  73081. */
  73082. color: Color4;
  73083. /**
  73084. * Define the scale of the layer in order to zoom in out of the texture.
  73085. */
  73086. scale: Vector2;
  73087. /**
  73088. * Define an offset for the layer in order to shift the texture.
  73089. */
  73090. offset: Vector2;
  73091. /**
  73092. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73093. */
  73094. alphaBlendingMode: number;
  73095. /**
  73096. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73097. * Alpha test will not mix with the background color in case of transparency.
  73098. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73099. */
  73100. alphaTest: boolean;
  73101. /**
  73102. * Define a mask to restrict the layer to only some of the scene cameras.
  73103. */
  73104. layerMask: number;
  73105. /**
  73106. * Define the list of render target the layer is visible into.
  73107. */
  73108. renderTargetTextures: RenderTargetTexture[];
  73109. /**
  73110. * Define if the layer is only used in renderTarget or if it also
  73111. * renders in the main frame buffer of the canvas.
  73112. */
  73113. renderOnlyInRenderTargetTextures: boolean;
  73114. private _scene;
  73115. private _vertexBuffers;
  73116. private _indexBuffer;
  73117. private _effect;
  73118. private _alphaTestEffect;
  73119. /**
  73120. * An event triggered when the layer is disposed.
  73121. */
  73122. onDisposeObservable: Observable<Layer>;
  73123. private _onDisposeObserver;
  73124. /**
  73125. * Back compatibility with callback before the onDisposeObservable existed.
  73126. * The set callback will be triggered when the layer has been disposed.
  73127. */
  73128. onDispose: () => void;
  73129. /**
  73130. * An event triggered before rendering the scene
  73131. */
  73132. onBeforeRenderObservable: Observable<Layer>;
  73133. private _onBeforeRenderObserver;
  73134. /**
  73135. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73136. * The set callback will be triggered just before rendering the layer.
  73137. */
  73138. onBeforeRender: () => void;
  73139. /**
  73140. * An event triggered after rendering the scene
  73141. */
  73142. onAfterRenderObservable: Observable<Layer>;
  73143. private _onAfterRenderObserver;
  73144. /**
  73145. * Back compatibility with callback before the onAfterRenderObservable existed.
  73146. * The set callback will be triggered just after rendering the layer.
  73147. */
  73148. onAfterRender: () => void;
  73149. /**
  73150. * Instantiates a new layer.
  73151. * This represents a full screen 2d layer.
  73152. * This can be useful to display a picture in the background of your scene for instance.
  73153. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73154. * @param name Define the name of the layer in the scene
  73155. * @param imgUrl Define the url of the texture to display in the layer
  73156. * @param scene Define the scene the layer belongs to
  73157. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  73158. * @param color Defines a color for the layer
  73159. */
  73160. constructor(
  73161. /**
  73162. * Define the name of the layer.
  73163. */
  73164. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  73165. private _createIndexBuffer;
  73166. /** @hidden */
  73167. _rebuild(): void;
  73168. /**
  73169. * Renders the layer in the scene.
  73170. */
  73171. render(): void;
  73172. /**
  73173. * Disposes and releases the associated ressources.
  73174. */
  73175. dispose(): void;
  73176. }
  73177. }
  73178. declare module BABYLON {
  73179. interface AbstractScene {
  73180. /**
  73181. * The list of procedural textures added to the scene
  73182. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73183. */
  73184. proceduralTextures: Array<ProceduralTexture>;
  73185. }
  73186. /**
  73187. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  73188. * in a given scene.
  73189. */
  73190. export class ProceduralTextureSceneComponent implements ISceneComponent {
  73191. /**
  73192. * The component name helpfull to identify the component in the list of scene components.
  73193. */
  73194. readonly name: string;
  73195. /**
  73196. * The scene the component belongs to.
  73197. */
  73198. scene: Scene;
  73199. /**
  73200. * Creates a new instance of the component for the given scene
  73201. * @param scene Defines the scene to register the component in
  73202. */
  73203. constructor(scene: Scene);
  73204. /**
  73205. * Registers the component in a given scene
  73206. */
  73207. register(): void;
  73208. /**
  73209. * Rebuilds the elements related to this component in case of
  73210. * context lost for instance.
  73211. */
  73212. rebuild(): void;
  73213. /**
  73214. * Disposes the component and the associated ressources.
  73215. */
  73216. dispose(): void;
  73217. private _beforeClear;
  73218. }
  73219. }
  73220. declare module BABYLON {
  73221. /** @hidden */
  73222. export var proceduralVertexShader: {
  73223. name: string;
  73224. shader: string;
  73225. };
  73226. }
  73227. declare module BABYLON {
  73228. /**
  73229. * 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.
  73230. * This is the base class of any Procedural texture and contains most of the shareable code.
  73231. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73232. */
  73233. export class ProceduralTexture extends Texture {
  73234. isCube: boolean;
  73235. /**
  73236. * Define if the texture is enabled or not (disabled texture will not render)
  73237. */
  73238. isEnabled: boolean;
  73239. /**
  73240. * Define if the texture must be cleared before rendering (default is true)
  73241. */
  73242. autoClear: boolean;
  73243. /**
  73244. * Callback called when the texture is generated
  73245. */
  73246. onGenerated: () => void;
  73247. /**
  73248. * Event raised when the texture is generated
  73249. */
  73250. onGeneratedObservable: Observable<ProceduralTexture>;
  73251. /** @hidden */
  73252. _generateMipMaps: boolean;
  73253. /** @hidden **/
  73254. _effect: Effect;
  73255. /** @hidden */
  73256. _textures: {
  73257. [key: string]: Texture;
  73258. };
  73259. private _size;
  73260. private _currentRefreshId;
  73261. private _refreshRate;
  73262. private _vertexBuffers;
  73263. private _indexBuffer;
  73264. private _uniforms;
  73265. private _samplers;
  73266. private _fragment;
  73267. private _floats;
  73268. private _ints;
  73269. private _floatsArrays;
  73270. private _colors3;
  73271. private _colors4;
  73272. private _vectors2;
  73273. private _vectors3;
  73274. private _matrices;
  73275. private _fallbackTexture;
  73276. private _fallbackTextureUsed;
  73277. private _engine;
  73278. private _cachedDefines;
  73279. private _contentUpdateId;
  73280. private _contentData;
  73281. /**
  73282. * Instantiates a new procedural texture.
  73283. * 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.
  73284. * This is the base class of any Procedural texture and contains most of the shareable code.
  73285. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73286. * @param name Define the name of the texture
  73287. * @param size Define the size of the texture to create
  73288. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  73289. * @param scene Define the scene the texture belongs to
  73290. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  73291. * @param generateMipMaps Define if the texture should creates mip maps or not
  73292. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  73293. */
  73294. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  73295. /**
  73296. * The effect that is created when initializing the post process.
  73297. * @returns The created effect corrisponding the the postprocess.
  73298. */
  73299. getEffect(): Effect;
  73300. /**
  73301. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  73302. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  73303. */
  73304. getContent(): Nullable<ArrayBufferView>;
  73305. private _createIndexBuffer;
  73306. /** @hidden */
  73307. _rebuild(): void;
  73308. /**
  73309. * Resets the texture in order to recreate its associated resources.
  73310. * This can be called in case of context loss
  73311. */
  73312. reset(): void;
  73313. protected _getDefines(): string;
  73314. /**
  73315. * Is the texture ready to be used ? (rendered at least once)
  73316. * @returns true if ready, otherwise, false.
  73317. */
  73318. isReady(): boolean;
  73319. /**
  73320. * Resets the refresh counter of the texture and start bak from scratch.
  73321. * Could be useful to regenerate the texture if it is setup to render only once.
  73322. */
  73323. resetRefreshCounter(): void;
  73324. /**
  73325. * Set the fragment shader to use in order to render the texture.
  73326. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  73327. */
  73328. setFragment(fragment: any): void;
  73329. /**
  73330. * Define the refresh rate of the texture or the rendering frequency.
  73331. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73332. */
  73333. refreshRate: number;
  73334. /** @hidden */
  73335. _shouldRender(): boolean;
  73336. /**
  73337. * Get the size the texture is rendering at.
  73338. * @returns the size (texture is always squared)
  73339. */
  73340. getRenderSize(): number;
  73341. /**
  73342. * Resize the texture to new value.
  73343. * @param size Define the new size the texture should have
  73344. * @param generateMipMaps Define whether the new texture should create mip maps
  73345. */
  73346. resize(size: number, generateMipMaps: boolean): void;
  73347. private _checkUniform;
  73348. /**
  73349. * Set a texture in the shader program used to render.
  73350. * @param name Define the name of the uniform samplers as defined in the shader
  73351. * @param texture Define the texture to bind to this sampler
  73352. * @return the texture itself allowing "fluent" like uniform updates
  73353. */
  73354. setTexture(name: string, texture: Texture): ProceduralTexture;
  73355. /**
  73356. * Set a float in the shader.
  73357. * @param name Define the name of the uniform as defined in the shader
  73358. * @param value Define the value to give to the uniform
  73359. * @return the texture itself allowing "fluent" like uniform updates
  73360. */
  73361. setFloat(name: string, value: number): ProceduralTexture;
  73362. /**
  73363. * Set a int in the shader.
  73364. * @param name Define the name of the uniform as defined in the shader
  73365. * @param value Define the value to give to the uniform
  73366. * @return the texture itself allowing "fluent" like uniform updates
  73367. */
  73368. setInt(name: string, value: number): ProceduralTexture;
  73369. /**
  73370. * Set an array of floats in the shader.
  73371. * @param name Define the name of the uniform as defined in the shader
  73372. * @param value Define the value to give to the uniform
  73373. * @return the texture itself allowing "fluent" like uniform updates
  73374. */
  73375. setFloats(name: string, value: number[]): ProceduralTexture;
  73376. /**
  73377. * Set a vec3 in the shader from a Color3.
  73378. * @param name Define the name of the uniform as defined in the shader
  73379. * @param value Define the value to give to the uniform
  73380. * @return the texture itself allowing "fluent" like uniform updates
  73381. */
  73382. setColor3(name: string, value: Color3): ProceduralTexture;
  73383. /**
  73384. * Set a vec4 in the shader from a Color4.
  73385. * @param name Define the name of the uniform as defined in the shader
  73386. * @param value Define the value to give to the uniform
  73387. * @return the texture itself allowing "fluent" like uniform updates
  73388. */
  73389. setColor4(name: string, value: Color4): ProceduralTexture;
  73390. /**
  73391. * Set a vec2 in the shader from a Vector2.
  73392. * @param name Define the name of the uniform as defined in the shader
  73393. * @param value Define the value to give to the uniform
  73394. * @return the texture itself allowing "fluent" like uniform updates
  73395. */
  73396. setVector2(name: string, value: Vector2): ProceduralTexture;
  73397. /**
  73398. * Set a vec3 in the shader from a Vector3.
  73399. * @param name Define the name of the uniform as defined in the shader
  73400. * @param value Define the value to give to the uniform
  73401. * @return the texture itself allowing "fluent" like uniform updates
  73402. */
  73403. setVector3(name: string, value: Vector3): ProceduralTexture;
  73404. /**
  73405. * Set a mat4 in the shader from a MAtrix.
  73406. * @param name Define the name of the uniform as defined in the shader
  73407. * @param value Define the value to give to the uniform
  73408. * @return the texture itself allowing "fluent" like uniform updates
  73409. */
  73410. setMatrix(name: string, value: Matrix): ProceduralTexture;
  73411. /**
  73412. * Render the texture to its associated render target.
  73413. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  73414. */
  73415. render(useCameraPostProcess?: boolean): void;
  73416. /**
  73417. * Clone the texture.
  73418. * @returns the cloned texture
  73419. */
  73420. clone(): ProceduralTexture;
  73421. /**
  73422. * Dispose the texture and release its asoociated resources.
  73423. */
  73424. dispose(): void;
  73425. }
  73426. }
  73427. declare module BABYLON {
  73428. /**
  73429. * This represents the base class for particle system in Babylon.
  73430. * 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.
  73431. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73432. * @example https://doc.babylonjs.com/babylon101/particles
  73433. */
  73434. export class BaseParticleSystem {
  73435. /**
  73436. * Source color is added to the destination color without alpha affecting the result
  73437. */
  73438. static BLENDMODE_ONEONE: number;
  73439. /**
  73440. * Blend current color and particle color using particle’s alpha
  73441. */
  73442. static BLENDMODE_STANDARD: number;
  73443. /**
  73444. * Add current color and particle color multiplied by particle’s alpha
  73445. */
  73446. static BLENDMODE_ADD: number;
  73447. /**
  73448. * Multiply current color with particle color
  73449. */
  73450. static BLENDMODE_MULTIPLY: number;
  73451. /**
  73452. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  73453. */
  73454. static BLENDMODE_MULTIPLYADD: number;
  73455. /**
  73456. * List of animations used by the particle system.
  73457. */
  73458. animations: Animation[];
  73459. /**
  73460. * The id of the Particle system.
  73461. */
  73462. id: string;
  73463. /**
  73464. * The friendly name of the Particle system.
  73465. */
  73466. name: string;
  73467. /**
  73468. * The rendering group used by the Particle system to chose when to render.
  73469. */
  73470. renderingGroupId: number;
  73471. /**
  73472. * The emitter represents the Mesh or position we are attaching the particle system to.
  73473. */
  73474. emitter: Nullable<AbstractMesh | Vector3>;
  73475. /**
  73476. * The maximum number of particles to emit per frame
  73477. */
  73478. emitRate: number;
  73479. /**
  73480. * If you want to launch only a few particles at once, that can be done, as well.
  73481. */
  73482. manualEmitCount: number;
  73483. /**
  73484. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73485. */
  73486. updateSpeed: number;
  73487. /**
  73488. * The amount of time the particle system is running (depends of the overall update speed).
  73489. */
  73490. targetStopDuration: number;
  73491. /**
  73492. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73493. */
  73494. disposeOnStop: boolean;
  73495. /**
  73496. * Minimum power of emitting particles.
  73497. */
  73498. minEmitPower: number;
  73499. /**
  73500. * Maximum power of emitting particles.
  73501. */
  73502. maxEmitPower: number;
  73503. /**
  73504. * Minimum life time of emitting particles.
  73505. */
  73506. minLifeTime: number;
  73507. /**
  73508. * Maximum life time of emitting particles.
  73509. */
  73510. maxLifeTime: number;
  73511. /**
  73512. * Minimum Size of emitting particles.
  73513. */
  73514. minSize: number;
  73515. /**
  73516. * Maximum Size of emitting particles.
  73517. */
  73518. maxSize: number;
  73519. /**
  73520. * Minimum scale of emitting particles on X axis.
  73521. */
  73522. minScaleX: number;
  73523. /**
  73524. * Maximum scale of emitting particles on X axis.
  73525. */
  73526. maxScaleX: number;
  73527. /**
  73528. * Minimum scale of emitting particles on Y axis.
  73529. */
  73530. minScaleY: number;
  73531. /**
  73532. * Maximum scale of emitting particles on Y axis.
  73533. */
  73534. maxScaleY: number;
  73535. /**
  73536. * Gets or sets the minimal initial rotation in radians.
  73537. */
  73538. minInitialRotation: number;
  73539. /**
  73540. * Gets or sets the maximal initial rotation in radians.
  73541. */
  73542. maxInitialRotation: number;
  73543. /**
  73544. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73545. */
  73546. minAngularSpeed: number;
  73547. /**
  73548. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73549. */
  73550. maxAngularSpeed: number;
  73551. /**
  73552. * The texture used to render each particle. (this can be a spritesheet)
  73553. */
  73554. particleTexture: Nullable<Texture>;
  73555. /**
  73556. * The layer mask we are rendering the particles through.
  73557. */
  73558. layerMask: number;
  73559. /**
  73560. * This can help using your own shader to render the particle system.
  73561. * The according effect will be created
  73562. */
  73563. customShader: any;
  73564. /**
  73565. * By default particle system starts as soon as they are created. This prevents the
  73566. * automatic start to happen and let you decide when to start emitting particles.
  73567. */
  73568. preventAutoStart: boolean;
  73569. private _noiseTexture;
  73570. /**
  73571. * Gets or sets a texture used to add random noise to particle positions
  73572. */
  73573. noiseTexture: Nullable<ProceduralTexture>;
  73574. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73575. noiseStrength: Vector3;
  73576. /**
  73577. * Callback triggered when the particle animation is ending.
  73578. */
  73579. onAnimationEnd: Nullable<() => void>;
  73580. /**
  73581. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  73582. */
  73583. blendMode: number;
  73584. /**
  73585. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  73586. * to override the particles.
  73587. */
  73588. forceDepthWrite: boolean;
  73589. /** 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 */
  73590. preWarmCycles: number;
  73591. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  73592. preWarmStepOffset: number;
  73593. /**
  73594. * 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)
  73595. */
  73596. spriteCellChangeSpeed: number;
  73597. /**
  73598. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73599. */
  73600. startSpriteCellID: number;
  73601. /**
  73602. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73603. */
  73604. endSpriteCellID: number;
  73605. /**
  73606. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73607. */
  73608. spriteCellWidth: number;
  73609. /**
  73610. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73611. */
  73612. spriteCellHeight: number;
  73613. /**
  73614. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73615. */
  73616. spriteRandomStartCell: boolean;
  73617. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73618. translationPivot: Vector2;
  73619. /** @hidden */
  73620. protected _isAnimationSheetEnabled: boolean;
  73621. /**
  73622. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73623. */
  73624. beginAnimationOnStart: boolean;
  73625. /**
  73626. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73627. */
  73628. beginAnimationFrom: number;
  73629. /**
  73630. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73631. */
  73632. beginAnimationTo: number;
  73633. /**
  73634. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73635. */
  73636. beginAnimationLoop: boolean;
  73637. /**
  73638. * Gets or sets a world offset applied to all particles
  73639. */
  73640. worldOffset: Vector3;
  73641. /**
  73642. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  73643. */
  73644. isAnimationSheetEnabled: boolean;
  73645. /**
  73646. * Get hosting scene
  73647. * @returns the scene
  73648. */
  73649. getScene(): Scene;
  73650. /**
  73651. * You can use gravity if you want to give an orientation to your particles.
  73652. */
  73653. gravity: Vector3;
  73654. protected _colorGradients: Nullable<Array<ColorGradient>>;
  73655. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  73656. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  73657. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  73658. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  73659. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  73660. protected _dragGradients: Nullable<Array<FactorGradient>>;
  73661. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  73662. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  73663. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  73664. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  73665. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  73666. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  73667. /**
  73668. * Defines the delay in milliseconds before starting the system (0 by default)
  73669. */
  73670. startDelay: number;
  73671. /**
  73672. * Gets the current list of drag gradients.
  73673. * You must use addDragGradient and removeDragGradient to udpate this list
  73674. * @returns the list of drag gradients
  73675. */
  73676. getDragGradients(): Nullable<Array<FactorGradient>>;
  73677. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73678. limitVelocityDamping: number;
  73679. /**
  73680. * Gets the current list of limit velocity gradients.
  73681. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73682. * @returns the list of limit velocity gradients
  73683. */
  73684. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73685. /**
  73686. * Gets the current list of color gradients.
  73687. * You must use addColorGradient and removeColorGradient to udpate this list
  73688. * @returns the list of color gradients
  73689. */
  73690. getColorGradients(): Nullable<Array<ColorGradient>>;
  73691. /**
  73692. * Gets the current list of size gradients.
  73693. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73694. * @returns the list of size gradients
  73695. */
  73696. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73697. /**
  73698. * Gets the current list of color remap gradients.
  73699. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73700. * @returns the list of color remap gradients
  73701. */
  73702. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73703. /**
  73704. * Gets the current list of alpha remap gradients.
  73705. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73706. * @returns the list of alpha remap gradients
  73707. */
  73708. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73709. /**
  73710. * Gets the current list of life time gradients.
  73711. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73712. * @returns the list of life time gradients
  73713. */
  73714. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73715. /**
  73716. * Gets the current list of angular speed gradients.
  73717. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73718. * @returns the list of angular speed gradients
  73719. */
  73720. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73721. /**
  73722. * Gets the current list of velocity gradients.
  73723. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73724. * @returns the list of velocity gradients
  73725. */
  73726. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73727. /**
  73728. * Gets the current list of start size gradients.
  73729. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73730. * @returns the list of start size gradients
  73731. */
  73732. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73733. /**
  73734. * Gets the current list of emit rate gradients.
  73735. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73736. * @returns the list of emit rate gradients
  73737. */
  73738. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73739. /**
  73740. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73741. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73742. */
  73743. direction1: Vector3;
  73744. /**
  73745. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73746. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73747. */
  73748. direction2: Vector3;
  73749. /**
  73750. * 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.
  73751. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73752. */
  73753. minEmitBox: Vector3;
  73754. /**
  73755. * 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.
  73756. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73757. */
  73758. maxEmitBox: Vector3;
  73759. /**
  73760. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73761. */
  73762. color1: Color4;
  73763. /**
  73764. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73765. */
  73766. color2: Color4;
  73767. /**
  73768. * Color the particle will have at the end of its lifetime
  73769. */
  73770. colorDead: Color4;
  73771. /**
  73772. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  73773. */
  73774. textureMask: Color4;
  73775. /**
  73776. * The particle emitter type defines the emitter used by the particle system.
  73777. * It can be for example box, sphere, or cone...
  73778. */
  73779. particleEmitterType: IParticleEmitterType;
  73780. /** @hidden */
  73781. _isSubEmitter: boolean;
  73782. /**
  73783. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73784. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73785. */
  73786. billboardMode: number;
  73787. protected _isBillboardBased: boolean;
  73788. /**
  73789. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73790. */
  73791. isBillboardBased: boolean;
  73792. /**
  73793. * The scene the particle system belongs to.
  73794. */
  73795. protected _scene: Scene;
  73796. /**
  73797. * Local cache of defines for image processing.
  73798. */
  73799. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  73800. /**
  73801. * Default configuration related to image processing available in the standard Material.
  73802. */
  73803. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  73804. /**
  73805. * Gets the image processing configuration used either in this material.
  73806. */
  73807. /**
  73808. * Sets the Default image processing configuration used either in the this material.
  73809. *
  73810. * If sets to null, the scene one is in use.
  73811. */
  73812. imageProcessingConfiguration: ImageProcessingConfiguration;
  73813. /**
  73814. * Attaches a new image processing configuration to the Standard Material.
  73815. * @param configuration
  73816. */
  73817. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  73818. /** @hidden */
  73819. protected _reset(): void;
  73820. /** @hidden */
  73821. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  73822. /**
  73823. * Instantiates a particle system.
  73824. * 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.
  73825. * @param name The name of the particle system
  73826. */
  73827. constructor(name: string);
  73828. /**
  73829. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73830. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73831. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73832. * @returns the emitter
  73833. */
  73834. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73835. /**
  73836. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73837. * @param radius The radius of the hemisphere to emit from
  73838. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73839. * @returns the emitter
  73840. */
  73841. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  73842. /**
  73843. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73844. * @param radius The radius of the sphere to emit from
  73845. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73846. * @returns the emitter
  73847. */
  73848. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  73849. /**
  73850. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73851. * @param radius The radius of the sphere to emit from
  73852. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73853. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73854. * @returns the emitter
  73855. */
  73856. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  73857. /**
  73858. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73859. * @param radius The radius of the emission cylinder
  73860. * @param height The height of the emission cylinder
  73861. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73862. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73863. * @returns the emitter
  73864. */
  73865. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  73866. /**
  73867. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73868. * @param radius The radius of the cylinder to emit from
  73869. * @param height The height of the emission cylinder
  73870. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73871. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73872. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73873. * @returns the emitter
  73874. */
  73875. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  73876. /**
  73877. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73878. * @param radius The radius of the cone to emit from
  73879. * @param angle The base angle of the cone
  73880. * @returns the emitter
  73881. */
  73882. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  73883. /**
  73884. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73885. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73886. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73887. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73888. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73889. * @returns the emitter
  73890. */
  73891. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73892. }
  73893. }
  73894. declare module BABYLON {
  73895. /**
  73896. * Type of sub emitter
  73897. */
  73898. export enum SubEmitterType {
  73899. /**
  73900. * Attached to the particle over it's lifetime
  73901. */
  73902. ATTACHED = 0,
  73903. /**
  73904. * Created when the particle dies
  73905. */
  73906. END = 1
  73907. }
  73908. /**
  73909. * Sub emitter class used to emit particles from an existing particle
  73910. */
  73911. export class SubEmitter {
  73912. /**
  73913. * the particle system to be used by the sub emitter
  73914. */
  73915. particleSystem: ParticleSystem;
  73916. /**
  73917. * Type of the submitter (Default: END)
  73918. */
  73919. type: SubEmitterType;
  73920. /**
  73921. * 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)
  73922. * Note: This only is supported when using an emitter of type Mesh
  73923. */
  73924. inheritDirection: boolean;
  73925. /**
  73926. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  73927. */
  73928. inheritedVelocityAmount: number;
  73929. /**
  73930. * Creates a sub emitter
  73931. * @param particleSystem the particle system to be used by the sub emitter
  73932. */
  73933. constructor(
  73934. /**
  73935. * the particle system to be used by the sub emitter
  73936. */
  73937. particleSystem: ParticleSystem);
  73938. /**
  73939. * Clones the sub emitter
  73940. * @returns the cloned sub emitter
  73941. */
  73942. clone(): SubEmitter;
  73943. /**
  73944. * Serialize current object to a JSON object
  73945. * @returns the serialized object
  73946. */
  73947. serialize(): any;
  73948. /** @hidden */
  73949. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  73950. /**
  73951. * Creates a new SubEmitter from a serialized JSON version
  73952. * @param serializationObject defines the JSON object to read from
  73953. * @param scene defines the hosting scene
  73954. * @param rootUrl defines the rootUrl for data loading
  73955. * @returns a new SubEmitter
  73956. */
  73957. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  73958. /** Release associated resources */
  73959. dispose(): void;
  73960. }
  73961. }
  73962. declare module BABYLON {
  73963. /** @hidden */
  73964. export var clipPlaneFragmentDeclaration: {
  73965. name: string;
  73966. shader: string;
  73967. };
  73968. }
  73969. declare module BABYLON {
  73970. /** @hidden */
  73971. export var imageProcessingDeclaration: {
  73972. name: string;
  73973. shader: string;
  73974. };
  73975. }
  73976. declare module BABYLON {
  73977. /** @hidden */
  73978. export var imageProcessingFunctions: {
  73979. name: string;
  73980. shader: string;
  73981. };
  73982. }
  73983. declare module BABYLON {
  73984. /** @hidden */
  73985. export var clipPlaneFragment: {
  73986. name: string;
  73987. shader: string;
  73988. };
  73989. }
  73990. declare module BABYLON {
  73991. /** @hidden */
  73992. export var particlesPixelShader: {
  73993. name: string;
  73994. shader: string;
  73995. };
  73996. }
  73997. declare module BABYLON {
  73998. /** @hidden */
  73999. export var clipPlaneVertexDeclaration: {
  74000. name: string;
  74001. shader: string;
  74002. };
  74003. }
  74004. declare module BABYLON {
  74005. /** @hidden */
  74006. export var clipPlaneVertex: {
  74007. name: string;
  74008. shader: string;
  74009. };
  74010. }
  74011. declare module BABYLON {
  74012. /** @hidden */
  74013. export var particlesVertexShader: {
  74014. name: string;
  74015. shader: string;
  74016. };
  74017. }
  74018. declare module BABYLON {
  74019. /**
  74020. * This represents a particle system in Babylon.
  74021. * 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.
  74022. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74023. * @example https://doc.babylonjs.com/babylon101/particles
  74024. */
  74025. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74026. /**
  74027. * Billboard mode will only apply to Y axis
  74028. */
  74029. static readonly BILLBOARDMODE_Y: number;
  74030. /**
  74031. * Billboard mode will apply to all axes
  74032. */
  74033. static readonly BILLBOARDMODE_ALL: number;
  74034. /**
  74035. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74036. */
  74037. static readonly BILLBOARDMODE_STRETCHED: number;
  74038. /**
  74039. * This function can be defined to provide custom update for active particles.
  74040. * This function will be called instead of regular update (age, position, color, etc.).
  74041. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74042. */
  74043. updateFunction: (particles: Particle[]) => void;
  74044. private _emitterWorldMatrix;
  74045. /**
  74046. * This function can be defined to specify initial direction for every new particle.
  74047. * It by default use the emitterType defined function
  74048. */
  74049. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74050. /**
  74051. * This function can be defined to specify initial position for every new particle.
  74052. * It by default use the emitterType defined function
  74053. */
  74054. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74055. /**
  74056. * @hidden
  74057. */
  74058. _inheritedVelocityOffset: Vector3;
  74059. /**
  74060. * An event triggered when the system is disposed
  74061. */
  74062. onDisposeObservable: Observable<ParticleSystem>;
  74063. private _onDisposeObserver;
  74064. /**
  74065. * Sets a callback that will be triggered when the system is disposed
  74066. */
  74067. onDispose: () => void;
  74068. private _particles;
  74069. private _epsilon;
  74070. private _capacity;
  74071. private _stockParticles;
  74072. private _newPartsExcess;
  74073. private _vertexData;
  74074. private _vertexBuffer;
  74075. private _vertexBuffers;
  74076. private _spriteBuffer;
  74077. private _indexBuffer;
  74078. private _effect;
  74079. private _customEffect;
  74080. private _cachedDefines;
  74081. private _scaledColorStep;
  74082. private _colorDiff;
  74083. private _scaledDirection;
  74084. private _scaledGravity;
  74085. private _currentRenderId;
  74086. private _alive;
  74087. private _useInstancing;
  74088. private _started;
  74089. private _stopped;
  74090. private _actualFrame;
  74091. private _scaledUpdateSpeed;
  74092. private _vertexBufferSize;
  74093. /** @hidden */
  74094. _currentEmitRateGradient: Nullable<FactorGradient>;
  74095. /** @hidden */
  74096. _currentEmitRate1: number;
  74097. /** @hidden */
  74098. _currentEmitRate2: number;
  74099. /** @hidden */
  74100. _currentStartSizeGradient: Nullable<FactorGradient>;
  74101. /** @hidden */
  74102. _currentStartSize1: number;
  74103. /** @hidden */
  74104. _currentStartSize2: number;
  74105. private readonly _rawTextureWidth;
  74106. private _rampGradientsTexture;
  74107. private _useRampGradients;
  74108. /** Gets or sets a boolean indicating that ramp gradients must be used
  74109. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74110. */
  74111. useRampGradients: boolean;
  74112. /**
  74113. * 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.
  74114. * 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: [])
  74115. */
  74116. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74117. private _subEmitters;
  74118. /**
  74119. * @hidden
  74120. * If the particle systems emitter should be disposed when the particle system is disposed
  74121. */
  74122. _disposeEmitterOnDispose: boolean;
  74123. /**
  74124. * The current active Sub-systems, this property is used by the root particle system only.
  74125. */
  74126. activeSubSystems: Array<ParticleSystem>;
  74127. private _rootParticleSystem;
  74128. /**
  74129. * Gets the current list of active particles
  74130. */
  74131. readonly particles: Particle[];
  74132. /**
  74133. * Returns the string "ParticleSystem"
  74134. * @returns a string containing the class name
  74135. */
  74136. getClassName(): string;
  74137. /**
  74138. * Instantiates a particle system.
  74139. * 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.
  74140. * @param name The name of the particle system
  74141. * @param capacity The max number of particles alive at the same time
  74142. * @param scene The scene the particle system belongs to
  74143. * @param customEffect a custom effect used to change the way particles are rendered by default
  74144. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  74145. * @param epsilon Offset used to render the particles
  74146. */
  74147. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  74148. private _addFactorGradient;
  74149. private _removeFactorGradient;
  74150. /**
  74151. * Adds a new life time gradient
  74152. * @param gradient defines the gradient to use (between 0 and 1)
  74153. * @param factor defines the life time factor to affect to the specified gradient
  74154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74155. * @returns the current particle system
  74156. */
  74157. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74158. /**
  74159. * Remove a specific life time gradient
  74160. * @param gradient defines the gradient to remove
  74161. * @returns the current particle system
  74162. */
  74163. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74164. /**
  74165. * Adds a new size gradient
  74166. * @param gradient defines the gradient to use (between 0 and 1)
  74167. * @param factor defines the size factor to affect to the specified gradient
  74168. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74169. * @returns the current particle system
  74170. */
  74171. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74172. /**
  74173. * Remove a specific size gradient
  74174. * @param gradient defines the gradient to remove
  74175. * @returns the current particle system
  74176. */
  74177. removeSizeGradient(gradient: number): IParticleSystem;
  74178. /**
  74179. * Adds a new color remap gradient
  74180. * @param gradient defines the gradient to use (between 0 and 1)
  74181. * @param min defines the color remap minimal range
  74182. * @param max defines the color remap maximal range
  74183. * @returns the current particle system
  74184. */
  74185. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74186. /**
  74187. * Remove a specific color remap gradient
  74188. * @param gradient defines the gradient to remove
  74189. * @returns the current particle system
  74190. */
  74191. removeColorRemapGradient(gradient: number): IParticleSystem;
  74192. /**
  74193. * Adds a new alpha remap gradient
  74194. * @param gradient defines the gradient to use (between 0 and 1)
  74195. * @param min defines the alpha remap minimal range
  74196. * @param max defines the alpha remap maximal range
  74197. * @returns the current particle system
  74198. */
  74199. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74200. /**
  74201. * Remove a specific alpha remap gradient
  74202. * @param gradient defines the gradient to remove
  74203. * @returns the current particle system
  74204. */
  74205. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  74206. /**
  74207. * Adds a new angular speed gradient
  74208. * @param gradient defines the gradient to use (between 0 and 1)
  74209. * @param factor defines the angular speed to affect to the specified gradient
  74210. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74211. * @returns the current particle system
  74212. */
  74213. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74214. /**
  74215. * Remove a specific angular speed gradient
  74216. * @param gradient defines the gradient to remove
  74217. * @returns the current particle system
  74218. */
  74219. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74220. /**
  74221. * Adds a new velocity gradient
  74222. * @param gradient defines the gradient to use (between 0 and 1)
  74223. * @param factor defines the velocity to affect to the specified gradient
  74224. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74225. * @returns the current particle system
  74226. */
  74227. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74228. /**
  74229. * Remove a specific velocity gradient
  74230. * @param gradient defines the gradient to remove
  74231. * @returns the current particle system
  74232. */
  74233. removeVelocityGradient(gradient: number): IParticleSystem;
  74234. /**
  74235. * Adds a new limit velocity gradient
  74236. * @param gradient defines the gradient to use (between 0 and 1)
  74237. * @param factor defines the limit velocity value to affect to the specified gradient
  74238. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74239. * @returns the current particle system
  74240. */
  74241. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74242. /**
  74243. * Remove a specific limit velocity gradient
  74244. * @param gradient defines the gradient to remove
  74245. * @returns the current particle system
  74246. */
  74247. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74248. /**
  74249. * Adds a new drag gradient
  74250. * @param gradient defines the gradient to use (between 0 and 1)
  74251. * @param factor defines the drag value to affect to the specified gradient
  74252. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74253. * @returns the current particle system
  74254. */
  74255. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74256. /**
  74257. * Remove a specific drag gradient
  74258. * @param gradient defines the gradient to remove
  74259. * @returns the current particle system
  74260. */
  74261. removeDragGradient(gradient: number): IParticleSystem;
  74262. /**
  74263. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74264. * @param gradient defines the gradient to use (between 0 and 1)
  74265. * @param factor defines the emit rate value to affect to the specified gradient
  74266. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74267. * @returns the current particle system
  74268. */
  74269. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74270. /**
  74271. * Remove a specific emit rate gradient
  74272. * @param gradient defines the gradient to remove
  74273. * @returns the current particle system
  74274. */
  74275. removeEmitRateGradient(gradient: number): IParticleSystem;
  74276. /**
  74277. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74278. * @param gradient defines the gradient to use (between 0 and 1)
  74279. * @param factor defines the start size value to affect to the specified gradient
  74280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74281. * @returns the current particle system
  74282. */
  74283. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74284. /**
  74285. * Remove a specific start size gradient
  74286. * @param gradient defines the gradient to remove
  74287. * @returns the current particle system
  74288. */
  74289. removeStartSizeGradient(gradient: number): IParticleSystem;
  74290. private _createRampGradientTexture;
  74291. /**
  74292. * Gets the current list of ramp gradients.
  74293. * You must use addRampGradient and removeRampGradient to udpate this list
  74294. * @returns the list of ramp gradients
  74295. */
  74296. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74297. /**
  74298. * Adds a new ramp gradient used to remap particle colors
  74299. * @param gradient defines the gradient to use (between 0 and 1)
  74300. * @param color defines the color to affect to the specified gradient
  74301. * @returns the current particle system
  74302. */
  74303. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  74304. /**
  74305. * Remove a specific ramp gradient
  74306. * @param gradient defines the gradient to remove
  74307. * @returns the current particle system
  74308. */
  74309. removeRampGradient(gradient: number): ParticleSystem;
  74310. /**
  74311. * Adds a new color gradient
  74312. * @param gradient defines the gradient to use (between 0 and 1)
  74313. * @param color1 defines the color to affect to the specified gradient
  74314. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74315. * @returns this particle system
  74316. */
  74317. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74318. /**
  74319. * Remove a specific color gradient
  74320. * @param gradient defines the gradient to remove
  74321. * @returns this particle system
  74322. */
  74323. removeColorGradient(gradient: number): IParticleSystem;
  74324. private _fetchR;
  74325. protected _reset(): void;
  74326. private _resetEffect;
  74327. private _createVertexBuffers;
  74328. private _createIndexBuffer;
  74329. /**
  74330. * Gets the maximum number of particles active at the same time.
  74331. * @returns The max number of active particles.
  74332. */
  74333. getCapacity(): number;
  74334. /**
  74335. * Gets whether there are still active particles in the system.
  74336. * @returns True if it is alive, otherwise false.
  74337. */
  74338. isAlive(): boolean;
  74339. /**
  74340. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74341. * @returns True if it has been started, otherwise false.
  74342. */
  74343. isStarted(): boolean;
  74344. private _prepareSubEmitterInternalArray;
  74345. /**
  74346. * Starts the particle system and begins to emit
  74347. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  74348. */
  74349. start(delay?: number): void;
  74350. /**
  74351. * Stops the particle system.
  74352. * @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.
  74353. */
  74354. stop(stopSubEmitters?: boolean): void;
  74355. /**
  74356. * Remove all active particles
  74357. */
  74358. reset(): void;
  74359. /**
  74360. * @hidden (for internal use only)
  74361. */
  74362. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  74363. /**
  74364. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  74365. * Its lifetime will start back at 0.
  74366. */
  74367. recycleParticle: (particle: Particle) => void;
  74368. private _stopSubEmitters;
  74369. private _createParticle;
  74370. private _removeFromRoot;
  74371. private _emitFromParticle;
  74372. private _update;
  74373. /** @hidden */
  74374. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  74375. /** @hidden */
  74376. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  74377. /** @hidden */
  74378. private _getEffect;
  74379. /**
  74380. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  74381. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  74382. */
  74383. animate(preWarmOnly?: boolean): void;
  74384. private _appendParticleVertices;
  74385. /**
  74386. * Rebuilds the particle system.
  74387. */
  74388. rebuild(): void;
  74389. /**
  74390. * Is this system ready to be used/rendered
  74391. * @return true if the system is ready
  74392. */
  74393. isReady(): boolean;
  74394. private _render;
  74395. /**
  74396. * Renders the particle system in its current state.
  74397. * @returns the current number of particles
  74398. */
  74399. render(): number;
  74400. /**
  74401. * Disposes the particle system and free the associated resources
  74402. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74403. */
  74404. dispose(disposeTexture?: boolean): void;
  74405. /**
  74406. * Clones the particle system.
  74407. * @param name The name of the cloned object
  74408. * @param newEmitter The new emitter to use
  74409. * @returns the cloned particle system
  74410. */
  74411. clone(name: string, newEmitter: any): ParticleSystem;
  74412. /**
  74413. * Serializes the particle system to a JSON object.
  74414. * @returns the JSON object
  74415. */
  74416. serialize(): any;
  74417. /** @hidden */
  74418. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  74419. /** @hidden */
  74420. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  74421. /**
  74422. * Parses a JSON object to create a particle system.
  74423. * @param parsedParticleSystem The JSON object to parse
  74424. * @param scene The scene to create the particle system in
  74425. * @param rootUrl The root url to use to load external dependencies like texture
  74426. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  74427. * @returns the Parsed particle system
  74428. */
  74429. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  74430. }
  74431. }
  74432. declare module BABYLON {
  74433. /**
  74434. * A particle represents one of the element emitted by a particle system.
  74435. * This is mainly define by its coordinates, direction, velocity and age.
  74436. */
  74437. export class Particle {
  74438. /**
  74439. * The particle system the particle belongs to.
  74440. */
  74441. particleSystem: ParticleSystem;
  74442. private static _Count;
  74443. /**
  74444. * Unique ID of the particle
  74445. */
  74446. id: number;
  74447. /**
  74448. * The world position of the particle in the scene.
  74449. */
  74450. position: Vector3;
  74451. /**
  74452. * The world direction of the particle in the scene.
  74453. */
  74454. direction: Vector3;
  74455. /**
  74456. * The color of the particle.
  74457. */
  74458. color: Color4;
  74459. /**
  74460. * The color change of the particle per step.
  74461. */
  74462. colorStep: Color4;
  74463. /**
  74464. * Defines how long will the life of the particle be.
  74465. */
  74466. lifeTime: number;
  74467. /**
  74468. * The current age of the particle.
  74469. */
  74470. age: number;
  74471. /**
  74472. * The current size of the particle.
  74473. */
  74474. size: number;
  74475. /**
  74476. * The current scale of the particle.
  74477. */
  74478. scale: Vector2;
  74479. /**
  74480. * The current angle of the particle.
  74481. */
  74482. angle: number;
  74483. /**
  74484. * Defines how fast is the angle changing.
  74485. */
  74486. angularSpeed: number;
  74487. /**
  74488. * Defines the cell index used by the particle to be rendered from a sprite.
  74489. */
  74490. cellIndex: number;
  74491. /**
  74492. * The information required to support color remapping
  74493. */
  74494. remapData: Vector4;
  74495. /** @hidden */
  74496. _randomCellOffset?: number;
  74497. /** @hidden */
  74498. _initialDirection: Nullable<Vector3>;
  74499. /** @hidden */
  74500. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  74501. /** @hidden */
  74502. _initialStartSpriteCellID: number;
  74503. /** @hidden */
  74504. _initialEndSpriteCellID: number;
  74505. /** @hidden */
  74506. _currentColorGradient: Nullable<ColorGradient>;
  74507. /** @hidden */
  74508. _currentColor1: Color4;
  74509. /** @hidden */
  74510. _currentColor2: Color4;
  74511. /** @hidden */
  74512. _currentSizeGradient: Nullable<FactorGradient>;
  74513. /** @hidden */
  74514. _currentSize1: number;
  74515. /** @hidden */
  74516. _currentSize2: number;
  74517. /** @hidden */
  74518. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  74519. /** @hidden */
  74520. _currentAngularSpeed1: number;
  74521. /** @hidden */
  74522. _currentAngularSpeed2: number;
  74523. /** @hidden */
  74524. _currentVelocityGradient: Nullable<FactorGradient>;
  74525. /** @hidden */
  74526. _currentVelocity1: number;
  74527. /** @hidden */
  74528. _currentVelocity2: number;
  74529. /** @hidden */
  74530. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  74531. /** @hidden */
  74532. _currentLimitVelocity1: number;
  74533. /** @hidden */
  74534. _currentLimitVelocity2: number;
  74535. /** @hidden */
  74536. _currentDragGradient: Nullable<FactorGradient>;
  74537. /** @hidden */
  74538. _currentDrag1: number;
  74539. /** @hidden */
  74540. _currentDrag2: number;
  74541. /** @hidden */
  74542. _randomNoiseCoordinates1: Vector3;
  74543. /** @hidden */
  74544. _randomNoiseCoordinates2: Vector3;
  74545. /**
  74546. * Creates a new instance Particle
  74547. * @param particleSystem the particle system the particle belongs to
  74548. */
  74549. constructor(
  74550. /**
  74551. * The particle system the particle belongs to.
  74552. */
  74553. particleSystem: ParticleSystem);
  74554. private updateCellInfoFromSystem;
  74555. /**
  74556. * Defines how the sprite cell index is updated for the particle
  74557. */
  74558. updateCellIndex(): void;
  74559. /** @hidden */
  74560. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  74561. /** @hidden */
  74562. _inheritParticleInfoToSubEmitters(): void;
  74563. /** @hidden */
  74564. _reset(): void;
  74565. /**
  74566. * Copy the properties of particle to another one.
  74567. * @param other the particle to copy the information to.
  74568. */
  74569. copyTo(other: Particle): void;
  74570. }
  74571. }
  74572. declare module BABYLON {
  74573. /**
  74574. * Particle emitter represents a volume emitting particles.
  74575. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  74576. */
  74577. export interface IParticleEmitterType {
  74578. /**
  74579. * Called by the particle System when the direction is computed for the created particle.
  74580. * @param worldMatrix is the world matrix of the particle system
  74581. * @param directionToUpdate is the direction vector to update with the result
  74582. * @param particle is the particle we are computed the direction for
  74583. */
  74584. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74585. /**
  74586. * Called by the particle System when the position is computed for the created particle.
  74587. * @param worldMatrix is the world matrix of the particle system
  74588. * @param positionToUpdate is the position vector to update with the result
  74589. * @param particle is the particle we are computed the position for
  74590. */
  74591. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74592. /**
  74593. * Clones the current emitter and returns a copy of it
  74594. * @returns the new emitter
  74595. */
  74596. clone(): IParticleEmitterType;
  74597. /**
  74598. * Called by the GPUParticleSystem to setup the update shader
  74599. * @param effect defines the update shader
  74600. */
  74601. applyToShader(effect: Effect): void;
  74602. /**
  74603. * Returns a string to use to update the GPU particles update shader
  74604. * @returns the effect defines string
  74605. */
  74606. getEffectDefines(): string;
  74607. /**
  74608. * Returns a string representing the class name
  74609. * @returns a string containing the class name
  74610. */
  74611. getClassName(): string;
  74612. /**
  74613. * Serializes the particle system to a JSON object.
  74614. * @returns the JSON object
  74615. */
  74616. serialize(): any;
  74617. /**
  74618. * Parse properties from a JSON object
  74619. * @param serializationObject defines the JSON object
  74620. */
  74621. parse(serializationObject: any): void;
  74622. }
  74623. }
  74624. declare module BABYLON {
  74625. /**
  74626. * Particle emitter emitting particles from the inside of a box.
  74627. * It emits the particles randomly between 2 given directions.
  74628. */
  74629. export class BoxParticleEmitter implements IParticleEmitterType {
  74630. /**
  74631. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74632. */
  74633. direction1: Vector3;
  74634. /**
  74635. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74636. */
  74637. direction2: Vector3;
  74638. /**
  74639. * 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.
  74640. */
  74641. minEmitBox: Vector3;
  74642. /**
  74643. * 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.
  74644. */
  74645. maxEmitBox: Vector3;
  74646. /**
  74647. * Creates a new instance BoxParticleEmitter
  74648. */
  74649. constructor();
  74650. /**
  74651. * Called by the particle System when the direction is computed for the created particle.
  74652. * @param worldMatrix is the world matrix of the particle system
  74653. * @param directionToUpdate is the direction vector to update with the result
  74654. * @param particle is the particle we are computed the direction for
  74655. */
  74656. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74657. /**
  74658. * Called by the particle System when the position is computed for the created particle.
  74659. * @param worldMatrix is the world matrix of the particle system
  74660. * @param positionToUpdate is the position vector to update with the result
  74661. * @param particle is the particle we are computed the position for
  74662. */
  74663. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74664. /**
  74665. * Clones the current emitter and returns a copy of it
  74666. * @returns the new emitter
  74667. */
  74668. clone(): BoxParticleEmitter;
  74669. /**
  74670. * Called by the GPUParticleSystem to setup the update shader
  74671. * @param effect defines the update shader
  74672. */
  74673. applyToShader(effect: Effect): void;
  74674. /**
  74675. * Returns a string to use to update the GPU particles update shader
  74676. * @returns a string containng the defines string
  74677. */
  74678. getEffectDefines(): string;
  74679. /**
  74680. * Returns the string "BoxParticleEmitter"
  74681. * @returns a string containing the class name
  74682. */
  74683. getClassName(): string;
  74684. /**
  74685. * Serializes the particle system to a JSON object.
  74686. * @returns the JSON object
  74687. */
  74688. serialize(): any;
  74689. /**
  74690. * Parse properties from a JSON object
  74691. * @param serializationObject defines the JSON object
  74692. */
  74693. parse(serializationObject: any): void;
  74694. }
  74695. }
  74696. declare module BABYLON {
  74697. /**
  74698. * Particle emitter emitting particles from the inside of a cone.
  74699. * It emits the particles alongside the cone volume from the base to the particle.
  74700. * The emission direction might be randomized.
  74701. */
  74702. export class ConeParticleEmitter implements IParticleEmitterType {
  74703. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74704. directionRandomizer: number;
  74705. private _radius;
  74706. private _angle;
  74707. private _height;
  74708. /**
  74709. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  74710. */
  74711. radiusRange: number;
  74712. /**
  74713. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  74714. */
  74715. heightRange: number;
  74716. /**
  74717. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  74718. */
  74719. emitFromSpawnPointOnly: boolean;
  74720. /**
  74721. * Gets or sets the radius of the emission cone
  74722. */
  74723. radius: number;
  74724. /**
  74725. * Gets or sets the angle of the emission cone
  74726. */
  74727. angle: number;
  74728. private _buildHeight;
  74729. /**
  74730. * Creates a new instance ConeParticleEmitter
  74731. * @param radius the radius of the emission cone (1 by default)
  74732. * @param angle the cone base angle (PI by default)
  74733. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  74734. */
  74735. constructor(radius?: number, angle?: number,
  74736. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74737. directionRandomizer?: number);
  74738. /**
  74739. * Called by the particle System when the direction is computed for the created particle.
  74740. * @param worldMatrix is the world matrix of the particle system
  74741. * @param directionToUpdate is the direction vector to update with the result
  74742. * @param particle is the particle we are computed the direction for
  74743. */
  74744. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74745. /**
  74746. * Called by the particle System when the position is computed for the created particle.
  74747. * @param worldMatrix is the world matrix of the particle system
  74748. * @param positionToUpdate is the position vector to update with the result
  74749. * @param particle is the particle we are computed the position for
  74750. */
  74751. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74752. /**
  74753. * Clones the current emitter and returns a copy of it
  74754. * @returns the new emitter
  74755. */
  74756. clone(): ConeParticleEmitter;
  74757. /**
  74758. * Called by the GPUParticleSystem to setup the update shader
  74759. * @param effect defines the update shader
  74760. */
  74761. applyToShader(effect: Effect): void;
  74762. /**
  74763. * Returns a string to use to update the GPU particles update shader
  74764. * @returns a string containng the defines string
  74765. */
  74766. getEffectDefines(): string;
  74767. /**
  74768. * Returns the string "ConeParticleEmitter"
  74769. * @returns a string containing the class name
  74770. */
  74771. getClassName(): string;
  74772. /**
  74773. * Serializes the particle system to a JSON object.
  74774. * @returns the JSON object
  74775. */
  74776. serialize(): any;
  74777. /**
  74778. * Parse properties from a JSON object
  74779. * @param serializationObject defines the JSON object
  74780. */
  74781. parse(serializationObject: any): void;
  74782. }
  74783. }
  74784. declare module BABYLON {
  74785. /**
  74786. * Particle emitter emitting particles from the inside of a cylinder.
  74787. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  74788. */
  74789. export class CylinderParticleEmitter implements IParticleEmitterType {
  74790. /**
  74791. * The radius of the emission cylinder.
  74792. */
  74793. radius: number;
  74794. /**
  74795. * The height of the emission cylinder.
  74796. */
  74797. height: number;
  74798. /**
  74799. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74800. */
  74801. radiusRange: number;
  74802. /**
  74803. * How much to randomize the particle direction [0-1].
  74804. */
  74805. directionRandomizer: number;
  74806. /**
  74807. * Creates a new instance CylinderParticleEmitter
  74808. * @param radius the radius of the emission cylinder (1 by default)
  74809. * @param height the height of the emission cylinder (1 by default)
  74810. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74811. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74812. */
  74813. constructor(
  74814. /**
  74815. * The radius of the emission cylinder.
  74816. */
  74817. radius?: number,
  74818. /**
  74819. * The height of the emission cylinder.
  74820. */
  74821. height?: number,
  74822. /**
  74823. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74824. */
  74825. radiusRange?: number,
  74826. /**
  74827. * How much to randomize the particle direction [0-1].
  74828. */
  74829. directionRandomizer?: number);
  74830. /**
  74831. * Called by the particle System when the direction is computed for the created particle.
  74832. * @param worldMatrix is the world matrix of the particle system
  74833. * @param directionToUpdate is the direction vector to update with the result
  74834. * @param particle is the particle we are computed the direction for
  74835. */
  74836. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74837. /**
  74838. * Called by the particle System when the position is computed for the created particle.
  74839. * @param worldMatrix is the world matrix of the particle system
  74840. * @param positionToUpdate is the position vector to update with the result
  74841. * @param particle is the particle we are computed the position for
  74842. */
  74843. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74844. /**
  74845. * Clones the current emitter and returns a copy of it
  74846. * @returns the new emitter
  74847. */
  74848. clone(): CylinderParticleEmitter;
  74849. /**
  74850. * Called by the GPUParticleSystem to setup the update shader
  74851. * @param effect defines the update shader
  74852. */
  74853. applyToShader(effect: Effect): void;
  74854. /**
  74855. * Returns a string to use to update the GPU particles update shader
  74856. * @returns a string containng the defines string
  74857. */
  74858. getEffectDefines(): string;
  74859. /**
  74860. * Returns the string "CylinderParticleEmitter"
  74861. * @returns a string containing the class name
  74862. */
  74863. getClassName(): string;
  74864. /**
  74865. * Serializes the particle system to a JSON object.
  74866. * @returns the JSON object
  74867. */
  74868. serialize(): any;
  74869. /**
  74870. * Parse properties from a JSON object
  74871. * @param serializationObject defines the JSON object
  74872. */
  74873. parse(serializationObject: any): void;
  74874. }
  74875. /**
  74876. * Particle emitter emitting particles from the inside of a cylinder.
  74877. * It emits the particles randomly between two vectors.
  74878. */
  74879. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  74880. /**
  74881. * The min limit of the emission direction.
  74882. */
  74883. direction1: Vector3;
  74884. /**
  74885. * The max limit of the emission direction.
  74886. */
  74887. direction2: Vector3;
  74888. /**
  74889. * Creates a new instance CylinderDirectedParticleEmitter
  74890. * @param radius the radius of the emission cylinder (1 by default)
  74891. * @param height the height of the emission cylinder (1 by default)
  74892. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74893. * @param direction1 the min limit of the emission direction (up vector by default)
  74894. * @param direction2 the max limit of the emission direction (up vector by default)
  74895. */
  74896. constructor(radius?: number, height?: number, radiusRange?: number,
  74897. /**
  74898. * The min limit of the emission direction.
  74899. */
  74900. direction1?: Vector3,
  74901. /**
  74902. * The max limit of the emission direction.
  74903. */
  74904. direction2?: Vector3);
  74905. /**
  74906. * Called by the particle System when the direction is computed for the created particle.
  74907. * @param worldMatrix is the world matrix of the particle system
  74908. * @param directionToUpdate is the direction vector to update with the result
  74909. * @param particle is the particle we are computed the direction for
  74910. */
  74911. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74912. /**
  74913. * Clones the current emitter and returns a copy of it
  74914. * @returns the new emitter
  74915. */
  74916. clone(): CylinderDirectedParticleEmitter;
  74917. /**
  74918. * Called by the GPUParticleSystem to setup the update shader
  74919. * @param effect defines the update shader
  74920. */
  74921. applyToShader(effect: Effect): void;
  74922. /**
  74923. * Returns a string to use to update the GPU particles update shader
  74924. * @returns a string containng the defines string
  74925. */
  74926. getEffectDefines(): string;
  74927. /**
  74928. * Returns the string "CylinderDirectedParticleEmitter"
  74929. * @returns a string containing the class name
  74930. */
  74931. getClassName(): string;
  74932. /**
  74933. * Serializes the particle system to a JSON object.
  74934. * @returns the JSON object
  74935. */
  74936. serialize(): any;
  74937. /**
  74938. * Parse properties from a JSON object
  74939. * @param serializationObject defines the JSON object
  74940. */
  74941. parse(serializationObject: any): void;
  74942. }
  74943. }
  74944. declare module BABYLON {
  74945. /**
  74946. * Particle emitter emitting particles from the inside of a hemisphere.
  74947. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  74948. */
  74949. export class HemisphericParticleEmitter implements IParticleEmitterType {
  74950. /**
  74951. * The radius of the emission hemisphere.
  74952. */
  74953. radius: number;
  74954. /**
  74955. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74956. */
  74957. radiusRange: number;
  74958. /**
  74959. * How much to randomize the particle direction [0-1].
  74960. */
  74961. directionRandomizer: number;
  74962. /**
  74963. * Creates a new instance HemisphericParticleEmitter
  74964. * @param radius the radius of the emission hemisphere (1 by default)
  74965. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74966. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74967. */
  74968. constructor(
  74969. /**
  74970. * The radius of the emission hemisphere.
  74971. */
  74972. radius?: number,
  74973. /**
  74974. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74975. */
  74976. radiusRange?: number,
  74977. /**
  74978. * How much to randomize the particle direction [0-1].
  74979. */
  74980. directionRandomizer?: number);
  74981. /**
  74982. * Called by the particle System when the direction is computed for the created particle.
  74983. * @param worldMatrix is the world matrix of the particle system
  74984. * @param directionToUpdate is the direction vector to update with the result
  74985. * @param particle is the particle we are computed the direction for
  74986. */
  74987. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74988. /**
  74989. * Called by the particle System when the position is computed for the created particle.
  74990. * @param worldMatrix is the world matrix of the particle system
  74991. * @param positionToUpdate is the position vector to update with the result
  74992. * @param particle is the particle we are computed the position for
  74993. */
  74994. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74995. /**
  74996. * Clones the current emitter and returns a copy of it
  74997. * @returns the new emitter
  74998. */
  74999. clone(): HemisphericParticleEmitter;
  75000. /**
  75001. * Called by the GPUParticleSystem to setup the update shader
  75002. * @param effect defines the update shader
  75003. */
  75004. applyToShader(effect: Effect): void;
  75005. /**
  75006. * Returns a string to use to update the GPU particles update shader
  75007. * @returns a string containng the defines string
  75008. */
  75009. getEffectDefines(): string;
  75010. /**
  75011. * Returns the string "HemisphericParticleEmitter"
  75012. * @returns a string containing the class name
  75013. */
  75014. getClassName(): string;
  75015. /**
  75016. * Serializes the particle system to a JSON object.
  75017. * @returns the JSON object
  75018. */
  75019. serialize(): any;
  75020. /**
  75021. * Parse properties from a JSON object
  75022. * @param serializationObject defines the JSON object
  75023. */
  75024. parse(serializationObject: any): void;
  75025. }
  75026. }
  75027. declare module BABYLON {
  75028. /**
  75029. * Particle emitter emitting particles from a point.
  75030. * It emits the particles randomly between 2 given directions.
  75031. */
  75032. export class PointParticleEmitter implements IParticleEmitterType {
  75033. /**
  75034. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75035. */
  75036. direction1: Vector3;
  75037. /**
  75038. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75039. */
  75040. direction2: Vector3;
  75041. /**
  75042. * Creates a new instance PointParticleEmitter
  75043. */
  75044. constructor();
  75045. /**
  75046. * Called by the particle System when the direction is computed for the created particle.
  75047. * @param worldMatrix is the world matrix of the particle system
  75048. * @param directionToUpdate is the direction vector to update with the result
  75049. * @param particle is the particle we are computed the direction for
  75050. */
  75051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75052. /**
  75053. * Called by the particle System when the position is computed for the created particle.
  75054. * @param worldMatrix is the world matrix of the particle system
  75055. * @param positionToUpdate is the position vector to update with the result
  75056. * @param particle is the particle we are computed the position for
  75057. */
  75058. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75059. /**
  75060. * Clones the current emitter and returns a copy of it
  75061. * @returns the new emitter
  75062. */
  75063. clone(): PointParticleEmitter;
  75064. /**
  75065. * Called by the GPUParticleSystem to setup the update shader
  75066. * @param effect defines the update shader
  75067. */
  75068. applyToShader(effect: Effect): void;
  75069. /**
  75070. * Returns a string to use to update the GPU particles update shader
  75071. * @returns a string containng the defines string
  75072. */
  75073. getEffectDefines(): string;
  75074. /**
  75075. * Returns the string "PointParticleEmitter"
  75076. * @returns a string containing the class name
  75077. */
  75078. getClassName(): string;
  75079. /**
  75080. * Serializes the particle system to a JSON object.
  75081. * @returns the JSON object
  75082. */
  75083. serialize(): any;
  75084. /**
  75085. * Parse properties from a JSON object
  75086. * @param serializationObject defines the JSON object
  75087. */
  75088. parse(serializationObject: any): void;
  75089. }
  75090. }
  75091. declare module BABYLON {
  75092. /**
  75093. * Particle emitter emitting particles from the inside of a sphere.
  75094. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75095. */
  75096. export class SphereParticleEmitter implements IParticleEmitterType {
  75097. /**
  75098. * The radius of the emission sphere.
  75099. */
  75100. radius: number;
  75101. /**
  75102. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75103. */
  75104. radiusRange: number;
  75105. /**
  75106. * How much to randomize the particle direction [0-1].
  75107. */
  75108. directionRandomizer: number;
  75109. /**
  75110. * Creates a new instance SphereParticleEmitter
  75111. * @param radius the radius of the emission sphere (1 by default)
  75112. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75113. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75114. */
  75115. constructor(
  75116. /**
  75117. * The radius of the emission sphere.
  75118. */
  75119. radius?: number,
  75120. /**
  75121. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75122. */
  75123. radiusRange?: number,
  75124. /**
  75125. * How much to randomize the particle direction [0-1].
  75126. */
  75127. directionRandomizer?: number);
  75128. /**
  75129. * Called by the particle System when the direction is computed for the created particle.
  75130. * @param worldMatrix is the world matrix of the particle system
  75131. * @param directionToUpdate is the direction vector to update with the result
  75132. * @param particle is the particle we are computed the direction for
  75133. */
  75134. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75135. /**
  75136. * Called by the particle System when the position is computed for the created particle.
  75137. * @param worldMatrix is the world matrix of the particle system
  75138. * @param positionToUpdate is the position vector to update with the result
  75139. * @param particle is the particle we are computed the position for
  75140. */
  75141. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75142. /**
  75143. * Clones the current emitter and returns a copy of it
  75144. * @returns the new emitter
  75145. */
  75146. clone(): SphereParticleEmitter;
  75147. /**
  75148. * Called by the GPUParticleSystem to setup the update shader
  75149. * @param effect defines the update shader
  75150. */
  75151. applyToShader(effect: Effect): void;
  75152. /**
  75153. * Returns a string to use to update the GPU particles update shader
  75154. * @returns a string containng the defines string
  75155. */
  75156. getEffectDefines(): string;
  75157. /**
  75158. * Returns the string "SphereParticleEmitter"
  75159. * @returns a string containing the class name
  75160. */
  75161. getClassName(): string;
  75162. /**
  75163. * Serializes the particle system to a JSON object.
  75164. * @returns the JSON object
  75165. */
  75166. serialize(): any;
  75167. /**
  75168. * Parse properties from a JSON object
  75169. * @param serializationObject defines the JSON object
  75170. */
  75171. parse(serializationObject: any): void;
  75172. }
  75173. /**
  75174. * Particle emitter emitting particles from the inside of a sphere.
  75175. * It emits the particles randomly between two vectors.
  75176. */
  75177. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  75178. /**
  75179. * The min limit of the emission direction.
  75180. */
  75181. direction1: Vector3;
  75182. /**
  75183. * The max limit of the emission direction.
  75184. */
  75185. direction2: Vector3;
  75186. /**
  75187. * Creates a new instance SphereDirectedParticleEmitter
  75188. * @param radius the radius of the emission sphere (1 by default)
  75189. * @param direction1 the min limit of the emission direction (up vector by default)
  75190. * @param direction2 the max limit of the emission direction (up vector by default)
  75191. */
  75192. constructor(radius?: number,
  75193. /**
  75194. * The min limit of the emission direction.
  75195. */
  75196. direction1?: Vector3,
  75197. /**
  75198. * The max limit of the emission direction.
  75199. */
  75200. direction2?: Vector3);
  75201. /**
  75202. * Called by the particle System when the direction is computed for the created particle.
  75203. * @param worldMatrix is the world matrix of the particle system
  75204. * @param directionToUpdate is the direction vector to update with the result
  75205. * @param particle is the particle we are computed the direction for
  75206. */
  75207. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75208. /**
  75209. * Clones the current emitter and returns a copy of it
  75210. * @returns the new emitter
  75211. */
  75212. clone(): SphereDirectedParticleEmitter;
  75213. /**
  75214. * Called by the GPUParticleSystem to setup the update shader
  75215. * @param effect defines the update shader
  75216. */
  75217. applyToShader(effect: Effect): void;
  75218. /**
  75219. * Returns a string to use to update the GPU particles update shader
  75220. * @returns a string containng the defines string
  75221. */
  75222. getEffectDefines(): string;
  75223. /**
  75224. * Returns the string "SphereDirectedParticleEmitter"
  75225. * @returns a string containing the class name
  75226. */
  75227. getClassName(): string;
  75228. /**
  75229. * Serializes the particle system to a JSON object.
  75230. * @returns the JSON object
  75231. */
  75232. serialize(): any;
  75233. /**
  75234. * Parse properties from a JSON object
  75235. * @param serializationObject defines the JSON object
  75236. */
  75237. parse(serializationObject: any): void;
  75238. }
  75239. }
  75240. declare module BABYLON {
  75241. /**
  75242. * Interface representing a particle system in Babylon.js.
  75243. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  75244. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  75245. */
  75246. export interface IParticleSystem {
  75247. /**
  75248. * List of animations used by the particle system.
  75249. */
  75250. animations: Animation[];
  75251. /**
  75252. * The id of the Particle system.
  75253. */
  75254. id: string;
  75255. /**
  75256. * The name of the Particle system.
  75257. */
  75258. name: string;
  75259. /**
  75260. * The emitter represents the Mesh or position we are attaching the particle system to.
  75261. */
  75262. emitter: Nullable<AbstractMesh | Vector3>;
  75263. /**
  75264. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  75265. */
  75266. isBillboardBased: boolean;
  75267. /**
  75268. * The rendering group used by the Particle system to chose when to render.
  75269. */
  75270. renderingGroupId: number;
  75271. /**
  75272. * The layer mask we are rendering the particles through.
  75273. */
  75274. layerMask: number;
  75275. /**
  75276. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  75277. */
  75278. updateSpeed: number;
  75279. /**
  75280. * The amount of time the particle system is running (depends of the overall update speed).
  75281. */
  75282. targetStopDuration: number;
  75283. /**
  75284. * The texture used to render each particle. (this can be a spritesheet)
  75285. */
  75286. particleTexture: Nullable<Texture>;
  75287. /**
  75288. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  75289. */
  75290. blendMode: number;
  75291. /**
  75292. * Minimum life time of emitting particles.
  75293. */
  75294. minLifeTime: number;
  75295. /**
  75296. * Maximum life time of emitting particles.
  75297. */
  75298. maxLifeTime: number;
  75299. /**
  75300. * Minimum Size of emitting particles.
  75301. */
  75302. minSize: number;
  75303. /**
  75304. * Maximum Size of emitting particles.
  75305. */
  75306. maxSize: number;
  75307. /**
  75308. * Minimum scale of emitting particles on X axis.
  75309. */
  75310. minScaleX: number;
  75311. /**
  75312. * Maximum scale of emitting particles on X axis.
  75313. */
  75314. maxScaleX: number;
  75315. /**
  75316. * Minimum scale of emitting particles on Y axis.
  75317. */
  75318. minScaleY: number;
  75319. /**
  75320. * Maximum scale of emitting particles on Y axis.
  75321. */
  75322. maxScaleY: number;
  75323. /**
  75324. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75325. */
  75326. color1: Color4;
  75327. /**
  75328. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75329. */
  75330. color2: Color4;
  75331. /**
  75332. * Color the particle will have at the end of its lifetime.
  75333. */
  75334. colorDead: Color4;
  75335. /**
  75336. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  75337. */
  75338. emitRate: number;
  75339. /**
  75340. * You can use gravity if you want to give an orientation to your particles.
  75341. */
  75342. gravity: Vector3;
  75343. /**
  75344. * Minimum power of emitting particles.
  75345. */
  75346. minEmitPower: number;
  75347. /**
  75348. * Maximum power of emitting particles.
  75349. */
  75350. maxEmitPower: number;
  75351. /**
  75352. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  75353. */
  75354. minAngularSpeed: number;
  75355. /**
  75356. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  75357. */
  75358. maxAngularSpeed: number;
  75359. /**
  75360. * Gets or sets the minimal initial rotation in radians.
  75361. */
  75362. minInitialRotation: number;
  75363. /**
  75364. * Gets or sets the maximal initial rotation in radians.
  75365. */
  75366. maxInitialRotation: number;
  75367. /**
  75368. * The particle emitter type defines the emitter used by the particle system.
  75369. * It can be for example box, sphere, or cone...
  75370. */
  75371. particleEmitterType: Nullable<IParticleEmitterType>;
  75372. /**
  75373. * Defines the delay in milliseconds before starting the system (0 by default)
  75374. */
  75375. startDelay: number;
  75376. /**
  75377. * 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
  75378. */
  75379. preWarmCycles: number;
  75380. /**
  75381. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  75382. */
  75383. preWarmStepOffset: number;
  75384. /**
  75385. * 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)
  75386. */
  75387. spriteCellChangeSpeed: number;
  75388. /**
  75389. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  75390. */
  75391. startSpriteCellID: number;
  75392. /**
  75393. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  75394. */
  75395. endSpriteCellID: number;
  75396. /**
  75397. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  75398. */
  75399. spriteCellWidth: number;
  75400. /**
  75401. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  75402. */
  75403. spriteCellHeight: number;
  75404. /**
  75405. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  75406. */
  75407. spriteRandomStartCell: boolean;
  75408. /**
  75409. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  75410. */
  75411. isAnimationSheetEnabled: boolean;
  75412. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  75413. translationPivot: Vector2;
  75414. /**
  75415. * Gets or sets a texture used to add random noise to particle positions
  75416. */
  75417. noiseTexture: Nullable<BaseTexture>;
  75418. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  75419. noiseStrength: Vector3;
  75420. /**
  75421. * Gets or sets the billboard mode to use when isBillboardBased = true.
  75422. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  75423. */
  75424. billboardMode: number;
  75425. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  75426. limitVelocityDamping: number;
  75427. /**
  75428. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  75429. */
  75430. beginAnimationOnStart: boolean;
  75431. /**
  75432. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  75433. */
  75434. beginAnimationFrom: number;
  75435. /**
  75436. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  75437. */
  75438. beginAnimationTo: number;
  75439. /**
  75440. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  75441. */
  75442. beginAnimationLoop: boolean;
  75443. /**
  75444. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  75445. */
  75446. disposeOnStop: boolean;
  75447. /**
  75448. * Gets the maximum number of particles active at the same time.
  75449. * @returns The max number of active particles.
  75450. */
  75451. getCapacity(): number;
  75452. /**
  75453. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75454. * @returns True if it has been started, otherwise false.
  75455. */
  75456. isStarted(): boolean;
  75457. /**
  75458. * Animates the particle system for this frame.
  75459. */
  75460. animate(): void;
  75461. /**
  75462. * Renders the particle system in its current state.
  75463. * @returns the current number of particles
  75464. */
  75465. render(): number;
  75466. /**
  75467. * Dispose the particle system and frees its associated resources.
  75468. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75469. */
  75470. dispose(disposeTexture?: boolean): void;
  75471. /**
  75472. * Clones the particle system.
  75473. * @param name The name of the cloned object
  75474. * @param newEmitter The new emitter to use
  75475. * @returns the cloned particle system
  75476. */
  75477. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  75478. /**
  75479. * Serializes the particle system to a JSON object.
  75480. * @returns the JSON object
  75481. */
  75482. serialize(): any;
  75483. /**
  75484. * Rebuild the particle system
  75485. */
  75486. rebuild(): void;
  75487. /**
  75488. * Starts the particle system and begins to emit
  75489. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  75490. */
  75491. start(delay?: number): void;
  75492. /**
  75493. * Stops the particle system.
  75494. */
  75495. stop(): void;
  75496. /**
  75497. * Remove all active particles
  75498. */
  75499. reset(): void;
  75500. /**
  75501. * Is this system ready to be used/rendered
  75502. * @return true if the system is ready
  75503. */
  75504. isReady(): boolean;
  75505. /**
  75506. * Adds a new color gradient
  75507. * @param gradient defines the gradient to use (between 0 and 1)
  75508. * @param color1 defines the color to affect to the specified gradient
  75509. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75510. * @returns the current particle system
  75511. */
  75512. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75513. /**
  75514. * Remove a specific color gradient
  75515. * @param gradient defines the gradient to remove
  75516. * @returns the current particle system
  75517. */
  75518. removeColorGradient(gradient: number): IParticleSystem;
  75519. /**
  75520. * Adds a new size gradient
  75521. * @param gradient defines the gradient to use (between 0 and 1)
  75522. * @param factor defines the size factor to affect to the specified gradient
  75523. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75524. * @returns the current particle system
  75525. */
  75526. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75527. /**
  75528. * Remove a specific size gradient
  75529. * @param gradient defines the gradient to remove
  75530. * @returns the current particle system
  75531. */
  75532. removeSizeGradient(gradient: number): IParticleSystem;
  75533. /**
  75534. * Gets the current list of color gradients.
  75535. * You must use addColorGradient and removeColorGradient to udpate this list
  75536. * @returns the list of color gradients
  75537. */
  75538. getColorGradients(): Nullable<Array<ColorGradient>>;
  75539. /**
  75540. * Gets the current list of size gradients.
  75541. * You must use addSizeGradient and removeSizeGradient to udpate this list
  75542. * @returns the list of size gradients
  75543. */
  75544. getSizeGradients(): Nullable<Array<FactorGradient>>;
  75545. /**
  75546. * Gets the current list of angular speed gradients.
  75547. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  75548. * @returns the list of angular speed gradients
  75549. */
  75550. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  75551. /**
  75552. * Adds a new angular speed gradient
  75553. * @param gradient defines the gradient to use (between 0 and 1)
  75554. * @param factor defines the angular speed to affect to the specified gradient
  75555. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75556. * @returns the current particle system
  75557. */
  75558. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75559. /**
  75560. * Remove a specific angular speed gradient
  75561. * @param gradient defines the gradient to remove
  75562. * @returns the current particle system
  75563. */
  75564. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75565. /**
  75566. * Gets the current list of velocity gradients.
  75567. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  75568. * @returns the list of velocity gradients
  75569. */
  75570. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  75571. /**
  75572. * Adds a new velocity gradient
  75573. * @param gradient defines the gradient to use (between 0 and 1)
  75574. * @param factor defines the velocity to affect to the specified gradient
  75575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75576. * @returns the current particle system
  75577. */
  75578. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75579. /**
  75580. * Remove a specific velocity gradient
  75581. * @param gradient defines the gradient to remove
  75582. * @returns the current particle system
  75583. */
  75584. removeVelocityGradient(gradient: number): IParticleSystem;
  75585. /**
  75586. * Gets the current list of limit velocity gradients.
  75587. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  75588. * @returns the list of limit velocity gradients
  75589. */
  75590. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  75591. /**
  75592. * Adds a new limit velocity gradient
  75593. * @param gradient defines the gradient to use (between 0 and 1)
  75594. * @param factor defines the limit velocity to affect to the specified gradient
  75595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75596. * @returns the current particle system
  75597. */
  75598. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75599. /**
  75600. * Remove a specific limit velocity gradient
  75601. * @param gradient defines the gradient to remove
  75602. * @returns the current particle system
  75603. */
  75604. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75605. /**
  75606. * Adds a new drag gradient
  75607. * @param gradient defines the gradient to use (between 0 and 1)
  75608. * @param factor defines the drag to affect to the specified gradient
  75609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75610. * @returns the current particle system
  75611. */
  75612. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75613. /**
  75614. * Remove a specific drag gradient
  75615. * @param gradient defines the gradient to remove
  75616. * @returns the current particle system
  75617. */
  75618. removeDragGradient(gradient: number): IParticleSystem;
  75619. /**
  75620. * Gets the current list of drag gradients.
  75621. * You must use addDragGradient and removeDragGradient to udpate this list
  75622. * @returns the list of drag gradients
  75623. */
  75624. getDragGradients(): Nullable<Array<FactorGradient>>;
  75625. /**
  75626. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75627. * @param gradient defines the gradient to use (between 0 and 1)
  75628. * @param factor defines the emit rate to affect to the specified gradient
  75629. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75630. * @returns the current particle system
  75631. */
  75632. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75633. /**
  75634. * Remove a specific emit rate gradient
  75635. * @param gradient defines the gradient to remove
  75636. * @returns the current particle system
  75637. */
  75638. removeEmitRateGradient(gradient: number): IParticleSystem;
  75639. /**
  75640. * Gets the current list of emit rate gradients.
  75641. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  75642. * @returns the list of emit rate gradients
  75643. */
  75644. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  75645. /**
  75646. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75647. * @param gradient defines the gradient to use (between 0 and 1)
  75648. * @param factor defines the start size to affect to the specified gradient
  75649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75650. * @returns the current particle system
  75651. */
  75652. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75653. /**
  75654. * Remove a specific start size gradient
  75655. * @param gradient defines the gradient to remove
  75656. * @returns the current particle system
  75657. */
  75658. removeStartSizeGradient(gradient: number): IParticleSystem;
  75659. /**
  75660. * Gets the current list of start size gradients.
  75661. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  75662. * @returns the list of start size gradients
  75663. */
  75664. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  75665. /**
  75666. * Adds a new life time gradient
  75667. * @param gradient defines the gradient to use (between 0 and 1)
  75668. * @param factor defines the life time factor to affect to the specified gradient
  75669. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75670. * @returns the current particle system
  75671. */
  75672. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75673. /**
  75674. * Remove a specific life time gradient
  75675. * @param gradient defines the gradient to remove
  75676. * @returns the current particle system
  75677. */
  75678. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75679. /**
  75680. * Gets the current list of life time gradients.
  75681. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  75682. * @returns the list of life time gradients
  75683. */
  75684. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  75685. /**
  75686. * Gets the current list of color gradients.
  75687. * You must use addColorGradient and removeColorGradient to udpate this list
  75688. * @returns the list of color gradients
  75689. */
  75690. getColorGradients(): Nullable<Array<ColorGradient>>;
  75691. /**
  75692. * Adds a new ramp gradient used to remap particle colors
  75693. * @param gradient defines the gradient to use (between 0 and 1)
  75694. * @param color defines the color to affect to the specified gradient
  75695. * @returns the current particle system
  75696. */
  75697. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  75698. /**
  75699. * Gets the current list of ramp gradients.
  75700. * You must use addRampGradient and removeRampGradient to udpate this list
  75701. * @returns the list of ramp gradients
  75702. */
  75703. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75704. /** Gets or sets a boolean indicating that ramp gradients must be used
  75705. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75706. */
  75707. useRampGradients: boolean;
  75708. /**
  75709. * Adds a new color remap gradient
  75710. * @param gradient defines the gradient to use (between 0 and 1)
  75711. * @param min defines the color remap minimal range
  75712. * @param max defines the color remap maximal range
  75713. * @returns the current particle system
  75714. */
  75715. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75716. /**
  75717. * Gets the current list of color remap gradients.
  75718. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  75719. * @returns the list of color remap gradients
  75720. */
  75721. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  75722. /**
  75723. * Adds a new alpha remap gradient
  75724. * @param gradient defines the gradient to use (between 0 and 1)
  75725. * @param min defines the alpha remap minimal range
  75726. * @param max defines the alpha remap maximal range
  75727. * @returns the current particle system
  75728. */
  75729. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75730. /**
  75731. * Gets the current list of alpha remap gradients.
  75732. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  75733. * @returns the list of alpha remap gradients
  75734. */
  75735. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  75736. /**
  75737. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  75738. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75739. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75740. * @returns the emitter
  75741. */
  75742. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  75743. /**
  75744. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  75745. * @param radius The radius of the hemisphere to emit from
  75746. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75747. * @returns the emitter
  75748. */
  75749. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  75750. /**
  75751. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  75752. * @param radius The radius of the sphere to emit from
  75753. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75754. * @returns the emitter
  75755. */
  75756. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  75757. /**
  75758. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  75759. * @param radius The radius of the sphere to emit from
  75760. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  75761. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  75762. * @returns the emitter
  75763. */
  75764. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75765. /**
  75766. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  75767. * @param radius The radius of the emission cylinder
  75768. * @param height The height of the emission cylinder
  75769. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  75770. * @param directionRandomizer How much to randomize the particle direction [0-1]
  75771. * @returns the emitter
  75772. */
  75773. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  75774. /**
  75775. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  75776. * @param radius The radius of the cylinder to emit from
  75777. * @param height The height of the emission cylinder
  75778. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75779. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  75780. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  75781. * @returns the emitter
  75782. */
  75783. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75784. /**
  75785. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  75786. * @param radius The radius of the cone to emit from
  75787. * @param angle The base angle of the cone
  75788. * @returns the emitter
  75789. */
  75790. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  75791. /**
  75792. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  75793. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75794. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75795. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75796. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75797. * @returns the emitter
  75798. */
  75799. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  75800. /**
  75801. * Get hosting scene
  75802. * @returns the scene
  75803. */
  75804. getScene(): Scene;
  75805. }
  75806. }
  75807. declare module BABYLON {
  75808. /**
  75809. * Creates an instance based on a source mesh.
  75810. */
  75811. export class InstancedMesh extends AbstractMesh {
  75812. private _sourceMesh;
  75813. private _currentLOD;
  75814. /** @hidden */
  75815. _indexInSourceMeshInstanceArray: number;
  75816. constructor(name: string, source: Mesh);
  75817. /**
  75818. * Returns the string "InstancedMesh".
  75819. */
  75820. getClassName(): string;
  75821. /**
  75822. * If the source mesh receives shadows
  75823. */
  75824. readonly receiveShadows: boolean;
  75825. /**
  75826. * The material of the source mesh
  75827. */
  75828. readonly material: Nullable<Material>;
  75829. /**
  75830. * Visibility of the source mesh
  75831. */
  75832. readonly visibility: number;
  75833. /**
  75834. * Skeleton of the source mesh
  75835. */
  75836. readonly skeleton: Nullable<Skeleton>;
  75837. /**
  75838. * Rendering ground id of the source mesh
  75839. */
  75840. renderingGroupId: number;
  75841. /**
  75842. * Returns the total number of vertices (integer).
  75843. */
  75844. getTotalVertices(): number;
  75845. /**
  75846. * Returns a positive integer : the total number of indices in this mesh geometry.
  75847. * @returns the numner of indices or zero if the mesh has no geometry.
  75848. */
  75849. getTotalIndices(): number;
  75850. /**
  75851. * The source mesh of the instance
  75852. */
  75853. readonly sourceMesh: Mesh;
  75854. /**
  75855. * Is this node ready to be used/rendered
  75856. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75857. * @return {boolean} is it ready
  75858. */
  75859. isReady(completeCheck?: boolean): boolean;
  75860. /**
  75861. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75862. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75863. * @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.
  75864. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75865. */
  75866. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75867. /**
  75868. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75869. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75870. * The `data` are either a numeric array either a Float32Array.
  75871. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75872. * 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).
  75873. * Note that a new underlying VertexBuffer object is created each call.
  75874. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75875. *
  75876. * Possible `kind` values :
  75877. * - VertexBuffer.PositionKind
  75878. * - VertexBuffer.UVKind
  75879. * - VertexBuffer.UV2Kind
  75880. * - VertexBuffer.UV3Kind
  75881. * - VertexBuffer.UV4Kind
  75882. * - VertexBuffer.UV5Kind
  75883. * - VertexBuffer.UV6Kind
  75884. * - VertexBuffer.ColorKind
  75885. * - VertexBuffer.MatricesIndicesKind
  75886. * - VertexBuffer.MatricesIndicesExtraKind
  75887. * - VertexBuffer.MatricesWeightsKind
  75888. * - VertexBuffer.MatricesWeightsExtraKind
  75889. *
  75890. * Returns the Mesh.
  75891. */
  75892. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75893. /**
  75894. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75895. * If the mesh has no geometry, it is simply returned as it is.
  75896. * The `data` are either a numeric array either a Float32Array.
  75897. * No new underlying VertexBuffer object is created.
  75898. * 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.
  75899. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75900. *
  75901. * Possible `kind` values :
  75902. * - VertexBuffer.PositionKind
  75903. * - VertexBuffer.UVKind
  75904. * - VertexBuffer.UV2Kind
  75905. * - VertexBuffer.UV3Kind
  75906. * - VertexBuffer.UV4Kind
  75907. * - VertexBuffer.UV5Kind
  75908. * - VertexBuffer.UV6Kind
  75909. * - VertexBuffer.ColorKind
  75910. * - VertexBuffer.MatricesIndicesKind
  75911. * - VertexBuffer.MatricesIndicesExtraKind
  75912. * - VertexBuffer.MatricesWeightsKind
  75913. * - VertexBuffer.MatricesWeightsExtraKind
  75914. *
  75915. * Returns the Mesh.
  75916. */
  75917. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75918. /**
  75919. * Sets the mesh indices.
  75920. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  75921. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  75922. * This method creates a new index buffer each call.
  75923. * Returns the Mesh.
  75924. */
  75925. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  75926. /**
  75927. * Boolean : True if the mesh owns the requested kind of data.
  75928. */
  75929. isVerticesDataPresent(kind: string): boolean;
  75930. /**
  75931. * Returns an array of indices (IndicesArray).
  75932. */
  75933. getIndices(): Nullable<IndicesArray>;
  75934. readonly _positions: Nullable<Vector3[]>;
  75935. /**
  75936. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75937. * This means the mesh underlying bounding box and sphere are recomputed.
  75938. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75939. * @returns the current mesh
  75940. */
  75941. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  75942. /** @hidden */
  75943. _preActivate(): InstancedMesh;
  75944. /** @hidden */
  75945. _activate(renderId: number): InstancedMesh;
  75946. /**
  75947. * Returns the current associated LOD AbstractMesh.
  75948. */
  75949. getLOD(camera: Camera): AbstractMesh;
  75950. /** @hidden */
  75951. _syncSubMeshes(): InstancedMesh;
  75952. /** @hidden */
  75953. _generatePointsArray(): boolean;
  75954. /**
  75955. * Creates a new InstancedMesh from the current mesh.
  75956. * - name (string) : the cloned mesh name
  75957. * - newParent (optional Node) : the optional Node to parent the clone to.
  75958. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  75959. *
  75960. * Returns the clone.
  75961. */
  75962. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  75963. /**
  75964. * Disposes the InstancedMesh.
  75965. * Returns nothing.
  75966. */
  75967. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75968. }
  75969. }
  75970. declare module BABYLON {
  75971. /**
  75972. * Defines the options associated with the creation of a shader material.
  75973. */
  75974. export interface IShaderMaterialOptions {
  75975. /**
  75976. * Does the material work in alpha blend mode
  75977. */
  75978. needAlphaBlending: boolean;
  75979. /**
  75980. * Does the material work in alpha test mode
  75981. */
  75982. needAlphaTesting: boolean;
  75983. /**
  75984. * The list of attribute names used in the shader
  75985. */
  75986. attributes: string[];
  75987. /**
  75988. * The list of unifrom names used in the shader
  75989. */
  75990. uniforms: string[];
  75991. /**
  75992. * The list of UBO names used in the shader
  75993. */
  75994. uniformBuffers: string[];
  75995. /**
  75996. * The list of sampler names used in the shader
  75997. */
  75998. samplers: string[];
  75999. /**
  76000. * The list of defines used in the shader
  76001. */
  76002. defines: string[];
  76003. }
  76004. /**
  76005. * 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.
  76006. *
  76007. * This returned material effects how the mesh will look based on the code in the shaders.
  76008. *
  76009. * @see http://doc.babylonjs.com/how_to/shader_material
  76010. */
  76011. export class ShaderMaterial extends Material {
  76012. private _shaderPath;
  76013. private _options;
  76014. private _textures;
  76015. private _textureArrays;
  76016. private _floats;
  76017. private _ints;
  76018. private _floatsArrays;
  76019. private _colors3;
  76020. private _colors3Arrays;
  76021. private _colors4;
  76022. private _vectors2;
  76023. private _vectors3;
  76024. private _vectors4;
  76025. private _matrices;
  76026. private _matrices3x3;
  76027. private _matrices2x2;
  76028. private _vectors2Arrays;
  76029. private _vectors3Arrays;
  76030. private _cachedWorldViewMatrix;
  76031. private _renderId;
  76032. /**
  76033. * Instantiate a new shader material.
  76034. * 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.
  76035. * This returned material effects how the mesh will look based on the code in the shaders.
  76036. * @see http://doc.babylonjs.com/how_to/shader_material
  76037. * @param name Define the name of the material in the scene
  76038. * @param scene Define the scene the material belongs to
  76039. * @param shaderPath Defines the route to the shader code in one of three ways:
  76040. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76041. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76042. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76043. * @param options Define the options used to create the shader
  76044. */
  76045. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76046. /**
  76047. * Gets the options used to compile the shader.
  76048. * They can be modified to trigger a new compilation
  76049. */
  76050. readonly options: IShaderMaterialOptions;
  76051. /**
  76052. * Gets the current class name of the material e.g. "ShaderMaterial"
  76053. * Mainly use in serialization.
  76054. * @returns the class name
  76055. */
  76056. getClassName(): string;
  76057. /**
  76058. * Specifies if the material will require alpha blending
  76059. * @returns a boolean specifying if alpha blending is needed
  76060. */
  76061. needAlphaBlending(): boolean;
  76062. /**
  76063. * Specifies if this material should be rendered in alpha test mode
  76064. * @returns a boolean specifying if an alpha test is needed.
  76065. */
  76066. needAlphaTesting(): boolean;
  76067. private _checkUniform;
  76068. /**
  76069. * Set a texture in the shader.
  76070. * @param name Define the name of the uniform samplers as defined in the shader
  76071. * @param texture Define the texture to bind to this sampler
  76072. * @return the material itself allowing "fluent" like uniform updates
  76073. */
  76074. setTexture(name: string, texture: Texture): ShaderMaterial;
  76075. /**
  76076. * Set a texture array in the shader.
  76077. * @param name Define the name of the uniform sampler array as defined in the shader
  76078. * @param textures Define the list of textures to bind to this sampler
  76079. * @return the material itself allowing "fluent" like uniform updates
  76080. */
  76081. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76082. /**
  76083. * Set a float in the shader.
  76084. * @param name Define the name of the uniform as defined in the shader
  76085. * @param value Define the value to give to the uniform
  76086. * @return the material itself allowing "fluent" like uniform updates
  76087. */
  76088. setFloat(name: string, value: number): ShaderMaterial;
  76089. /**
  76090. * Set a int in the shader.
  76091. * @param name Define the name of the uniform as defined in the shader
  76092. * @param value Define the value to give to the uniform
  76093. * @return the material itself allowing "fluent" like uniform updates
  76094. */
  76095. setInt(name: string, value: number): ShaderMaterial;
  76096. /**
  76097. * Set an array of floats in the shader.
  76098. * @param name Define the name of the uniform as defined in the shader
  76099. * @param value Define the value to give to the uniform
  76100. * @return the material itself allowing "fluent" like uniform updates
  76101. */
  76102. setFloats(name: string, value: number[]): ShaderMaterial;
  76103. /**
  76104. * Set a vec3 in the shader from a Color3.
  76105. * @param name Define the name of the uniform as defined in the shader
  76106. * @param value Define the value to give to the uniform
  76107. * @return the material itself allowing "fluent" like uniform updates
  76108. */
  76109. setColor3(name: string, value: Color3): ShaderMaterial;
  76110. /**
  76111. * Set a vec3 array in the shader from a Color3 array.
  76112. * @param name Define the name of the uniform as defined in the shader
  76113. * @param value Define the value to give to the uniform
  76114. * @return the material itself allowing "fluent" like uniform updates
  76115. */
  76116. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76117. /**
  76118. * Set a vec4 in the shader from a Color4.
  76119. * @param name Define the name of the uniform as defined in the shader
  76120. * @param value Define the value to give to the uniform
  76121. * @return the material itself allowing "fluent" like uniform updates
  76122. */
  76123. setColor4(name: string, value: Color4): ShaderMaterial;
  76124. /**
  76125. * Set a vec2 in the shader from a Vector2.
  76126. * @param name Define the name of the uniform as defined in the shader
  76127. * @param value Define the value to give to the uniform
  76128. * @return the material itself allowing "fluent" like uniform updates
  76129. */
  76130. setVector2(name: string, value: Vector2): ShaderMaterial;
  76131. /**
  76132. * Set a vec3 in the shader from a Vector3.
  76133. * @param name Define the name of the uniform as defined in the shader
  76134. * @param value Define the value to give to the uniform
  76135. * @return the material itself allowing "fluent" like uniform updates
  76136. */
  76137. setVector3(name: string, value: Vector3): ShaderMaterial;
  76138. /**
  76139. * Set a vec4 in the shader from a Vector4.
  76140. * @param name Define the name of the uniform as defined in the shader
  76141. * @param value Define the value to give to the uniform
  76142. * @return the material itself allowing "fluent" like uniform updates
  76143. */
  76144. setVector4(name: string, value: Vector4): ShaderMaterial;
  76145. /**
  76146. * Set a mat4 in the shader from a Matrix.
  76147. * @param name Define the name of the uniform as defined in the shader
  76148. * @param value Define the value to give to the uniform
  76149. * @return the material itself allowing "fluent" like uniform updates
  76150. */
  76151. setMatrix(name: string, value: Matrix): ShaderMaterial;
  76152. /**
  76153. * Set a mat3 in the shader from a Float32Array.
  76154. * @param name Define the name of the uniform as defined in the shader
  76155. * @param value Define the value to give to the uniform
  76156. * @return the material itself allowing "fluent" like uniform updates
  76157. */
  76158. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  76159. /**
  76160. * Set a mat2 in the shader from a Float32Array.
  76161. * @param name Define the name of the uniform as defined in the shader
  76162. * @param value Define the value to give to the uniform
  76163. * @return the material itself allowing "fluent" like uniform updates
  76164. */
  76165. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  76166. /**
  76167. * Set a vec2 array in the shader from a number array.
  76168. * @param name Define the name of the uniform as defined in the shader
  76169. * @param value Define the value to give to the uniform
  76170. * @return the material itself allowing "fluent" like uniform updates
  76171. */
  76172. setArray2(name: string, value: number[]): ShaderMaterial;
  76173. /**
  76174. * Set a vec3 array in the shader from a number array.
  76175. * @param name Define the name of the uniform as defined in the shader
  76176. * @param value Define the value to give to the uniform
  76177. * @return the material itself allowing "fluent" like uniform updates
  76178. */
  76179. setArray3(name: string, value: number[]): ShaderMaterial;
  76180. private _checkCache;
  76181. /**
  76182. * Specifies that the submesh is ready to be used
  76183. * @param mesh defines the mesh to check
  76184. * @param subMesh defines which submesh to check
  76185. * @param useInstances specifies that instances should be used
  76186. * @returns a boolean indicating that the submesh is ready or not
  76187. */
  76188. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  76189. /**
  76190. * Checks if the material is ready to render the requested mesh
  76191. * @param mesh Define the mesh to render
  76192. * @param useInstances Define whether or not the material is used with instances
  76193. * @returns true if ready, otherwise false
  76194. */
  76195. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  76196. /**
  76197. * Binds the world matrix to the material
  76198. * @param world defines the world transformation matrix
  76199. */
  76200. bindOnlyWorldMatrix(world: Matrix): void;
  76201. /**
  76202. * Binds the material to the mesh
  76203. * @param world defines the world transformation matrix
  76204. * @param mesh defines the mesh to bind the material to
  76205. */
  76206. bind(world: Matrix, mesh?: Mesh): void;
  76207. /**
  76208. * Gets the active textures from the material
  76209. * @returns an array of textures
  76210. */
  76211. getActiveTextures(): BaseTexture[];
  76212. /**
  76213. * Specifies if the material uses a texture
  76214. * @param texture defines the texture to check against the material
  76215. * @returns a boolean specifying if the material uses the texture
  76216. */
  76217. hasTexture(texture: BaseTexture): boolean;
  76218. /**
  76219. * Makes a duplicate of the material, and gives it a new name
  76220. * @param name defines the new name for the duplicated material
  76221. * @returns the cloned material
  76222. */
  76223. clone(name: string): ShaderMaterial;
  76224. /**
  76225. * Disposes the material
  76226. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  76227. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  76228. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  76229. */
  76230. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  76231. /**
  76232. * Serializes this material in a JSON representation
  76233. * @returns the serialized material object
  76234. */
  76235. serialize(): any;
  76236. /**
  76237. * Creates a shader material from parsed shader material data
  76238. * @param source defines the JSON represnetation of the material
  76239. * @param scene defines the hosting scene
  76240. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76241. * @returns a new material
  76242. */
  76243. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  76244. }
  76245. }
  76246. declare module BABYLON {
  76247. /** @hidden */
  76248. export var colorPixelShader: {
  76249. name: string;
  76250. shader: string;
  76251. };
  76252. }
  76253. declare module BABYLON {
  76254. /** @hidden */
  76255. export var colorVertexShader: {
  76256. name: string;
  76257. shader: string;
  76258. };
  76259. }
  76260. declare module BABYLON {
  76261. /**
  76262. * Line mesh
  76263. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  76264. */
  76265. export class LinesMesh extends Mesh {
  76266. /**
  76267. * If vertex color should be applied to the mesh
  76268. */
  76269. useVertexColor?: boolean | undefined;
  76270. /**
  76271. * If vertex alpha should be applied to the mesh
  76272. */
  76273. useVertexAlpha?: boolean | undefined;
  76274. /**
  76275. * Color of the line (Default: White)
  76276. */
  76277. color: Color3;
  76278. /**
  76279. * Alpha of the line (Default: 1)
  76280. */
  76281. alpha: number;
  76282. /**
  76283. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76284. * This margin is expressed in world space coordinates, so its value may vary.
  76285. * Default value is 0.1
  76286. */
  76287. intersectionThreshold: number;
  76288. private _colorShader;
  76289. /**
  76290. * Creates a new LinesMesh
  76291. * @param name defines the name
  76292. * @param scene defines the hosting scene
  76293. * @param parent defines the parent mesh if any
  76294. * @param source defines the optional source LinesMesh used to clone data from
  76295. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76296. * When false, achieved by calling a clone(), also passing False.
  76297. * This will make creation of children, recursive.
  76298. * @param useVertexColor defines if this LinesMesh supports vertex color
  76299. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  76300. */
  76301. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  76302. /**
  76303. * If vertex color should be applied to the mesh
  76304. */
  76305. useVertexColor?: boolean | undefined,
  76306. /**
  76307. * If vertex alpha should be applied to the mesh
  76308. */
  76309. useVertexAlpha?: boolean | undefined);
  76310. private _addClipPlaneDefine;
  76311. private _removeClipPlaneDefine;
  76312. isReady(): boolean;
  76313. /**
  76314. * Returns the string "LineMesh"
  76315. */
  76316. getClassName(): string;
  76317. /**
  76318. * @hidden
  76319. */
  76320. /**
  76321. * @hidden
  76322. */
  76323. material: Material;
  76324. /**
  76325. * @hidden
  76326. */
  76327. readonly checkCollisions: boolean;
  76328. /** @hidden */
  76329. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  76330. /** @hidden */
  76331. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  76332. /**
  76333. * Disposes of the line mesh
  76334. * @param doNotRecurse If children should be disposed
  76335. */
  76336. dispose(doNotRecurse?: boolean): void;
  76337. /**
  76338. * Returns a new LineMesh object cloned from the current one.
  76339. */
  76340. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  76341. /**
  76342. * Creates a new InstancedLinesMesh object from the mesh model.
  76343. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76344. * @param name defines the name of the new instance
  76345. * @returns a new InstancedLinesMesh
  76346. */
  76347. createInstance(name: string): InstancedLinesMesh;
  76348. }
  76349. /**
  76350. * Creates an instance based on a source LinesMesh
  76351. */
  76352. export class InstancedLinesMesh extends InstancedMesh {
  76353. /**
  76354. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76355. * This margin is expressed in world space coordinates, so its value may vary.
  76356. * Initilized with the intersectionThreshold value of the source LinesMesh
  76357. */
  76358. intersectionThreshold: number;
  76359. constructor(name: string, source: LinesMesh);
  76360. /**
  76361. * Returns the string "InstancedLinesMesh".
  76362. */
  76363. getClassName(): string;
  76364. }
  76365. }
  76366. declare module BABYLON {
  76367. /** @hidden */
  76368. export var linePixelShader: {
  76369. name: string;
  76370. shader: string;
  76371. };
  76372. }
  76373. declare module BABYLON {
  76374. /** @hidden */
  76375. export var lineVertexShader: {
  76376. name: string;
  76377. shader: string;
  76378. };
  76379. }
  76380. declare module BABYLON {
  76381. interface AbstractMesh {
  76382. /**
  76383. * Disables the mesh edge rendering mode
  76384. * @returns the currentAbstractMesh
  76385. */
  76386. disableEdgesRendering(): AbstractMesh;
  76387. /**
  76388. * Enables the edge rendering mode on the mesh.
  76389. * This mode makes the mesh edges visible
  76390. * @param epsilon defines the maximal distance between two angles to detect a face
  76391. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76392. * @returns the currentAbstractMesh
  76393. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76394. */
  76395. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76396. /**
  76397. * Gets the edgesRenderer associated with the mesh
  76398. */
  76399. edgesRenderer: Nullable<EdgesRenderer>;
  76400. }
  76401. interface LinesMesh {
  76402. /**
  76403. * Enables the edge rendering mode on the mesh.
  76404. * This mode makes the mesh edges visible
  76405. * @param epsilon defines the maximal distance between two angles to detect a face
  76406. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76407. * @returns the currentAbstractMesh
  76408. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76409. */
  76410. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76411. }
  76412. interface InstancedLinesMesh {
  76413. /**
  76414. * Enables the edge rendering mode on the mesh.
  76415. * This mode makes the mesh edges visible
  76416. * @param epsilon defines the maximal distance between two angles to detect a face
  76417. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76418. * @returns the current InstancedLinesMesh
  76419. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76420. */
  76421. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  76422. }
  76423. /**
  76424. * Defines the minimum contract an Edges renderer should follow.
  76425. */
  76426. export interface IEdgesRenderer extends IDisposable {
  76427. /**
  76428. * Gets or sets a boolean indicating if the edgesRenderer is active
  76429. */
  76430. isEnabled: boolean;
  76431. /**
  76432. * Renders the edges of the attached mesh,
  76433. */
  76434. render(): void;
  76435. /**
  76436. * Checks wether or not the edges renderer is ready to render.
  76437. * @return true if ready, otherwise false.
  76438. */
  76439. isReady(): boolean;
  76440. }
  76441. /**
  76442. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  76443. */
  76444. export class EdgesRenderer implements IEdgesRenderer {
  76445. /**
  76446. * Define the size of the edges with an orthographic camera
  76447. */
  76448. edgesWidthScalerForOrthographic: number;
  76449. /**
  76450. * Define the size of the edges with a perspective camera
  76451. */
  76452. edgesWidthScalerForPerspective: number;
  76453. protected _source: AbstractMesh;
  76454. protected _linesPositions: number[];
  76455. protected _linesNormals: number[];
  76456. protected _linesIndices: number[];
  76457. protected _epsilon: number;
  76458. protected _indicesCount: number;
  76459. protected _lineShader: ShaderMaterial;
  76460. protected _ib: WebGLBuffer;
  76461. protected _buffers: {
  76462. [key: string]: Nullable<VertexBuffer>;
  76463. };
  76464. protected _checkVerticesInsteadOfIndices: boolean;
  76465. private _meshRebuildObserver;
  76466. private _meshDisposeObserver;
  76467. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  76468. isEnabled: boolean;
  76469. /**
  76470. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  76471. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  76472. * @param source Mesh used to create edges
  76473. * @param epsilon sum of angles in adjacency to check for edge
  76474. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  76475. * @param generateEdgesLines - should generate Lines or only prepare resources.
  76476. */
  76477. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  76478. protected _prepareRessources(): void;
  76479. /** @hidden */
  76480. _rebuild(): void;
  76481. /**
  76482. * Releases the required resources for the edges renderer
  76483. */
  76484. dispose(): void;
  76485. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  76486. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  76487. /**
  76488. * Checks if the pair of p0 and p1 is en edge
  76489. * @param faceIndex
  76490. * @param edge
  76491. * @param faceNormals
  76492. * @param p0
  76493. * @param p1
  76494. * @private
  76495. */
  76496. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  76497. /**
  76498. * push line into the position, normal and index buffer
  76499. * @protected
  76500. */
  76501. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  76502. /**
  76503. * Generates lines edges from adjacencjes
  76504. * @private
  76505. */
  76506. _generateEdgesLines(): void;
  76507. /**
  76508. * Checks wether or not the edges renderer is ready to render.
  76509. * @return true if ready, otherwise false.
  76510. */
  76511. isReady(): boolean;
  76512. /**
  76513. * Renders the edges of the attached mesh,
  76514. */
  76515. render(): void;
  76516. }
  76517. /**
  76518. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  76519. */
  76520. export class LineEdgesRenderer extends EdgesRenderer {
  76521. /**
  76522. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  76523. * @param source LineMesh used to generate edges
  76524. * @param epsilon not important (specified angle for edge detection)
  76525. * @param checkVerticesInsteadOfIndices not important for LineMesh
  76526. */
  76527. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  76528. /**
  76529. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  76530. */
  76531. _generateEdgesLines(): void;
  76532. }
  76533. }
  76534. declare module BABYLON {
  76535. /**
  76536. * This represents the object necessary to create a rendering group.
  76537. * This is exclusively used and created by the rendering manager.
  76538. * To modify the behavior, you use the available helpers in your scene or meshes.
  76539. * @hidden
  76540. */
  76541. export class RenderingGroup {
  76542. index: number;
  76543. private _scene;
  76544. private _opaqueSubMeshes;
  76545. private _transparentSubMeshes;
  76546. private _alphaTestSubMeshes;
  76547. private _depthOnlySubMeshes;
  76548. private _particleSystems;
  76549. private _spriteManagers;
  76550. private _opaqueSortCompareFn;
  76551. private _alphaTestSortCompareFn;
  76552. private _transparentSortCompareFn;
  76553. private _renderOpaque;
  76554. private _renderAlphaTest;
  76555. private _renderTransparent;
  76556. private _edgesRenderers;
  76557. onBeforeTransparentRendering: () => void;
  76558. /**
  76559. * Set the opaque sort comparison function.
  76560. * If null the sub meshes will be render in the order they were created
  76561. */
  76562. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76563. /**
  76564. * Set the alpha test sort comparison function.
  76565. * If null the sub meshes will be render in the order they were created
  76566. */
  76567. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76568. /**
  76569. * Set the transparent sort comparison function.
  76570. * If null the sub meshes will be render in the order they were created
  76571. */
  76572. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76573. /**
  76574. * Creates a new rendering group.
  76575. * @param index The rendering group index
  76576. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  76577. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  76578. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  76579. */
  76580. 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>);
  76581. /**
  76582. * Render all the sub meshes contained in the group.
  76583. * @param customRenderFunction Used to override the default render behaviour of the group.
  76584. * @returns true if rendered some submeshes.
  76585. */
  76586. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  76587. /**
  76588. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  76589. * @param subMeshes The submeshes to render
  76590. */
  76591. private renderOpaqueSorted;
  76592. /**
  76593. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  76594. * @param subMeshes The submeshes to render
  76595. */
  76596. private renderAlphaTestSorted;
  76597. /**
  76598. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  76599. * @param subMeshes The submeshes to render
  76600. */
  76601. private renderTransparentSorted;
  76602. /**
  76603. * Renders the submeshes in a specified order.
  76604. * @param subMeshes The submeshes to sort before render
  76605. * @param sortCompareFn The comparison function use to sort
  76606. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  76607. * @param transparent Specifies to activate blending if true
  76608. */
  76609. private static renderSorted;
  76610. /**
  76611. * Renders the submeshes in the order they were dispatched (no sort applied).
  76612. * @param subMeshes The submeshes to render
  76613. */
  76614. private static renderUnsorted;
  76615. /**
  76616. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76617. * are rendered back to front if in the same alpha index.
  76618. *
  76619. * @param a The first submesh
  76620. * @param b The second submesh
  76621. * @returns The result of the comparison
  76622. */
  76623. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  76624. /**
  76625. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76626. * are rendered back to front.
  76627. *
  76628. * @param a The first submesh
  76629. * @param b The second submesh
  76630. * @returns The result of the comparison
  76631. */
  76632. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  76633. /**
  76634. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76635. * are rendered front to back (prevent overdraw).
  76636. *
  76637. * @param a The first submesh
  76638. * @param b The second submesh
  76639. * @returns The result of the comparison
  76640. */
  76641. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  76642. /**
  76643. * Resets the different lists of submeshes to prepare a new frame.
  76644. */
  76645. prepare(): void;
  76646. dispose(): void;
  76647. /**
  76648. * Inserts the submesh in its correct queue depending on its material.
  76649. * @param subMesh The submesh to dispatch
  76650. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76651. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76652. */
  76653. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76654. dispatchSprites(spriteManager: ISpriteManager): void;
  76655. dispatchParticles(particleSystem: IParticleSystem): void;
  76656. private _renderParticles;
  76657. private _renderSprites;
  76658. }
  76659. }
  76660. declare module BABYLON {
  76661. /**
  76662. * Interface describing the different options available in the rendering manager
  76663. * regarding Auto Clear between groups.
  76664. */
  76665. export interface IRenderingManagerAutoClearSetup {
  76666. /**
  76667. * Defines whether or not autoclear is enable.
  76668. */
  76669. autoClear: boolean;
  76670. /**
  76671. * Defines whether or not to autoclear the depth buffer.
  76672. */
  76673. depth: boolean;
  76674. /**
  76675. * Defines whether or not to autoclear the stencil buffer.
  76676. */
  76677. stencil: boolean;
  76678. }
  76679. /**
  76680. * This class is used by the onRenderingGroupObservable
  76681. */
  76682. export class RenderingGroupInfo {
  76683. /**
  76684. * The Scene that being rendered
  76685. */
  76686. scene: Scene;
  76687. /**
  76688. * The camera currently used for the rendering pass
  76689. */
  76690. camera: Nullable<Camera>;
  76691. /**
  76692. * The ID of the renderingGroup being processed
  76693. */
  76694. renderingGroupId: number;
  76695. }
  76696. /**
  76697. * This is the manager responsible of all the rendering for meshes sprites and particles.
  76698. * It is enable to manage the different groups as well as the different necessary sort functions.
  76699. * This should not be used directly aside of the few static configurations
  76700. */
  76701. export class RenderingManager {
  76702. /**
  76703. * The max id used for rendering groups (not included)
  76704. */
  76705. static MAX_RENDERINGGROUPS: number;
  76706. /**
  76707. * The min id used for rendering groups (included)
  76708. */
  76709. static MIN_RENDERINGGROUPS: number;
  76710. /**
  76711. * Used to globally prevent autoclearing scenes.
  76712. */
  76713. static AUTOCLEAR: boolean;
  76714. /**
  76715. * @hidden
  76716. */
  76717. _useSceneAutoClearSetup: boolean;
  76718. private _scene;
  76719. private _renderingGroups;
  76720. private _depthStencilBufferAlreadyCleaned;
  76721. private _autoClearDepthStencil;
  76722. private _customOpaqueSortCompareFn;
  76723. private _customAlphaTestSortCompareFn;
  76724. private _customTransparentSortCompareFn;
  76725. private _renderingGroupInfo;
  76726. /**
  76727. * Instantiates a new rendering group for a particular scene
  76728. * @param scene Defines the scene the groups belongs to
  76729. */
  76730. constructor(scene: Scene);
  76731. private _clearDepthStencilBuffer;
  76732. /**
  76733. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  76734. * @hidden
  76735. */
  76736. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  76737. /**
  76738. * Resets the different information of the group to prepare a new frame
  76739. * @hidden
  76740. */
  76741. reset(): void;
  76742. /**
  76743. * Dispose and release the group and its associated resources.
  76744. * @hidden
  76745. */
  76746. dispose(): void;
  76747. /**
  76748. * Clear the info related to rendering groups preventing retention points during dispose.
  76749. */
  76750. freeRenderingGroups(): void;
  76751. private _prepareRenderingGroup;
  76752. /**
  76753. * Add a sprite manager to the rendering manager in order to render it this frame.
  76754. * @param spriteManager Define the sprite manager to render
  76755. */
  76756. dispatchSprites(spriteManager: ISpriteManager): void;
  76757. /**
  76758. * Add a particle system to the rendering manager in order to render it this frame.
  76759. * @param particleSystem Define the particle system to render
  76760. */
  76761. dispatchParticles(particleSystem: IParticleSystem): void;
  76762. /**
  76763. * Add a submesh to the manager in order to render it this frame
  76764. * @param subMesh The submesh to dispatch
  76765. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76766. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76767. */
  76768. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76769. /**
  76770. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76771. * This allowed control for front to back rendering or reversly depending of the special needs.
  76772. *
  76773. * @param renderingGroupId The rendering group id corresponding to its index
  76774. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76775. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76776. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76777. */
  76778. 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;
  76779. /**
  76780. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76781. *
  76782. * @param renderingGroupId The rendering group id corresponding to its index
  76783. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76784. * @param depth Automatically clears depth between groups if true and autoClear is true.
  76785. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  76786. */
  76787. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  76788. /**
  76789. * Gets the current auto clear configuration for one rendering group of the rendering
  76790. * manager.
  76791. * @param index the rendering group index to get the information for
  76792. * @returns The auto clear setup for the requested rendering group
  76793. */
  76794. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  76795. }
  76796. }
  76797. declare module BABYLON {
  76798. /**
  76799. * This Helps creating a texture that will be created from a camera in your scene.
  76800. * It is basically a dynamic texture that could be used to create special effects for instance.
  76801. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  76802. */
  76803. export class RenderTargetTexture extends Texture {
  76804. isCube: boolean;
  76805. /**
  76806. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  76807. */
  76808. static readonly REFRESHRATE_RENDER_ONCE: number;
  76809. /**
  76810. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  76811. */
  76812. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  76813. /**
  76814. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  76815. * the central point of your effect and can save a lot of performances.
  76816. */
  76817. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  76818. /**
  76819. * Use this predicate to dynamically define the list of mesh you want to render.
  76820. * If set, the renderList property will be overwritten.
  76821. */
  76822. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  76823. private _renderList;
  76824. /**
  76825. * Use this list to define the list of mesh you want to render.
  76826. */
  76827. renderList: Nullable<Array<AbstractMesh>>;
  76828. private _hookArray;
  76829. /**
  76830. * Define if particles should be rendered in your texture.
  76831. */
  76832. renderParticles: boolean;
  76833. /**
  76834. * Define if sprites should be rendered in your texture.
  76835. */
  76836. renderSprites: boolean;
  76837. /**
  76838. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  76839. */
  76840. coordinatesMode: number;
  76841. /**
  76842. * Define the camera used to render the texture.
  76843. */
  76844. activeCamera: Nullable<Camera>;
  76845. /**
  76846. * Override the render function of the texture with your own one.
  76847. */
  76848. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  76849. /**
  76850. * Define if camera post processes should be use while rendering the texture.
  76851. */
  76852. useCameraPostProcesses: boolean;
  76853. /**
  76854. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  76855. */
  76856. ignoreCameraViewport: boolean;
  76857. private _postProcessManager;
  76858. private _postProcesses;
  76859. private _resizeObserver;
  76860. /**
  76861. * An event triggered when the texture is unbind.
  76862. */
  76863. onBeforeBindObservable: Observable<RenderTargetTexture>;
  76864. /**
  76865. * An event triggered when the texture is unbind.
  76866. */
  76867. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  76868. private _onAfterUnbindObserver;
  76869. /**
  76870. * Set a after unbind callback in the texture.
  76871. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  76872. */
  76873. onAfterUnbind: () => void;
  76874. /**
  76875. * An event triggered before rendering the texture
  76876. */
  76877. onBeforeRenderObservable: Observable<number>;
  76878. private _onBeforeRenderObserver;
  76879. /**
  76880. * Set a before render callback in the texture.
  76881. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  76882. */
  76883. onBeforeRender: (faceIndex: number) => void;
  76884. /**
  76885. * An event triggered after rendering the texture
  76886. */
  76887. onAfterRenderObservable: Observable<number>;
  76888. private _onAfterRenderObserver;
  76889. /**
  76890. * Set a after render callback in the texture.
  76891. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  76892. */
  76893. onAfterRender: (faceIndex: number) => void;
  76894. /**
  76895. * An event triggered after the texture clear
  76896. */
  76897. onClearObservable: Observable<Engine>;
  76898. private _onClearObserver;
  76899. /**
  76900. * Set a clear callback in the texture.
  76901. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  76902. */
  76903. onClear: (Engine: Engine) => void;
  76904. /**
  76905. * Define the clear color of the Render Target if it should be different from the scene.
  76906. */
  76907. clearColor: Color4;
  76908. protected _size: number | {
  76909. width: number;
  76910. height: number;
  76911. };
  76912. protected _initialSizeParameter: number | {
  76913. width: number;
  76914. height: number;
  76915. } | {
  76916. ratio: number;
  76917. };
  76918. protected _sizeRatio: Nullable<number>;
  76919. /** @hidden */
  76920. _generateMipMaps: boolean;
  76921. protected _renderingManager: RenderingManager;
  76922. /** @hidden */
  76923. _waitingRenderList: string[];
  76924. protected _doNotChangeAspectRatio: boolean;
  76925. protected _currentRefreshId: number;
  76926. protected _refreshRate: number;
  76927. protected _textureMatrix: Matrix;
  76928. protected _samples: number;
  76929. protected _renderTargetOptions: RenderTargetCreationOptions;
  76930. /**
  76931. * Gets render target creation options that were used.
  76932. */
  76933. readonly renderTargetOptions: RenderTargetCreationOptions;
  76934. protected _engine: Engine;
  76935. protected _onRatioRescale(): void;
  76936. /**
  76937. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  76938. * It must define where the camera used to render the texture is set
  76939. */
  76940. boundingBoxPosition: Vector3;
  76941. private _boundingBoxSize;
  76942. /**
  76943. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  76944. * When defined, the cubemap will switch to local mode
  76945. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76946. * @example https://www.babylonjs-playground.com/#RNASML
  76947. */
  76948. boundingBoxSize: Vector3;
  76949. /**
  76950. * In case the RTT has been created with a depth texture, get the associated
  76951. * depth texture.
  76952. * Otherwise, return null.
  76953. */
  76954. depthStencilTexture: Nullable<InternalTexture>;
  76955. /**
  76956. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  76957. * or used a shadow, depth texture...
  76958. * @param name The friendly name of the texture
  76959. * @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)
  76960. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  76961. * @param generateMipMaps True if mip maps need to be generated after render.
  76962. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  76963. * @param type The type of the buffer in the RTT (int, half float, float...)
  76964. * @param isCube True if a cube texture needs to be created
  76965. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  76966. * @param generateDepthBuffer True to generate a depth buffer
  76967. * @param generateStencilBuffer True to generate a stencil buffer
  76968. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  76969. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  76970. * @param delayAllocation if the texture allocation should be delayed (default: false)
  76971. */
  76972. constructor(name: string, size: number | {
  76973. width: number;
  76974. height: number;
  76975. } | {
  76976. ratio: number;
  76977. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  76978. /**
  76979. * Creates a depth stencil texture.
  76980. * This is only available in WebGL 2 or with the depth texture extension available.
  76981. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  76982. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  76983. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  76984. */
  76985. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  76986. private _processSizeParameter;
  76987. /**
  76988. * Define the number of samples to use in case of MSAA.
  76989. * It defaults to one meaning no MSAA has been enabled.
  76990. */
  76991. samples: number;
  76992. /**
  76993. * Resets the refresh counter of the texture and start bak from scratch.
  76994. * Could be useful to regenerate the texture if it is setup to render only once.
  76995. */
  76996. resetRefreshCounter(): void;
  76997. /**
  76998. * Define the refresh rate of the texture or the rendering frequency.
  76999. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77000. */
  77001. refreshRate: number;
  77002. /**
  77003. * Adds a post process to the render target rendering passes.
  77004. * @param postProcess define the post process to add
  77005. */
  77006. addPostProcess(postProcess: PostProcess): void;
  77007. /**
  77008. * Clear all the post processes attached to the render target
  77009. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77010. */
  77011. clearPostProcesses(dispose?: boolean): void;
  77012. /**
  77013. * Remove one of the post process from the list of attached post processes to the texture
  77014. * @param postProcess define the post process to remove from the list
  77015. */
  77016. removePostProcess(postProcess: PostProcess): void;
  77017. /** @hidden */
  77018. _shouldRender(): boolean;
  77019. /**
  77020. * Gets the actual render size of the texture.
  77021. * @returns the width of the render size
  77022. */
  77023. getRenderSize(): number;
  77024. /**
  77025. * Gets the actual render width of the texture.
  77026. * @returns the width of the render size
  77027. */
  77028. getRenderWidth(): number;
  77029. /**
  77030. * Gets the actual render height of the texture.
  77031. * @returns the height of the render size
  77032. */
  77033. getRenderHeight(): number;
  77034. /**
  77035. * Get if the texture can be rescaled or not.
  77036. */
  77037. readonly canRescale: boolean;
  77038. /**
  77039. * Resize the texture using a ratio.
  77040. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77041. */
  77042. scale(ratio: number): void;
  77043. /**
  77044. * Get the texture reflection matrix used to rotate/transform the reflection.
  77045. * @returns the reflection matrix
  77046. */
  77047. getReflectionTextureMatrix(): Matrix;
  77048. /**
  77049. * Resize the texture to a new desired size.
  77050. * Be carrefull as it will recreate all the data in the new texture.
  77051. * @param size Define the new size. It can be:
  77052. * - a number for squared texture,
  77053. * - an object containing { width: number, height: number }
  77054. * - or an object containing a ratio { ratio: number }
  77055. */
  77056. resize(size: number | {
  77057. width: number;
  77058. height: number;
  77059. } | {
  77060. ratio: number;
  77061. }): void;
  77062. /**
  77063. * Renders all the objects from the render list into the texture.
  77064. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77065. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77066. */
  77067. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77068. private _bestReflectionRenderTargetDimension;
  77069. /**
  77070. * @hidden
  77071. * @param faceIndex face index to bind to if this is a cubetexture
  77072. */
  77073. _bindFrameBuffer(faceIndex?: number): void;
  77074. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77075. private renderToTarget;
  77076. /**
  77077. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77078. * This allowed control for front to back rendering or reversly depending of the special needs.
  77079. *
  77080. * @param renderingGroupId The rendering group id corresponding to its index
  77081. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77082. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77083. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77084. */
  77085. 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;
  77086. /**
  77087. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77088. *
  77089. * @param renderingGroupId The rendering group id corresponding to its index
  77090. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77091. */
  77092. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77093. /**
  77094. * Clones the texture.
  77095. * @returns the cloned texture
  77096. */
  77097. clone(): RenderTargetTexture;
  77098. /**
  77099. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77100. * @returns The JSON representation of the texture
  77101. */
  77102. serialize(): any;
  77103. /**
  77104. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77105. */
  77106. disposeFramebufferObjects(): void;
  77107. /**
  77108. * Dispose the texture and release its associated resources.
  77109. */
  77110. dispose(): void;
  77111. /** @hidden */
  77112. _rebuild(): void;
  77113. /**
  77114. * Clear the info related to rendering groups preventing retention point in material dispose.
  77115. */
  77116. freeRenderingGroups(): void;
  77117. /**
  77118. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77119. * @returns the view count
  77120. */
  77121. getViewCount(): number;
  77122. }
  77123. }
  77124. declare module BABYLON {
  77125. /**
  77126. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77127. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77128. * You can then easily use it as a reflectionTexture on a flat surface.
  77129. * In case the surface is not a plane, please consider relying on reflection probes.
  77130. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77131. */
  77132. export class MirrorTexture extends RenderTargetTexture {
  77133. private scene;
  77134. /**
  77135. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  77136. * 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.
  77137. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77138. */
  77139. mirrorPlane: Plane;
  77140. /**
  77141. * Define the blur ratio used to blur the reflection if needed.
  77142. */
  77143. blurRatio: number;
  77144. /**
  77145. * Define the adaptive blur kernel used to blur the reflection if needed.
  77146. * This will autocompute the closest best match for the `blurKernel`
  77147. */
  77148. adaptiveBlurKernel: number;
  77149. /**
  77150. * Define the blur kernel used to blur the reflection if needed.
  77151. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77152. */
  77153. blurKernel: number;
  77154. /**
  77155. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  77156. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77157. */
  77158. blurKernelX: number;
  77159. /**
  77160. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  77161. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77162. */
  77163. blurKernelY: number;
  77164. private _autoComputeBlurKernel;
  77165. protected _onRatioRescale(): void;
  77166. private _updateGammaSpace;
  77167. private _imageProcessingConfigChangeObserver;
  77168. private _transformMatrix;
  77169. private _mirrorMatrix;
  77170. private _savedViewMatrix;
  77171. private _blurX;
  77172. private _blurY;
  77173. private _adaptiveBlurKernel;
  77174. private _blurKernelX;
  77175. private _blurKernelY;
  77176. private _blurRatio;
  77177. /**
  77178. * Instantiates a Mirror Texture.
  77179. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77180. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77181. * You can then easily use it as a reflectionTexture on a flat surface.
  77182. * In case the surface is not a plane, please consider relying on reflection probes.
  77183. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77184. * @param name
  77185. * @param size
  77186. * @param scene
  77187. * @param generateMipMaps
  77188. * @param type
  77189. * @param samplingMode
  77190. * @param generateDepthBuffer
  77191. */
  77192. constructor(name: string, size: number | {
  77193. width: number;
  77194. height: number;
  77195. } | {
  77196. ratio: number;
  77197. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  77198. private _preparePostProcesses;
  77199. /**
  77200. * Clone the mirror texture.
  77201. * @returns the cloned texture
  77202. */
  77203. clone(): MirrorTexture;
  77204. /**
  77205. * Serialize the texture to a JSON representation you could use in Parse later on
  77206. * @returns the serialized JSON representation
  77207. */
  77208. serialize(): any;
  77209. /**
  77210. * Dispose the texture and release its associated resources.
  77211. */
  77212. dispose(): void;
  77213. }
  77214. }
  77215. declare module BABYLON {
  77216. /**
  77217. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77218. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77219. */
  77220. export class Texture extends BaseTexture {
  77221. /** @hidden */
  77222. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  77223. /** @hidden */
  77224. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  77225. /** @hidden */
  77226. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  77227. /** nearest is mag = nearest and min = nearest and mip = linear */
  77228. static readonly NEAREST_SAMPLINGMODE: number;
  77229. /** nearest is mag = nearest and min = nearest and mip = linear */
  77230. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  77231. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77232. static readonly BILINEAR_SAMPLINGMODE: number;
  77233. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77234. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  77235. /** Trilinear is mag = linear and min = linear and mip = linear */
  77236. static readonly TRILINEAR_SAMPLINGMODE: number;
  77237. /** Trilinear is mag = linear and min = linear and mip = linear */
  77238. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  77239. /** mag = nearest and min = nearest and mip = nearest */
  77240. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  77241. /** mag = nearest and min = linear and mip = nearest */
  77242. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  77243. /** mag = nearest and min = linear and mip = linear */
  77244. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  77245. /** mag = nearest and min = linear and mip = none */
  77246. static readonly NEAREST_LINEAR: number;
  77247. /** mag = nearest and min = nearest and mip = none */
  77248. static readonly NEAREST_NEAREST: number;
  77249. /** mag = linear and min = nearest and mip = nearest */
  77250. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  77251. /** mag = linear and min = nearest and mip = linear */
  77252. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  77253. /** mag = linear and min = linear and mip = none */
  77254. static readonly LINEAR_LINEAR: number;
  77255. /** mag = linear and min = nearest and mip = none */
  77256. static readonly LINEAR_NEAREST: number;
  77257. /** Explicit coordinates mode */
  77258. static readonly EXPLICIT_MODE: number;
  77259. /** Spherical coordinates mode */
  77260. static readonly SPHERICAL_MODE: number;
  77261. /** Planar coordinates mode */
  77262. static readonly PLANAR_MODE: number;
  77263. /** Cubic coordinates mode */
  77264. static readonly CUBIC_MODE: number;
  77265. /** Projection coordinates mode */
  77266. static readonly PROJECTION_MODE: number;
  77267. /** Inverse Cubic coordinates mode */
  77268. static readonly SKYBOX_MODE: number;
  77269. /** Inverse Cubic coordinates mode */
  77270. static readonly INVCUBIC_MODE: number;
  77271. /** Equirectangular coordinates mode */
  77272. static readonly EQUIRECTANGULAR_MODE: number;
  77273. /** Equirectangular Fixed coordinates mode */
  77274. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  77275. /** Equirectangular Fixed Mirrored coordinates mode */
  77276. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77277. /** Texture is not repeating outside of 0..1 UVs */
  77278. static readonly CLAMP_ADDRESSMODE: number;
  77279. /** Texture is repeating outside of 0..1 UVs */
  77280. static readonly WRAP_ADDRESSMODE: number;
  77281. /** Texture is repeating and mirrored */
  77282. static readonly MIRROR_ADDRESSMODE: number;
  77283. /**
  77284. * 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
  77285. */
  77286. static UseSerializedUrlIfAny: boolean;
  77287. /**
  77288. * Define the url of the texture.
  77289. */
  77290. url: Nullable<string>;
  77291. /**
  77292. * Define an offset on the texture to offset the u coordinates of the UVs
  77293. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77294. */
  77295. uOffset: number;
  77296. /**
  77297. * Define an offset on the texture to offset the v coordinates of the UVs
  77298. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77299. */
  77300. vOffset: number;
  77301. /**
  77302. * Define an offset on the texture to scale the u coordinates of the UVs
  77303. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77304. */
  77305. uScale: number;
  77306. /**
  77307. * Define an offset on the texture to scale the v coordinates of the UVs
  77308. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77309. */
  77310. vScale: number;
  77311. /**
  77312. * Define an offset on the texture to rotate around the u coordinates of the UVs
  77313. * @see http://doc.babylonjs.com/how_to/more_materials
  77314. */
  77315. uAng: number;
  77316. /**
  77317. * Define an offset on the texture to rotate around the v coordinates of the UVs
  77318. * @see http://doc.babylonjs.com/how_to/more_materials
  77319. */
  77320. vAng: number;
  77321. /**
  77322. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  77323. * @see http://doc.babylonjs.com/how_to/more_materials
  77324. */
  77325. wAng: number;
  77326. /**
  77327. * Defines the center of rotation (U)
  77328. */
  77329. uRotationCenter: number;
  77330. /**
  77331. * Defines the center of rotation (V)
  77332. */
  77333. vRotationCenter: number;
  77334. /**
  77335. * Defines the center of rotation (W)
  77336. */
  77337. wRotationCenter: number;
  77338. /**
  77339. * Are mip maps generated for this texture or not.
  77340. */
  77341. readonly noMipmap: boolean;
  77342. /**
  77343. * List of inspectable custom properties (used by the Inspector)
  77344. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77345. */
  77346. inspectableCustomProperties: IInspectable[];
  77347. private _noMipmap;
  77348. /** @hidden */
  77349. _invertY: boolean;
  77350. private _rowGenerationMatrix;
  77351. private _cachedTextureMatrix;
  77352. private _projectionModeMatrix;
  77353. private _t0;
  77354. private _t1;
  77355. private _t2;
  77356. private _cachedUOffset;
  77357. private _cachedVOffset;
  77358. private _cachedUScale;
  77359. private _cachedVScale;
  77360. private _cachedUAng;
  77361. private _cachedVAng;
  77362. private _cachedWAng;
  77363. private _cachedProjectionMatrixId;
  77364. private _cachedCoordinatesMode;
  77365. /** @hidden */
  77366. protected _initialSamplingMode: number;
  77367. /** @hidden */
  77368. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  77369. private _deleteBuffer;
  77370. protected _format: Nullable<number>;
  77371. private _delayedOnLoad;
  77372. private _delayedOnError;
  77373. /**
  77374. * Observable triggered once the texture has been loaded.
  77375. */
  77376. onLoadObservable: Observable<Texture>;
  77377. protected _isBlocking: boolean;
  77378. /**
  77379. * Is the texture preventing material to render while loading.
  77380. * If false, a default texture will be used instead of the loading one during the preparation step.
  77381. */
  77382. isBlocking: boolean;
  77383. /**
  77384. * Get the current sampling mode associated with the texture.
  77385. */
  77386. readonly samplingMode: number;
  77387. /**
  77388. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  77389. */
  77390. readonly invertY: boolean;
  77391. /**
  77392. * Instantiates a new texture.
  77393. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77394. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77395. * @param url define the url of the picture to load as a texture
  77396. * @param scene define the scene the texture will belong to
  77397. * @param noMipmap define if the texture will require mip maps or not
  77398. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77399. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77400. * @param onLoad define a callback triggered when the texture has been loaded
  77401. * @param onError define a callback triggered when an error occurred during the loading session
  77402. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77403. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77404. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77405. */
  77406. 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);
  77407. /**
  77408. * Update the url (and optional buffer) of this texture if url was null during construction.
  77409. * @param url the url of the texture
  77410. * @param buffer the buffer of the texture (defaults to null)
  77411. * @param onLoad callback called when the texture is loaded (defaults to null)
  77412. */
  77413. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  77414. /**
  77415. * Finish the loading sequence of a texture flagged as delayed load.
  77416. * @hidden
  77417. */
  77418. delayLoad(): void;
  77419. private _prepareRowForTextureGeneration;
  77420. /**
  77421. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  77422. * @returns the transform matrix of the texture.
  77423. */
  77424. getTextureMatrix(): Matrix;
  77425. /**
  77426. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  77427. * @returns The reflection texture transform
  77428. */
  77429. getReflectionTextureMatrix(): Matrix;
  77430. /**
  77431. * Clones the texture.
  77432. * @returns the cloned texture
  77433. */
  77434. clone(): Texture;
  77435. /**
  77436. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77437. * @returns The JSON representation of the texture
  77438. */
  77439. serialize(): any;
  77440. /**
  77441. * Get the current class name of the texture useful for serialization or dynamic coding.
  77442. * @returns "Texture"
  77443. */
  77444. getClassName(): string;
  77445. /**
  77446. * Dispose the texture and release its associated resources.
  77447. */
  77448. dispose(): void;
  77449. /**
  77450. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  77451. * @param parsedTexture Define the JSON representation of the texture
  77452. * @param scene Define the scene the parsed texture should be instantiated in
  77453. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  77454. * @returns The parsed texture if successful
  77455. */
  77456. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  77457. /**
  77458. * Creates a texture from its base 64 representation.
  77459. * @param data Define the base64 payload without the data: prefix
  77460. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77461. * @param scene Define the scene the texture should belong to
  77462. * @param noMipmap Forces the texture to not create mip map information if true
  77463. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77464. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77465. * @param onLoad define a callback triggered when the texture has been loaded
  77466. * @param onError define a callback triggered when an error occurred during the loading session
  77467. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77468. * @returns the created texture
  77469. */
  77470. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  77471. /**
  77472. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  77473. * @param data Define the base64 payload without the data: prefix
  77474. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77475. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77476. * @param scene Define the scene the texture should belong to
  77477. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77478. * @param noMipmap Forces the texture to not create mip map information if true
  77479. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77480. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77481. * @param onLoad define a callback triggered when the texture has been loaded
  77482. * @param onError define a callback triggered when an error occurred during the loading session
  77483. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77484. * @returns the created texture
  77485. */
  77486. 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;
  77487. }
  77488. }
  77489. declare module BABYLON {
  77490. /**
  77491. * Raw texture can help creating a texture directly from an array of data.
  77492. * This can be super useful if you either get the data from an uncompressed source or
  77493. * if you wish to create your texture pixel by pixel.
  77494. */
  77495. export class RawTexture extends Texture {
  77496. /**
  77497. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77498. */
  77499. format: number;
  77500. private _engine;
  77501. /**
  77502. * Instantiates a new RawTexture.
  77503. * Raw texture can help creating a texture directly from an array of data.
  77504. * This can be super useful if you either get the data from an uncompressed source or
  77505. * if you wish to create your texture pixel by pixel.
  77506. * @param data define the array of data to use to create the texture
  77507. * @param width define the width of the texture
  77508. * @param height define the height of the texture
  77509. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77510. * @param scene define the scene the texture belongs to
  77511. * @param generateMipMaps define whether mip maps should be generated or not
  77512. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77513. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77514. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77515. */
  77516. constructor(data: ArrayBufferView, width: number, height: number,
  77517. /**
  77518. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77519. */
  77520. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77521. /**
  77522. * Updates the texture underlying data.
  77523. * @param data Define the new data of the texture
  77524. */
  77525. update(data: ArrayBufferView): void;
  77526. /**
  77527. * Creates a luminance texture from some data.
  77528. * @param data Define the texture data
  77529. * @param width Define the width of the texture
  77530. * @param height Define the height of the texture
  77531. * @param scene Define the scene the texture belongs to
  77532. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77533. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77534. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77535. * @returns the luminance texture
  77536. */
  77537. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77538. /**
  77539. * Creates a luminance alpha texture from some data.
  77540. * @param data Define the texture data
  77541. * @param width Define the width of the texture
  77542. * @param height Define the height of the texture
  77543. * @param scene Define the scene the texture belongs to
  77544. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77545. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77546. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77547. * @returns the luminance alpha texture
  77548. */
  77549. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77550. /**
  77551. * Creates an alpha texture from some data.
  77552. * @param data Define the texture data
  77553. * @param width Define the width of the texture
  77554. * @param height Define the height of the texture
  77555. * @param scene Define the scene the texture belongs to
  77556. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77557. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77558. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77559. * @returns the alpha texture
  77560. */
  77561. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77562. /**
  77563. * Creates a RGB texture from some data.
  77564. * @param data Define the texture data
  77565. * @param width Define the width of the texture
  77566. * @param height Define the height of the texture
  77567. * @param scene Define the scene the texture belongs to
  77568. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77569. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77570. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77571. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77572. * @returns the RGB alpha texture
  77573. */
  77574. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77575. /**
  77576. * Creates a RGBA texture from some data.
  77577. * @param data Define the texture data
  77578. * @param width Define the width of the texture
  77579. * @param height Define the height of the texture
  77580. * @param scene Define the scene the texture belongs to
  77581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77585. * @returns the RGBA texture
  77586. */
  77587. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77588. /**
  77589. * Creates a R texture from some data.
  77590. * @param data Define the texture data
  77591. * @param width Define the width of the texture
  77592. * @param height Define the height of the texture
  77593. * @param scene Define the scene the texture belongs to
  77594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77597. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77598. * @returns the R texture
  77599. */
  77600. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77601. }
  77602. }
  77603. declare module BABYLON {
  77604. /**
  77605. * Defines a runtime animation
  77606. */
  77607. export class RuntimeAnimation {
  77608. private _events;
  77609. /**
  77610. * The current frame of the runtime animation
  77611. */
  77612. private _currentFrame;
  77613. /**
  77614. * The animation used by the runtime animation
  77615. */
  77616. private _animation;
  77617. /**
  77618. * The target of the runtime animation
  77619. */
  77620. private _target;
  77621. /**
  77622. * The initiating animatable
  77623. */
  77624. private _host;
  77625. /**
  77626. * The original value of the runtime animation
  77627. */
  77628. private _originalValue;
  77629. /**
  77630. * The original blend value of the runtime animation
  77631. */
  77632. private _originalBlendValue;
  77633. /**
  77634. * The offsets cache of the runtime animation
  77635. */
  77636. private _offsetsCache;
  77637. /**
  77638. * The high limits cache of the runtime animation
  77639. */
  77640. private _highLimitsCache;
  77641. /**
  77642. * Specifies if the runtime animation has been stopped
  77643. */
  77644. private _stopped;
  77645. /**
  77646. * The blending factor of the runtime animation
  77647. */
  77648. private _blendingFactor;
  77649. /**
  77650. * The BabylonJS scene
  77651. */
  77652. private _scene;
  77653. /**
  77654. * The current value of the runtime animation
  77655. */
  77656. private _currentValue;
  77657. /** @hidden */
  77658. _workValue: any;
  77659. /**
  77660. * The active target of the runtime animation
  77661. */
  77662. private _activeTarget;
  77663. /**
  77664. * The target path of the runtime animation
  77665. */
  77666. private _targetPath;
  77667. /**
  77668. * The weight of the runtime animation
  77669. */
  77670. private _weight;
  77671. /**
  77672. * The ratio offset of the runtime animation
  77673. */
  77674. private _ratioOffset;
  77675. /**
  77676. * The previous delay of the runtime animation
  77677. */
  77678. private _previousDelay;
  77679. /**
  77680. * The previous ratio of the runtime animation
  77681. */
  77682. private _previousRatio;
  77683. private _enableBlending;
  77684. private _correctLoopMode;
  77685. /**
  77686. * Gets the current frame of the runtime animation
  77687. */
  77688. readonly currentFrame: number;
  77689. /**
  77690. * Gets the weight of the runtime animation
  77691. */
  77692. readonly weight: number;
  77693. /**
  77694. * Gets the current value of the runtime animation
  77695. */
  77696. readonly currentValue: any;
  77697. /**
  77698. * Gets the target path of the runtime animation
  77699. */
  77700. readonly targetPath: string;
  77701. /**
  77702. * Gets the actual target of the runtime animation
  77703. */
  77704. readonly target: any;
  77705. /**
  77706. * Create a new RuntimeAnimation object
  77707. * @param target defines the target of the animation
  77708. * @param animation defines the source animation object
  77709. * @param scene defines the hosting scene
  77710. * @param host defines the initiating Animatable
  77711. */
  77712. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77713. /**
  77714. * Gets the animation from the runtime animation
  77715. */
  77716. readonly animation: Animation;
  77717. /**
  77718. * Resets the runtime animation to the beginning
  77719. * @param restoreOriginal defines whether to restore the target property to the original value
  77720. */
  77721. reset(restoreOriginal?: boolean): void;
  77722. /**
  77723. * Specifies if the runtime animation is stopped
  77724. * @returns Boolean specifying if the runtime animation is stopped
  77725. */
  77726. isStopped(): boolean;
  77727. /**
  77728. * Disposes of the runtime animation
  77729. */
  77730. dispose(): void;
  77731. /**
  77732. * Interpolates the animation from the current frame
  77733. * @param currentFrame The frame to interpolate the animation to
  77734. * @param repeatCount The number of times that the animation should loop
  77735. * @param loopMode The type of looping mode to use
  77736. * @param offsetValue Animation offset value
  77737. * @param highLimitValue The high limit value
  77738. * @returns The interpolated value
  77739. */
  77740. private _interpolate;
  77741. /**
  77742. * Apply the interpolated value to the target
  77743. * @param currentValue defines the value computed by the animation
  77744. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77745. */
  77746. setValue(currentValue: any, weight?: number): void;
  77747. private _setValue;
  77748. /**
  77749. * Gets the loop pmode of the runtime animation
  77750. * @returns Loop Mode
  77751. */
  77752. private _getCorrectLoopMode;
  77753. /**
  77754. * Move the current animation to a given frame
  77755. * @param frame defines the frame to move to
  77756. */
  77757. goToFrame(frame: number): void;
  77758. /**
  77759. * @hidden Internal use only
  77760. */
  77761. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77762. /**
  77763. * Execute the current animation
  77764. * @param delay defines the delay to add to the current frame
  77765. * @param from defines the lower bound of the animation range
  77766. * @param to defines the upper bound of the animation range
  77767. * @param loop defines if the current animation must loop
  77768. * @param speedRatio defines the current speed ratio
  77769. * @param weight defines the weight of the animation (default is -1 so no weight)
  77770. * @param onLoop optional callback called when animation loops
  77771. * @returns a boolean indicating if the animation is running
  77772. */
  77773. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  77774. }
  77775. }
  77776. declare module BABYLON {
  77777. /**
  77778. * Class used to store an actual running animation
  77779. */
  77780. export class Animatable {
  77781. /** defines the target object */
  77782. target: any;
  77783. /** defines the starting frame number (default is 0) */
  77784. fromFrame: number;
  77785. /** defines the ending frame number (default is 100) */
  77786. toFrame: number;
  77787. /** defines if the animation must loop (default is false) */
  77788. loopAnimation: boolean;
  77789. /** defines a callback to call when animation ends if it is not looping */
  77790. onAnimationEnd?: (() => void) | null | undefined;
  77791. /** defines a callback to call when animation loops */
  77792. onAnimationLoop?: (() => void) | null | undefined;
  77793. private _localDelayOffset;
  77794. private _pausedDelay;
  77795. private _runtimeAnimations;
  77796. private _paused;
  77797. private _scene;
  77798. private _speedRatio;
  77799. private _weight;
  77800. private _syncRoot;
  77801. /**
  77802. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77803. * This will only apply for non looping animation (default is true)
  77804. */
  77805. disposeOnEnd: boolean;
  77806. /**
  77807. * Gets a boolean indicating if the animation has started
  77808. */
  77809. animationStarted: boolean;
  77810. /**
  77811. * Observer raised when the animation ends
  77812. */
  77813. onAnimationEndObservable: Observable<Animatable>;
  77814. /**
  77815. * Observer raised when the animation loops
  77816. */
  77817. onAnimationLoopObservable: Observable<Animatable>;
  77818. /**
  77819. * Gets the root Animatable used to synchronize and normalize animations
  77820. */
  77821. readonly syncRoot: Animatable;
  77822. /**
  77823. * Gets the current frame of the first RuntimeAnimation
  77824. * Used to synchronize Animatables
  77825. */
  77826. readonly masterFrame: number;
  77827. /**
  77828. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77829. */
  77830. weight: number;
  77831. /**
  77832. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77833. */
  77834. speedRatio: number;
  77835. /**
  77836. * Creates a new Animatable
  77837. * @param scene defines the hosting scene
  77838. * @param target defines the target object
  77839. * @param fromFrame defines the starting frame number (default is 0)
  77840. * @param toFrame defines the ending frame number (default is 100)
  77841. * @param loopAnimation defines if the animation must loop (default is false)
  77842. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77843. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77844. * @param animations defines a group of animation to add to the new Animatable
  77845. * @param onAnimationLoop defines a callback to call when animation loops
  77846. */
  77847. constructor(scene: Scene,
  77848. /** defines the target object */
  77849. target: any,
  77850. /** defines the starting frame number (default is 0) */
  77851. fromFrame?: number,
  77852. /** defines the ending frame number (default is 100) */
  77853. toFrame?: number,
  77854. /** defines if the animation must loop (default is false) */
  77855. loopAnimation?: boolean, speedRatio?: number,
  77856. /** defines a callback to call when animation ends if it is not looping */
  77857. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77858. /** defines a callback to call when animation loops */
  77859. onAnimationLoop?: (() => void) | null | undefined);
  77860. /**
  77861. * Synchronize and normalize current Animatable with a source Animatable
  77862. * This is useful when using animation weights and when animations are not of the same length
  77863. * @param root defines the root Animatable to synchronize with
  77864. * @returns the current Animatable
  77865. */
  77866. syncWith(root: Animatable): Animatable;
  77867. /**
  77868. * Gets the list of runtime animations
  77869. * @returns an array of RuntimeAnimation
  77870. */
  77871. getAnimations(): RuntimeAnimation[];
  77872. /**
  77873. * Adds more animations to the current animatable
  77874. * @param target defines the target of the animations
  77875. * @param animations defines the new animations to add
  77876. */
  77877. appendAnimations(target: any, animations: Animation[]): void;
  77878. /**
  77879. * Gets the source animation for a specific property
  77880. * @param property defines the propertyu to look for
  77881. * @returns null or the source animation for the given property
  77882. */
  77883. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77884. /**
  77885. * Gets the runtime animation for a specific property
  77886. * @param property defines the propertyu to look for
  77887. * @returns null or the runtime animation for the given property
  77888. */
  77889. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77890. /**
  77891. * Resets the animatable to its original state
  77892. */
  77893. reset(): void;
  77894. /**
  77895. * Allows the animatable to blend with current running animations
  77896. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77897. * @param blendingSpeed defines the blending speed to use
  77898. */
  77899. enableBlending(blendingSpeed: number): void;
  77900. /**
  77901. * Disable animation blending
  77902. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77903. */
  77904. disableBlending(): void;
  77905. /**
  77906. * Jump directly to a given frame
  77907. * @param frame defines the frame to jump to
  77908. */
  77909. goToFrame(frame: number): void;
  77910. /**
  77911. * Pause the animation
  77912. */
  77913. pause(): void;
  77914. /**
  77915. * Restart the animation
  77916. */
  77917. restart(): void;
  77918. private _raiseOnAnimationEnd;
  77919. /**
  77920. * Stop and delete the current animation
  77921. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77922. * @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)
  77923. */
  77924. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77925. /**
  77926. * Wait asynchronously for the animation to end
  77927. * @returns a promise which will be fullfilled when the animation ends
  77928. */
  77929. waitAsync(): Promise<Animatable>;
  77930. /** @hidden */
  77931. _animate(delay: number): boolean;
  77932. }
  77933. interface Scene {
  77934. /** @hidden */
  77935. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77936. /** @hidden */
  77937. _processLateAnimationBindingsForMatrices(holder: {
  77938. totalWeight: number;
  77939. animations: RuntimeAnimation[];
  77940. originalValue: Matrix;
  77941. }): any;
  77942. /** @hidden */
  77943. _processLateAnimationBindingsForQuaternions(holder: {
  77944. totalWeight: number;
  77945. animations: RuntimeAnimation[];
  77946. originalValue: Quaternion;
  77947. }, refQuaternion: Quaternion): Quaternion;
  77948. /** @hidden */
  77949. _processLateAnimationBindings(): void;
  77950. /**
  77951. * Will start the animation sequence of a given target
  77952. * @param target defines the target
  77953. * @param from defines from which frame should animation start
  77954. * @param to defines until which frame should animation run.
  77955. * @param weight defines the weight to apply to the animation (1.0 by default)
  77956. * @param loop defines if the animation loops
  77957. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77958. * @param onAnimationEnd defines the function to be executed when the animation ends
  77959. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77960. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77961. * @param onAnimationLoop defines the callback to call when an animation loops
  77962. * @returns the animatable object created for this animation
  77963. */
  77964. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77965. /**
  77966. * Will start the animation sequence of a given target
  77967. * @param target defines the target
  77968. * @param from defines from which frame should animation start
  77969. * @param to defines until which frame should animation run.
  77970. * @param loop defines if the animation loops
  77971. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77972. * @param onAnimationEnd defines the function to be executed when the animation ends
  77973. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77974. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77975. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  77976. * @param onAnimationLoop defines the callback to call when an animation loops
  77977. * @returns the animatable object created for this animation
  77978. */
  77979. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77980. /**
  77981. * Will start the animation sequence of a given target and its hierarchy
  77982. * @param target defines the target
  77983. * @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.
  77984. * @param from defines from which frame should animation start
  77985. * @param to defines until which frame should animation run.
  77986. * @param loop defines if the animation loops
  77987. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77988. * @param onAnimationEnd defines the function to be executed when the animation ends
  77989. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77990. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77991. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77992. * @param onAnimationLoop defines the callback to call when an animation loops
  77993. * @returns the list of created animatables
  77994. */
  77995. 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[];
  77996. /**
  77997. * Begin a new animation on a given node
  77998. * @param target defines the target where the animation will take place
  77999. * @param animations defines the list of animations to start
  78000. * @param from defines the initial value
  78001. * @param to defines the final value
  78002. * @param loop defines if you want animation to loop (off by default)
  78003. * @param speedRatio defines the speed ratio to apply to all animations
  78004. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78005. * @param onAnimationLoop defines the callback to call when an animation loops
  78006. * @returns the list of created animatables
  78007. */
  78008. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78009. /**
  78010. * Begin a new animation on a given node and its hierarchy
  78011. * @param target defines the root node where the animation will take place
  78012. * @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.
  78013. * @param animations defines the list of animations to start
  78014. * @param from defines the initial value
  78015. * @param to defines the final value
  78016. * @param loop defines if you want animation to loop (off by default)
  78017. * @param speedRatio defines the speed ratio to apply to all animations
  78018. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78019. * @param onAnimationLoop defines the callback to call when an animation loops
  78020. * @returns the list of animatables created for all nodes
  78021. */
  78022. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78023. /**
  78024. * Gets the animatable associated with a specific target
  78025. * @param target defines the target of the animatable
  78026. * @returns the required animatable if found
  78027. */
  78028. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78029. /**
  78030. * Gets all animatables associated with a given target
  78031. * @param target defines the target to look animatables for
  78032. * @returns an array of Animatables
  78033. */
  78034. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78035. /**
  78036. * Will stop the animation of the given target
  78037. * @param target - the target
  78038. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  78039. * @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)
  78040. */
  78041. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  78042. /**
  78043. * Stops and removes all animations that have been applied to the scene
  78044. */
  78045. stopAllAnimations(): void;
  78046. }
  78047. interface Bone {
  78048. /**
  78049. * Copy an animation range from another bone
  78050. * @param source defines the source bone
  78051. * @param rangeName defines the range name to copy
  78052. * @param frameOffset defines the frame offset
  78053. * @param rescaleAsRequired defines if rescaling must be applied if required
  78054. * @param skelDimensionsRatio defines the scaling ratio
  78055. * @returns true if operation was successful
  78056. */
  78057. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78058. }
  78059. }
  78060. declare module BABYLON {
  78061. /**
  78062. * Class used to handle skinning animations
  78063. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78064. */
  78065. export class Skeleton implements IAnimatable {
  78066. /** defines the skeleton name */
  78067. name: string;
  78068. /** defines the skeleton Id */
  78069. id: string;
  78070. /**
  78071. * Defines the list of child bones
  78072. */
  78073. bones: Bone[];
  78074. /**
  78075. * Defines an estimate of the dimension of the skeleton at rest
  78076. */
  78077. dimensionsAtRest: Vector3;
  78078. /**
  78079. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78080. */
  78081. needInitialSkinMatrix: boolean;
  78082. /**
  78083. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78084. */
  78085. overrideMesh: Nullable<AbstractMesh>;
  78086. /**
  78087. * Gets the list of animations attached to this skeleton
  78088. */
  78089. animations: Array<Animation>;
  78090. private _scene;
  78091. private _isDirty;
  78092. private _transformMatrices;
  78093. private _transformMatrixTexture;
  78094. private _meshesWithPoseMatrix;
  78095. private _animatables;
  78096. private _identity;
  78097. private _synchronizedWithMesh;
  78098. private _ranges;
  78099. private _lastAbsoluteTransformsUpdateId;
  78100. private _canUseTextureForBones;
  78101. private _uniqueId;
  78102. /** @hidden */
  78103. _numBonesWithLinkedTransformNode: number;
  78104. /**
  78105. * Specifies if the skeleton should be serialized
  78106. */
  78107. doNotSerialize: boolean;
  78108. private _useTextureToStoreBoneMatrices;
  78109. /**
  78110. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78111. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  78112. */
  78113. useTextureToStoreBoneMatrices: boolean;
  78114. private _animationPropertiesOverride;
  78115. /**
  78116. * Gets or sets the animation properties override
  78117. */
  78118. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78119. /**
  78120. * List of inspectable custom properties (used by the Inspector)
  78121. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78122. */
  78123. inspectableCustomProperties: IInspectable[];
  78124. /**
  78125. * An observable triggered before computing the skeleton's matrices
  78126. */
  78127. onBeforeComputeObservable: Observable<Skeleton>;
  78128. /**
  78129. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78130. */
  78131. readonly isUsingTextureForMatrices: boolean;
  78132. /**
  78133. * Gets the unique ID of this skeleton
  78134. */
  78135. readonly uniqueId: number;
  78136. /**
  78137. * Creates a new skeleton
  78138. * @param name defines the skeleton name
  78139. * @param id defines the skeleton Id
  78140. * @param scene defines the hosting scene
  78141. */
  78142. constructor(
  78143. /** defines the skeleton name */
  78144. name: string,
  78145. /** defines the skeleton Id */
  78146. id: string, scene: Scene);
  78147. /**
  78148. * Gets the current object class name.
  78149. * @return the class name
  78150. */
  78151. getClassName(): string;
  78152. /**
  78153. * Returns an array containing the root bones
  78154. * @returns an array containing the root bones
  78155. */
  78156. getChildren(): Array<Bone>;
  78157. /**
  78158. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78159. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78160. * @returns a Float32Array containing matrices data
  78161. */
  78162. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78163. /**
  78164. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78165. * @returns a raw texture containing the data
  78166. */
  78167. getTransformMatrixTexture(): Nullable<RawTexture>;
  78168. /**
  78169. * Gets the current hosting scene
  78170. * @returns a scene object
  78171. */
  78172. getScene(): Scene;
  78173. /**
  78174. * Gets a string representing the current skeleton data
  78175. * @param fullDetails defines a boolean indicating if we want a verbose version
  78176. * @returns a string representing the current skeleton data
  78177. */
  78178. toString(fullDetails?: boolean): string;
  78179. /**
  78180. * Get bone's index searching by name
  78181. * @param name defines bone's name to search for
  78182. * @return the indice of the bone. Returns -1 if not found
  78183. */
  78184. getBoneIndexByName(name: string): number;
  78185. /**
  78186. * Creater a new animation range
  78187. * @param name defines the name of the range
  78188. * @param from defines the start key
  78189. * @param to defines the end key
  78190. */
  78191. createAnimationRange(name: string, from: number, to: number): void;
  78192. /**
  78193. * Delete a specific animation range
  78194. * @param name defines the name of the range
  78195. * @param deleteFrames defines if frames must be removed as well
  78196. */
  78197. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78198. /**
  78199. * Gets a specific animation range
  78200. * @param name defines the name of the range to look for
  78201. * @returns the requested animation range or null if not found
  78202. */
  78203. getAnimationRange(name: string): Nullable<AnimationRange>;
  78204. /**
  78205. * Gets the list of all animation ranges defined on this skeleton
  78206. * @returns an array
  78207. */
  78208. getAnimationRanges(): Nullable<AnimationRange>[];
  78209. /**
  78210. * Copy animation range from a source skeleton.
  78211. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78212. * @param source defines the source skeleton
  78213. * @param name defines the name of the range to copy
  78214. * @param rescaleAsRequired defines if rescaling must be applied if required
  78215. * @returns true if operation was successful
  78216. */
  78217. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78218. /**
  78219. * Forces the skeleton to go to rest pose
  78220. */
  78221. returnToRest(): void;
  78222. private _getHighestAnimationFrame;
  78223. /**
  78224. * Begin a specific animation range
  78225. * @param name defines the name of the range to start
  78226. * @param loop defines if looping must be turned on (false by default)
  78227. * @param speedRatio defines the speed ratio to apply (1 by default)
  78228. * @param onAnimationEnd defines a callback which will be called when animation will end
  78229. * @returns a new animatable
  78230. */
  78231. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78232. /** @hidden */
  78233. _markAsDirty(): void;
  78234. /** @hidden */
  78235. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78236. /** @hidden */
  78237. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78238. private _computeTransformMatrices;
  78239. /**
  78240. * Build all resources required to render a skeleton
  78241. */
  78242. prepare(): void;
  78243. /**
  78244. * Gets the list of animatables currently running for this skeleton
  78245. * @returns an array of animatables
  78246. */
  78247. getAnimatables(): IAnimatable[];
  78248. /**
  78249. * Clone the current skeleton
  78250. * @param name defines the name of the new skeleton
  78251. * @param id defines the id of the enw skeleton
  78252. * @returns the new skeleton
  78253. */
  78254. clone(name: string, id: string): Skeleton;
  78255. /**
  78256. * Enable animation blending for this skeleton
  78257. * @param blendingSpeed defines the blending speed to apply
  78258. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78259. */
  78260. enableBlending(blendingSpeed?: number): void;
  78261. /**
  78262. * Releases all resources associated with the current skeleton
  78263. */
  78264. dispose(): void;
  78265. /**
  78266. * Serialize the skeleton in a JSON object
  78267. * @returns a JSON object
  78268. */
  78269. serialize(): any;
  78270. /**
  78271. * Creates a new skeleton from serialized data
  78272. * @param parsedSkeleton defines the serialized data
  78273. * @param scene defines the hosting scene
  78274. * @returns a new skeleton
  78275. */
  78276. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78277. /**
  78278. * Compute all node absolute transforms
  78279. * @param forceUpdate defines if computation must be done even if cache is up to date
  78280. */
  78281. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78282. /**
  78283. * Gets the root pose matrix
  78284. * @returns a matrix
  78285. */
  78286. getPoseMatrix(): Nullable<Matrix>;
  78287. /**
  78288. * Sorts bones per internal index
  78289. */
  78290. sortBones(): void;
  78291. private _sortBones;
  78292. }
  78293. }
  78294. declare module BABYLON {
  78295. /**
  78296. * Defines a target to use with MorphTargetManager
  78297. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78298. */
  78299. export class MorphTarget implements IAnimatable {
  78300. /** defines the name of the target */
  78301. name: string;
  78302. /**
  78303. * Gets or sets the list of animations
  78304. */
  78305. animations: Animation[];
  78306. private _scene;
  78307. private _positions;
  78308. private _normals;
  78309. private _tangents;
  78310. private _influence;
  78311. /**
  78312. * Observable raised when the influence changes
  78313. */
  78314. onInfluenceChanged: Observable<boolean>;
  78315. /** @hidden */
  78316. _onDataLayoutChanged: Observable<void>;
  78317. /**
  78318. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  78319. */
  78320. influence: number;
  78321. /**
  78322. * Gets or sets the id of the morph Target
  78323. */
  78324. id: string;
  78325. private _animationPropertiesOverride;
  78326. /**
  78327. * Gets or sets the animation properties override
  78328. */
  78329. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78330. /**
  78331. * Creates a new MorphTarget
  78332. * @param name defines the name of the target
  78333. * @param influence defines the influence to use
  78334. * @param scene defines the scene the morphtarget belongs to
  78335. */
  78336. constructor(
  78337. /** defines the name of the target */
  78338. name: string, influence?: number, scene?: Nullable<Scene>);
  78339. /**
  78340. * Gets a boolean defining if the target contains position data
  78341. */
  78342. readonly hasPositions: boolean;
  78343. /**
  78344. * Gets a boolean defining if the target contains normal data
  78345. */
  78346. readonly hasNormals: boolean;
  78347. /**
  78348. * Gets a boolean defining if the target contains tangent data
  78349. */
  78350. readonly hasTangents: boolean;
  78351. /**
  78352. * Affects position data to this target
  78353. * @param data defines the position data to use
  78354. */
  78355. setPositions(data: Nullable<FloatArray>): void;
  78356. /**
  78357. * Gets the position data stored in this target
  78358. * @returns a FloatArray containing the position data (or null if not present)
  78359. */
  78360. getPositions(): Nullable<FloatArray>;
  78361. /**
  78362. * Affects normal data to this target
  78363. * @param data defines the normal data to use
  78364. */
  78365. setNormals(data: Nullable<FloatArray>): void;
  78366. /**
  78367. * Gets the normal data stored in this target
  78368. * @returns a FloatArray containing the normal data (or null if not present)
  78369. */
  78370. getNormals(): Nullable<FloatArray>;
  78371. /**
  78372. * Affects tangent data to this target
  78373. * @param data defines the tangent data to use
  78374. */
  78375. setTangents(data: Nullable<FloatArray>): void;
  78376. /**
  78377. * Gets the tangent data stored in this target
  78378. * @returns a FloatArray containing the tangent data (or null if not present)
  78379. */
  78380. getTangents(): Nullable<FloatArray>;
  78381. /**
  78382. * Serializes the current target into a Serialization object
  78383. * @returns the serialized object
  78384. */
  78385. serialize(): any;
  78386. /**
  78387. * Returns the string "MorphTarget"
  78388. * @returns "MorphTarget"
  78389. */
  78390. getClassName(): string;
  78391. /**
  78392. * Creates a new target from serialized data
  78393. * @param serializationObject defines the serialized data to use
  78394. * @returns a new MorphTarget
  78395. */
  78396. static Parse(serializationObject: any): MorphTarget;
  78397. /**
  78398. * Creates a MorphTarget from mesh data
  78399. * @param mesh defines the source mesh
  78400. * @param name defines the name to use for the new target
  78401. * @param influence defines the influence to attach to the target
  78402. * @returns a new MorphTarget
  78403. */
  78404. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  78405. }
  78406. }
  78407. declare module BABYLON {
  78408. /**
  78409. * This class is used to deform meshes using morphing between different targets
  78410. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78411. */
  78412. export class MorphTargetManager {
  78413. private _targets;
  78414. private _targetInfluenceChangedObservers;
  78415. private _targetDataLayoutChangedObservers;
  78416. private _activeTargets;
  78417. private _scene;
  78418. private _influences;
  78419. private _supportsNormals;
  78420. private _supportsTangents;
  78421. private _vertexCount;
  78422. private _uniqueId;
  78423. private _tempInfluences;
  78424. /**
  78425. * Creates a new MorphTargetManager
  78426. * @param scene defines the current scene
  78427. */
  78428. constructor(scene?: Nullable<Scene>);
  78429. /**
  78430. * Gets the unique ID of this manager
  78431. */
  78432. readonly uniqueId: number;
  78433. /**
  78434. * Gets the number of vertices handled by this manager
  78435. */
  78436. readonly vertexCount: number;
  78437. /**
  78438. * Gets a boolean indicating if this manager supports morphing of normals
  78439. */
  78440. readonly supportsNormals: boolean;
  78441. /**
  78442. * Gets a boolean indicating if this manager supports morphing of tangents
  78443. */
  78444. readonly supportsTangents: boolean;
  78445. /**
  78446. * Gets the number of targets stored in this manager
  78447. */
  78448. readonly numTargets: number;
  78449. /**
  78450. * Gets the number of influencers (ie. the number of targets with influences > 0)
  78451. */
  78452. readonly numInfluencers: number;
  78453. /**
  78454. * Gets the list of influences (one per target)
  78455. */
  78456. readonly influences: Float32Array;
  78457. /**
  78458. * Gets the active target at specified index. An active target is a target with an influence > 0
  78459. * @param index defines the index to check
  78460. * @returns the requested target
  78461. */
  78462. getActiveTarget(index: number): MorphTarget;
  78463. /**
  78464. * Gets the target at specified index
  78465. * @param index defines the index to check
  78466. * @returns the requested target
  78467. */
  78468. getTarget(index: number): MorphTarget;
  78469. /**
  78470. * Add a new target to this manager
  78471. * @param target defines the target to add
  78472. */
  78473. addTarget(target: MorphTarget): void;
  78474. /**
  78475. * Removes a target from the manager
  78476. * @param target defines the target to remove
  78477. */
  78478. removeTarget(target: MorphTarget): void;
  78479. /**
  78480. * Serializes the current manager into a Serialization object
  78481. * @returns the serialized object
  78482. */
  78483. serialize(): any;
  78484. private _syncActiveTargets;
  78485. /**
  78486. * Syncrhonize the targets with all the meshes using this morph target manager
  78487. */
  78488. synchronize(): void;
  78489. /**
  78490. * Creates a new MorphTargetManager from serialized data
  78491. * @param serializationObject defines the serialized data
  78492. * @param scene defines the hosting scene
  78493. * @returns the new MorphTargetManager
  78494. */
  78495. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  78496. }
  78497. }
  78498. declare module BABYLON {
  78499. /**
  78500. * Mesh representing the gorund
  78501. */
  78502. export class GroundMesh extends Mesh {
  78503. /** If octree should be generated */
  78504. generateOctree: boolean;
  78505. private _heightQuads;
  78506. /** @hidden */
  78507. _subdivisionsX: number;
  78508. /** @hidden */
  78509. _subdivisionsY: number;
  78510. /** @hidden */
  78511. _width: number;
  78512. /** @hidden */
  78513. _height: number;
  78514. /** @hidden */
  78515. _minX: number;
  78516. /** @hidden */
  78517. _maxX: number;
  78518. /** @hidden */
  78519. _minZ: number;
  78520. /** @hidden */
  78521. _maxZ: number;
  78522. constructor(name: string, scene: Scene);
  78523. /**
  78524. * "GroundMesh"
  78525. * @returns "GroundMesh"
  78526. */
  78527. getClassName(): string;
  78528. /**
  78529. * The minimum of x and y subdivisions
  78530. */
  78531. readonly subdivisions: number;
  78532. /**
  78533. * X subdivisions
  78534. */
  78535. readonly subdivisionsX: number;
  78536. /**
  78537. * Y subdivisions
  78538. */
  78539. readonly subdivisionsY: number;
  78540. /**
  78541. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  78542. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  78543. * @param chunksCount the number of subdivisions for x and y
  78544. * @param octreeBlocksSize (Default: 32)
  78545. */
  78546. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  78547. /**
  78548. * Returns a height (y) value in the Worl system :
  78549. * the ground altitude at the coordinates (x, z) expressed in the World system.
  78550. * @param x x coordinate
  78551. * @param z z coordinate
  78552. * @returns the ground y position if (x, z) are outside the ground surface.
  78553. */
  78554. getHeightAtCoordinates(x: number, z: number): number;
  78555. /**
  78556. * Returns a normalized vector (Vector3) orthogonal to the ground
  78557. * at the ground coordinates (x, z) expressed in the World system.
  78558. * @param x x coordinate
  78559. * @param z z coordinate
  78560. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  78561. */
  78562. getNormalAtCoordinates(x: number, z: number): Vector3;
  78563. /**
  78564. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  78565. * at the ground coordinates (x, z) expressed in the World system.
  78566. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  78567. * @param x x coordinate
  78568. * @param z z coordinate
  78569. * @param ref vector to store the result
  78570. * @returns the GroundMesh.
  78571. */
  78572. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  78573. /**
  78574. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  78575. * if the ground has been updated.
  78576. * This can be used in the render loop.
  78577. * @returns the GroundMesh.
  78578. */
  78579. updateCoordinateHeights(): GroundMesh;
  78580. private _getFacetAt;
  78581. private _initHeightQuads;
  78582. private _computeHeightQuads;
  78583. /**
  78584. * Serializes this ground mesh
  78585. * @param serializationObject object to write serialization to
  78586. */
  78587. serialize(serializationObject: any): void;
  78588. /**
  78589. * Parses a serialized ground mesh
  78590. * @param parsedMesh the serialized mesh
  78591. * @param scene the scene to create the ground mesh in
  78592. * @returns the created ground mesh
  78593. */
  78594. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  78595. }
  78596. }
  78597. declare module BABYLON {
  78598. /**
  78599. * Interface for Physics-Joint data
  78600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78601. */
  78602. export interface PhysicsJointData {
  78603. /**
  78604. * The main pivot of the joint
  78605. */
  78606. mainPivot?: Vector3;
  78607. /**
  78608. * The connected pivot of the joint
  78609. */
  78610. connectedPivot?: Vector3;
  78611. /**
  78612. * The main axis of the joint
  78613. */
  78614. mainAxis?: Vector3;
  78615. /**
  78616. * The connected axis of the joint
  78617. */
  78618. connectedAxis?: Vector3;
  78619. /**
  78620. * The collision of the joint
  78621. */
  78622. collision?: boolean;
  78623. /**
  78624. * Native Oimo/Cannon/Energy data
  78625. */
  78626. nativeParams?: any;
  78627. }
  78628. /**
  78629. * This is a holder class for the physics joint created by the physics plugin
  78630. * It holds a set of functions to control the underlying joint
  78631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78632. */
  78633. export class PhysicsJoint {
  78634. /**
  78635. * The type of the physics joint
  78636. */
  78637. type: number;
  78638. /**
  78639. * The data for the physics joint
  78640. */
  78641. jointData: PhysicsJointData;
  78642. private _physicsJoint;
  78643. protected _physicsPlugin: IPhysicsEnginePlugin;
  78644. /**
  78645. * Initializes the physics joint
  78646. * @param type The type of the physics joint
  78647. * @param jointData The data for the physics joint
  78648. */
  78649. constructor(
  78650. /**
  78651. * The type of the physics joint
  78652. */
  78653. type: number,
  78654. /**
  78655. * The data for the physics joint
  78656. */
  78657. jointData: PhysicsJointData);
  78658. /**
  78659. * Gets the physics joint
  78660. */
  78661. /**
  78662. * Sets the physics joint
  78663. */
  78664. physicsJoint: any;
  78665. /**
  78666. * Sets the physics plugin
  78667. */
  78668. physicsPlugin: IPhysicsEnginePlugin;
  78669. /**
  78670. * Execute a function that is physics-plugin specific.
  78671. * @param {Function} func the function that will be executed.
  78672. * It accepts two parameters: the physics world and the physics joint
  78673. */
  78674. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  78675. /**
  78676. * Distance-Joint type
  78677. */
  78678. static DistanceJoint: number;
  78679. /**
  78680. * Hinge-Joint type
  78681. */
  78682. static HingeJoint: number;
  78683. /**
  78684. * Ball-and-Socket joint type
  78685. */
  78686. static BallAndSocketJoint: number;
  78687. /**
  78688. * Wheel-Joint type
  78689. */
  78690. static WheelJoint: number;
  78691. /**
  78692. * Slider-Joint type
  78693. */
  78694. static SliderJoint: number;
  78695. /**
  78696. * Prismatic-Joint type
  78697. */
  78698. static PrismaticJoint: number;
  78699. /**
  78700. * Universal-Joint type
  78701. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  78702. */
  78703. static UniversalJoint: number;
  78704. /**
  78705. * Hinge-Joint 2 type
  78706. */
  78707. static Hinge2Joint: number;
  78708. /**
  78709. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  78710. */
  78711. static PointToPointJoint: number;
  78712. /**
  78713. * Spring-Joint type
  78714. */
  78715. static SpringJoint: number;
  78716. /**
  78717. * Lock-Joint type
  78718. */
  78719. static LockJoint: number;
  78720. }
  78721. /**
  78722. * A class representing a physics distance joint
  78723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78724. */
  78725. export class DistanceJoint extends PhysicsJoint {
  78726. /**
  78727. *
  78728. * @param jointData The data for the Distance-Joint
  78729. */
  78730. constructor(jointData: DistanceJointData);
  78731. /**
  78732. * Update the predefined distance.
  78733. * @param maxDistance The maximum preferred distance
  78734. * @param minDistance The minimum preferred distance
  78735. */
  78736. updateDistance(maxDistance: number, minDistance?: number): void;
  78737. }
  78738. /**
  78739. * Represents a Motor-Enabled Joint
  78740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78741. */
  78742. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  78743. /**
  78744. * Initializes the Motor-Enabled Joint
  78745. * @param type The type of the joint
  78746. * @param jointData The physica joint data for the joint
  78747. */
  78748. constructor(type: number, jointData: PhysicsJointData);
  78749. /**
  78750. * Set the motor values.
  78751. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78752. * @param force the force to apply
  78753. * @param maxForce max force for this motor.
  78754. */
  78755. setMotor(force?: number, maxForce?: number): void;
  78756. /**
  78757. * Set the motor's limits.
  78758. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78759. * @param upperLimit The upper limit of the motor
  78760. * @param lowerLimit The lower limit of the motor
  78761. */
  78762. setLimit(upperLimit: number, lowerLimit?: number): void;
  78763. }
  78764. /**
  78765. * This class represents a single physics Hinge-Joint
  78766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78767. */
  78768. export class HingeJoint extends MotorEnabledJoint {
  78769. /**
  78770. * Initializes the Hinge-Joint
  78771. * @param jointData The joint data for the Hinge-Joint
  78772. */
  78773. constructor(jointData: PhysicsJointData);
  78774. /**
  78775. * Set the motor values.
  78776. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78777. * @param {number} force the force to apply
  78778. * @param {number} maxForce max force for this motor.
  78779. */
  78780. setMotor(force?: number, maxForce?: number): void;
  78781. /**
  78782. * Set the motor's limits.
  78783. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78784. * @param upperLimit The upper limit of the motor
  78785. * @param lowerLimit The lower limit of the motor
  78786. */
  78787. setLimit(upperLimit: number, lowerLimit?: number): void;
  78788. }
  78789. /**
  78790. * This class represents a dual hinge physics joint (same as wheel joint)
  78791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78792. */
  78793. export class Hinge2Joint extends MotorEnabledJoint {
  78794. /**
  78795. * Initializes the Hinge2-Joint
  78796. * @param jointData The joint data for the Hinge2-Joint
  78797. */
  78798. constructor(jointData: PhysicsJointData);
  78799. /**
  78800. * Set the motor values.
  78801. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78802. * @param {number} targetSpeed the speed the motor is to reach
  78803. * @param {number} maxForce max force for this motor.
  78804. * @param {motorIndex} the motor's index, 0 or 1.
  78805. */
  78806. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  78807. /**
  78808. * Set the motor limits.
  78809. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78810. * @param {number} upperLimit the upper limit
  78811. * @param {number} lowerLimit lower limit
  78812. * @param {motorIndex} the motor's index, 0 or 1.
  78813. */
  78814. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78815. }
  78816. /**
  78817. * Interface for a motor enabled joint
  78818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78819. */
  78820. export interface IMotorEnabledJoint {
  78821. /**
  78822. * Physics joint
  78823. */
  78824. physicsJoint: any;
  78825. /**
  78826. * Sets the motor of the motor-enabled joint
  78827. * @param force The force of the motor
  78828. * @param maxForce The maximum force of the motor
  78829. * @param motorIndex The index of the motor
  78830. */
  78831. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  78832. /**
  78833. * Sets the limit of the motor
  78834. * @param upperLimit The upper limit of the motor
  78835. * @param lowerLimit The lower limit of the motor
  78836. * @param motorIndex The index of the motor
  78837. */
  78838. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78839. }
  78840. /**
  78841. * Joint data for a Distance-Joint
  78842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78843. */
  78844. export interface DistanceJointData extends PhysicsJointData {
  78845. /**
  78846. * Max distance the 2 joint objects can be apart
  78847. */
  78848. maxDistance: number;
  78849. }
  78850. /**
  78851. * Joint data from a spring joint
  78852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78853. */
  78854. export interface SpringJointData extends PhysicsJointData {
  78855. /**
  78856. * Length of the spring
  78857. */
  78858. length: number;
  78859. /**
  78860. * Stiffness of the spring
  78861. */
  78862. stiffness: number;
  78863. /**
  78864. * Damping of the spring
  78865. */
  78866. damping: number;
  78867. /** this callback will be called when applying the force to the impostors. */
  78868. forceApplicationCallback: () => void;
  78869. }
  78870. }
  78871. declare module BABYLON {
  78872. /**
  78873. * Holds the data for the raycast result
  78874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78875. */
  78876. export class PhysicsRaycastResult {
  78877. private _hasHit;
  78878. private _hitDistance;
  78879. private _hitNormalWorld;
  78880. private _hitPointWorld;
  78881. private _rayFromWorld;
  78882. private _rayToWorld;
  78883. /**
  78884. * Gets if there was a hit
  78885. */
  78886. readonly hasHit: boolean;
  78887. /**
  78888. * Gets the distance from the hit
  78889. */
  78890. readonly hitDistance: number;
  78891. /**
  78892. * Gets the hit normal/direction in the world
  78893. */
  78894. readonly hitNormalWorld: Vector3;
  78895. /**
  78896. * Gets the hit point in the world
  78897. */
  78898. readonly hitPointWorld: Vector3;
  78899. /**
  78900. * Gets the ray "start point" of the ray in the world
  78901. */
  78902. readonly rayFromWorld: Vector3;
  78903. /**
  78904. * Gets the ray "end point" of the ray in the world
  78905. */
  78906. readonly rayToWorld: Vector3;
  78907. /**
  78908. * Sets the hit data (normal & point in world space)
  78909. * @param hitNormalWorld defines the normal in world space
  78910. * @param hitPointWorld defines the point in world space
  78911. */
  78912. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  78913. /**
  78914. * Sets the distance from the start point to the hit point
  78915. * @param distance
  78916. */
  78917. setHitDistance(distance: number): void;
  78918. /**
  78919. * Calculates the distance manually
  78920. */
  78921. calculateHitDistance(): void;
  78922. /**
  78923. * Resets all the values to default
  78924. * @param from The from point on world space
  78925. * @param to The to point on world space
  78926. */
  78927. reset(from?: Vector3, to?: Vector3): void;
  78928. }
  78929. /**
  78930. * Interface for the size containing width and height
  78931. */
  78932. interface IXYZ {
  78933. /**
  78934. * X
  78935. */
  78936. x: number;
  78937. /**
  78938. * Y
  78939. */
  78940. y: number;
  78941. /**
  78942. * Z
  78943. */
  78944. z: number;
  78945. }
  78946. }
  78947. declare module BABYLON {
  78948. /**
  78949. * Interface used to describe a physics joint
  78950. */
  78951. export interface PhysicsImpostorJoint {
  78952. /** Defines the main impostor to which the joint is linked */
  78953. mainImpostor: PhysicsImpostor;
  78954. /** Defines the impostor that is connected to the main impostor using this joint */
  78955. connectedImpostor: PhysicsImpostor;
  78956. /** Defines the joint itself */
  78957. joint: PhysicsJoint;
  78958. }
  78959. /** @hidden */
  78960. export interface IPhysicsEnginePlugin {
  78961. world: any;
  78962. name: string;
  78963. setGravity(gravity: Vector3): void;
  78964. setTimeStep(timeStep: number): void;
  78965. getTimeStep(): number;
  78966. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  78967. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  78968. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  78969. generatePhysicsBody(impostor: PhysicsImpostor): void;
  78970. removePhysicsBody(impostor: PhysicsImpostor): void;
  78971. generateJoint(joint: PhysicsImpostorJoint): void;
  78972. removeJoint(joint: PhysicsImpostorJoint): void;
  78973. isSupported(): boolean;
  78974. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  78975. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  78976. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  78977. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  78978. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  78979. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  78980. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  78981. getBodyMass(impostor: PhysicsImpostor): number;
  78982. getBodyFriction(impostor: PhysicsImpostor): number;
  78983. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  78984. getBodyRestitution(impostor: PhysicsImpostor): number;
  78985. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  78986. getBodyPressure?(impostor: PhysicsImpostor): number;
  78987. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  78988. getBodyStiffness?(impostor: PhysicsImpostor): number;
  78989. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  78990. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  78991. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  78992. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  78993. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  78994. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  78995. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  78996. sleepBody(impostor: PhysicsImpostor): void;
  78997. wakeUpBody(impostor: PhysicsImpostor): void;
  78998. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78999. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  79000. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  79001. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79002. getRadius(impostor: PhysicsImpostor): number;
  79003. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  79004. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  79005. dispose(): void;
  79006. }
  79007. /**
  79008. * Interface used to define a physics engine
  79009. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  79010. */
  79011. export interface IPhysicsEngine {
  79012. /**
  79013. * Gets the gravity vector used by the simulation
  79014. */
  79015. gravity: Vector3;
  79016. /**
  79017. * Sets the gravity vector used by the simulation
  79018. * @param gravity defines the gravity vector to use
  79019. */
  79020. setGravity(gravity: Vector3): void;
  79021. /**
  79022. * Set the time step of the physics engine.
  79023. * Default is 1/60.
  79024. * To slow it down, enter 1/600 for example.
  79025. * To speed it up, 1/30
  79026. * @param newTimeStep the new timestep to apply to this world.
  79027. */
  79028. setTimeStep(newTimeStep: number): void;
  79029. /**
  79030. * Get the time step of the physics engine.
  79031. * @returns the current time step
  79032. */
  79033. getTimeStep(): number;
  79034. /**
  79035. * Release all resources
  79036. */
  79037. dispose(): void;
  79038. /**
  79039. * Gets the name of the current physics plugin
  79040. * @returns the name of the plugin
  79041. */
  79042. getPhysicsPluginName(): string;
  79043. /**
  79044. * Adding a new impostor for the impostor tracking.
  79045. * This will be done by the impostor itself.
  79046. * @param impostor the impostor to add
  79047. */
  79048. addImpostor(impostor: PhysicsImpostor): void;
  79049. /**
  79050. * Remove an impostor from the engine.
  79051. * This impostor and its mesh will not longer be updated by the physics engine.
  79052. * @param impostor the impostor to remove
  79053. */
  79054. removeImpostor(impostor: PhysicsImpostor): void;
  79055. /**
  79056. * Add a joint to the physics engine
  79057. * @param mainImpostor defines the main impostor to which the joint is added.
  79058. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  79059. * @param joint defines the joint that will connect both impostors.
  79060. */
  79061. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79062. /**
  79063. * Removes a joint from the simulation
  79064. * @param mainImpostor defines the impostor used with the joint
  79065. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  79066. * @param joint defines the joint to remove
  79067. */
  79068. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79069. /**
  79070. * Gets the current plugin used to run the simulation
  79071. * @returns current plugin
  79072. */
  79073. getPhysicsPlugin(): IPhysicsEnginePlugin;
  79074. /**
  79075. * Gets the list of physic impostors
  79076. * @returns an array of PhysicsImpostor
  79077. */
  79078. getImpostors(): Array<PhysicsImpostor>;
  79079. /**
  79080. * Gets the impostor for a physics enabled object
  79081. * @param object defines the object impersonated by the impostor
  79082. * @returns the PhysicsImpostor or null if not found
  79083. */
  79084. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79085. /**
  79086. * Gets the impostor for a physics body object
  79087. * @param body defines physics body used by the impostor
  79088. * @returns the PhysicsImpostor or null if not found
  79089. */
  79090. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  79091. /**
  79092. * Does a raycast in the physics world
  79093. * @param from when should the ray start?
  79094. * @param to when should the ray end?
  79095. * @returns PhysicsRaycastResult
  79096. */
  79097. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79098. /**
  79099. * Called by the scene. No need to call it.
  79100. * @param delta defines the timespam between frames
  79101. */
  79102. _step(delta: number): void;
  79103. }
  79104. }
  79105. declare module BABYLON {
  79106. /**
  79107. * The interface for the physics imposter parameters
  79108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79109. */
  79110. export interface PhysicsImpostorParameters {
  79111. /**
  79112. * The mass of the physics imposter
  79113. */
  79114. mass: number;
  79115. /**
  79116. * The friction of the physics imposter
  79117. */
  79118. friction?: number;
  79119. /**
  79120. * The coefficient of restitution of the physics imposter
  79121. */
  79122. restitution?: number;
  79123. /**
  79124. * The native options of the physics imposter
  79125. */
  79126. nativeOptions?: any;
  79127. /**
  79128. * Specifies if the parent should be ignored
  79129. */
  79130. ignoreParent?: boolean;
  79131. /**
  79132. * Specifies if bi-directional transformations should be disabled
  79133. */
  79134. disableBidirectionalTransformation?: boolean;
  79135. /**
  79136. * The pressure inside the physics imposter, soft object only
  79137. */
  79138. pressure?: number;
  79139. /**
  79140. * The stiffness the physics imposter, soft object only
  79141. */
  79142. stiffness?: number;
  79143. /**
  79144. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  79145. */
  79146. velocityIterations?: number;
  79147. /**
  79148. * The number of iterations used in maintaining consistent vertex positions, soft object only
  79149. */
  79150. positionIterations?: number;
  79151. /**
  79152. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  79153. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  79154. * Add to fix multiple points
  79155. */
  79156. fixedPoints?: number;
  79157. /**
  79158. * The collision margin around a soft object
  79159. */
  79160. margin?: number;
  79161. /**
  79162. * The collision margin around a soft object
  79163. */
  79164. damping?: number;
  79165. /**
  79166. * The path for a rope based on an extrusion
  79167. */
  79168. path?: any;
  79169. /**
  79170. * The shape of an extrusion used for a rope based on an extrusion
  79171. */
  79172. shape?: any;
  79173. }
  79174. /**
  79175. * Interface for a physics-enabled object
  79176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79177. */
  79178. export interface IPhysicsEnabledObject {
  79179. /**
  79180. * The position of the physics-enabled object
  79181. */
  79182. position: Vector3;
  79183. /**
  79184. * The rotation of the physics-enabled object
  79185. */
  79186. rotationQuaternion: Nullable<Quaternion>;
  79187. /**
  79188. * The scale of the physics-enabled object
  79189. */
  79190. scaling: Vector3;
  79191. /**
  79192. * The rotation of the physics-enabled object
  79193. */
  79194. rotation?: Vector3;
  79195. /**
  79196. * The parent of the physics-enabled object
  79197. */
  79198. parent?: any;
  79199. /**
  79200. * The bounding info of the physics-enabled object
  79201. * @returns The bounding info of the physics-enabled object
  79202. */
  79203. getBoundingInfo(): BoundingInfo;
  79204. /**
  79205. * Computes the world matrix
  79206. * @param force Specifies if the world matrix should be computed by force
  79207. * @returns A world matrix
  79208. */
  79209. computeWorldMatrix(force: boolean): Matrix;
  79210. /**
  79211. * Gets the world matrix
  79212. * @returns A world matrix
  79213. */
  79214. getWorldMatrix?(): Matrix;
  79215. /**
  79216. * Gets the child meshes
  79217. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  79218. * @returns An array of abstract meshes
  79219. */
  79220. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  79221. /**
  79222. * Gets the vertex data
  79223. * @param kind The type of vertex data
  79224. * @returns A nullable array of numbers, or a float32 array
  79225. */
  79226. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  79227. /**
  79228. * Gets the indices from the mesh
  79229. * @returns A nullable array of index arrays
  79230. */
  79231. getIndices?(): Nullable<IndicesArray>;
  79232. /**
  79233. * Gets the scene from the mesh
  79234. * @returns the indices array or null
  79235. */
  79236. getScene?(): Scene;
  79237. /**
  79238. * Gets the absolute position from the mesh
  79239. * @returns the absolute position
  79240. */
  79241. getAbsolutePosition(): Vector3;
  79242. /**
  79243. * Gets the absolute pivot point from the mesh
  79244. * @returns the absolute pivot point
  79245. */
  79246. getAbsolutePivotPoint(): Vector3;
  79247. /**
  79248. * Rotates the mesh
  79249. * @param axis The axis of rotation
  79250. * @param amount The amount of rotation
  79251. * @param space The space of the rotation
  79252. * @returns The rotation transform node
  79253. */
  79254. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79255. /**
  79256. * Translates the mesh
  79257. * @param axis The axis of translation
  79258. * @param distance The distance of translation
  79259. * @param space The space of the translation
  79260. * @returns The transform node
  79261. */
  79262. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79263. /**
  79264. * Sets the absolute position of the mesh
  79265. * @param absolutePosition The absolute position of the mesh
  79266. * @returns The transform node
  79267. */
  79268. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79269. /**
  79270. * Gets the class name of the mesh
  79271. * @returns The class name
  79272. */
  79273. getClassName(): string;
  79274. }
  79275. /**
  79276. * Represents a physics imposter
  79277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79278. */
  79279. export class PhysicsImpostor {
  79280. /**
  79281. * The physics-enabled object used as the physics imposter
  79282. */
  79283. object: IPhysicsEnabledObject;
  79284. /**
  79285. * The type of the physics imposter
  79286. */
  79287. type: number;
  79288. private _options;
  79289. private _scene?;
  79290. /**
  79291. * The default object size of the imposter
  79292. */
  79293. static DEFAULT_OBJECT_SIZE: Vector3;
  79294. /**
  79295. * The identity quaternion of the imposter
  79296. */
  79297. static IDENTITY_QUATERNION: Quaternion;
  79298. /** @hidden */
  79299. _pluginData: any;
  79300. private _physicsEngine;
  79301. private _physicsBody;
  79302. private _bodyUpdateRequired;
  79303. private _onBeforePhysicsStepCallbacks;
  79304. private _onAfterPhysicsStepCallbacks;
  79305. /** @hidden */
  79306. _onPhysicsCollideCallbacks: Array<{
  79307. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  79308. otherImpostors: Array<PhysicsImpostor>;
  79309. }>;
  79310. private _deltaPosition;
  79311. private _deltaRotation;
  79312. private _deltaRotationConjugated;
  79313. /** hidden */
  79314. _isFromLine: boolean;
  79315. private _parent;
  79316. private _isDisposed;
  79317. private static _tmpVecs;
  79318. private static _tmpQuat;
  79319. /**
  79320. * Specifies if the physics imposter is disposed
  79321. */
  79322. readonly isDisposed: boolean;
  79323. /**
  79324. * Gets the mass of the physics imposter
  79325. */
  79326. mass: number;
  79327. /**
  79328. * Gets the coefficient of friction
  79329. */
  79330. /**
  79331. * Sets the coefficient of friction
  79332. */
  79333. friction: number;
  79334. /**
  79335. * Gets the coefficient of restitution
  79336. */
  79337. /**
  79338. * Sets the coefficient of restitution
  79339. */
  79340. restitution: number;
  79341. /**
  79342. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  79343. */
  79344. /**
  79345. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  79346. */
  79347. pressure: number;
  79348. /**
  79349. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79350. */
  79351. /**
  79352. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79353. */
  79354. stiffness: number;
  79355. /**
  79356. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79357. */
  79358. /**
  79359. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79360. */
  79361. velocityIterations: number;
  79362. /**
  79363. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79364. */
  79365. /**
  79366. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79367. */
  79368. positionIterations: number;
  79369. /**
  79370. * The unique id of the physics imposter
  79371. * set by the physics engine when adding this impostor to the array
  79372. */
  79373. uniqueId: number;
  79374. /**
  79375. * @hidden
  79376. */
  79377. soft: boolean;
  79378. /**
  79379. * @hidden
  79380. */
  79381. segments: number;
  79382. private _joints;
  79383. /**
  79384. * Initializes the physics imposter
  79385. * @param object The physics-enabled object used as the physics imposter
  79386. * @param type The type of the physics imposter
  79387. * @param _options The options for the physics imposter
  79388. * @param _scene The Babylon scene
  79389. */
  79390. constructor(
  79391. /**
  79392. * The physics-enabled object used as the physics imposter
  79393. */
  79394. object: IPhysicsEnabledObject,
  79395. /**
  79396. * The type of the physics imposter
  79397. */
  79398. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  79399. /**
  79400. * This function will completly initialize this impostor.
  79401. * It will create a new body - but only if this mesh has no parent.
  79402. * If it has, this impostor will not be used other than to define the impostor
  79403. * of the child mesh.
  79404. * @hidden
  79405. */
  79406. _init(): void;
  79407. private _getPhysicsParent;
  79408. /**
  79409. * Should a new body be generated.
  79410. * @returns boolean specifying if body initialization is required
  79411. */
  79412. isBodyInitRequired(): boolean;
  79413. /**
  79414. * Sets the updated scaling
  79415. * @param updated Specifies if the scaling is updated
  79416. */
  79417. setScalingUpdated(): void;
  79418. /**
  79419. * Force a regeneration of this or the parent's impostor's body.
  79420. * Use under cautious - This will remove all joints already implemented.
  79421. */
  79422. forceUpdate(): void;
  79423. /**
  79424. * Gets the body that holds this impostor. Either its own, or its parent.
  79425. */
  79426. /**
  79427. * Set the physics body. Used mainly by the physics engine/plugin
  79428. */
  79429. physicsBody: any;
  79430. /**
  79431. * Get the parent of the physics imposter
  79432. * @returns Physics imposter or null
  79433. */
  79434. /**
  79435. * Sets the parent of the physics imposter
  79436. */
  79437. parent: Nullable<PhysicsImpostor>;
  79438. /**
  79439. * Resets the update flags
  79440. */
  79441. resetUpdateFlags(): void;
  79442. /**
  79443. * Gets the object extend size
  79444. * @returns the object extend size
  79445. */
  79446. getObjectExtendSize(): Vector3;
  79447. /**
  79448. * Gets the object center
  79449. * @returns The object center
  79450. */
  79451. getObjectCenter(): Vector3;
  79452. /**
  79453. * Get a specific parametes from the options parameter
  79454. * @param paramName The object parameter name
  79455. * @returns The object parameter
  79456. */
  79457. getParam(paramName: string): any;
  79458. /**
  79459. * Sets a specific parameter in the options given to the physics plugin
  79460. * @param paramName The parameter name
  79461. * @param value The value of the parameter
  79462. */
  79463. setParam(paramName: string, value: number): void;
  79464. /**
  79465. * Specifically change the body's mass option. Won't recreate the physics body object
  79466. * @param mass The mass of the physics imposter
  79467. */
  79468. setMass(mass: number): void;
  79469. /**
  79470. * Gets the linear velocity
  79471. * @returns linear velocity or null
  79472. */
  79473. getLinearVelocity(): Nullable<Vector3>;
  79474. /**
  79475. * Sets the linear velocity
  79476. * @param velocity linear velocity or null
  79477. */
  79478. setLinearVelocity(velocity: Nullable<Vector3>): void;
  79479. /**
  79480. * Gets the angular velocity
  79481. * @returns angular velocity or null
  79482. */
  79483. getAngularVelocity(): Nullable<Vector3>;
  79484. /**
  79485. * Sets the angular velocity
  79486. * @param velocity The velocity or null
  79487. */
  79488. setAngularVelocity(velocity: Nullable<Vector3>): void;
  79489. /**
  79490. * Execute a function with the physics plugin native code
  79491. * Provide a function the will have two variables - the world object and the physics body object
  79492. * @param func The function to execute with the physics plugin native code
  79493. */
  79494. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  79495. /**
  79496. * Register a function that will be executed before the physics world is stepping forward
  79497. * @param func The function to execute before the physics world is stepped forward
  79498. */
  79499. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79500. /**
  79501. * Unregister a function that will be executed before the physics world is stepping forward
  79502. * @param func The function to execute before the physics world is stepped forward
  79503. */
  79504. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79505. /**
  79506. * Register a function that will be executed after the physics step
  79507. * @param func The function to execute after physics step
  79508. */
  79509. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79510. /**
  79511. * Unregisters a function that will be executed after the physics step
  79512. * @param func The function to execute after physics step
  79513. */
  79514. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79515. /**
  79516. * register a function that will be executed when this impostor collides against a different body
  79517. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  79518. * @param func Callback that is executed on collision
  79519. */
  79520. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  79521. /**
  79522. * Unregisters the physics imposter on contact
  79523. * @param collideAgainst The physics object to collide against
  79524. * @param func Callback to execute on collision
  79525. */
  79526. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  79527. private _tmpQuat;
  79528. private _tmpQuat2;
  79529. /**
  79530. * Get the parent rotation
  79531. * @returns The parent rotation
  79532. */
  79533. getParentsRotation(): Quaternion;
  79534. /**
  79535. * this function is executed by the physics engine.
  79536. */
  79537. beforeStep: () => void;
  79538. /**
  79539. * this function is executed by the physics engine
  79540. */
  79541. afterStep: () => void;
  79542. /**
  79543. * Legacy collision detection event support
  79544. */
  79545. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  79546. /**
  79547. * event and body object due to cannon's event-based architecture.
  79548. */
  79549. onCollide: (e: {
  79550. body: any;
  79551. }) => void;
  79552. /**
  79553. * Apply a force
  79554. * @param force The force to apply
  79555. * @param contactPoint The contact point for the force
  79556. * @returns The physics imposter
  79557. */
  79558. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79559. /**
  79560. * Apply an impulse
  79561. * @param force The impulse force
  79562. * @param contactPoint The contact point for the impulse force
  79563. * @returns The physics imposter
  79564. */
  79565. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79566. /**
  79567. * A help function to create a joint
  79568. * @param otherImpostor A physics imposter used to create a joint
  79569. * @param jointType The type of joint
  79570. * @param jointData The data for the joint
  79571. * @returns The physics imposter
  79572. */
  79573. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  79574. /**
  79575. * Add a joint to this impostor with a different impostor
  79576. * @param otherImpostor A physics imposter used to add a joint
  79577. * @param joint The joint to add
  79578. * @returns The physics imposter
  79579. */
  79580. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  79581. /**
  79582. * Add an anchor to a cloth impostor
  79583. * @param otherImpostor rigid impostor to anchor to
  79584. * @param width ratio across width from 0 to 1
  79585. * @param height ratio up height from 0 to 1
  79586. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  79587. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  79588. * @returns impostor the soft imposter
  79589. */
  79590. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79591. /**
  79592. * Add a hook to a rope impostor
  79593. * @param otherImpostor rigid impostor to anchor to
  79594. * @param length ratio across rope from 0 to 1
  79595. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  79596. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  79597. * @returns impostor the rope imposter
  79598. */
  79599. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79600. /**
  79601. * Will keep this body still, in a sleep mode.
  79602. * @returns the physics imposter
  79603. */
  79604. sleep(): PhysicsImpostor;
  79605. /**
  79606. * Wake the body up.
  79607. * @returns The physics imposter
  79608. */
  79609. wakeUp(): PhysicsImpostor;
  79610. /**
  79611. * Clones the physics imposter
  79612. * @param newObject The physics imposter clones to this physics-enabled object
  79613. * @returns A nullable physics imposter
  79614. */
  79615. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79616. /**
  79617. * Disposes the physics imposter
  79618. */
  79619. dispose(): void;
  79620. /**
  79621. * Sets the delta position
  79622. * @param position The delta position amount
  79623. */
  79624. setDeltaPosition(position: Vector3): void;
  79625. /**
  79626. * Sets the delta rotation
  79627. * @param rotation The delta rotation amount
  79628. */
  79629. setDeltaRotation(rotation: Quaternion): void;
  79630. /**
  79631. * Gets the box size of the physics imposter and stores the result in the input parameter
  79632. * @param result Stores the box size
  79633. * @returns The physics imposter
  79634. */
  79635. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  79636. /**
  79637. * Gets the radius of the physics imposter
  79638. * @returns Radius of the physics imposter
  79639. */
  79640. getRadius(): number;
  79641. /**
  79642. * Sync a bone with this impostor
  79643. * @param bone The bone to sync to the impostor.
  79644. * @param boneMesh The mesh that the bone is influencing.
  79645. * @param jointPivot The pivot of the joint / bone in local space.
  79646. * @param distToJoint Optional distance from the impostor to the joint.
  79647. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79648. */
  79649. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  79650. /**
  79651. * Sync impostor to a bone
  79652. * @param bone The bone that the impostor will be synced to.
  79653. * @param boneMesh The mesh that the bone is influencing.
  79654. * @param jointPivot The pivot of the joint / bone in local space.
  79655. * @param distToJoint Optional distance from the impostor to the joint.
  79656. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79657. * @param boneAxis Optional vector3 axis the bone is aligned with
  79658. */
  79659. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  79660. /**
  79661. * No-Imposter type
  79662. */
  79663. static NoImpostor: number;
  79664. /**
  79665. * Sphere-Imposter type
  79666. */
  79667. static SphereImpostor: number;
  79668. /**
  79669. * Box-Imposter type
  79670. */
  79671. static BoxImpostor: number;
  79672. /**
  79673. * Plane-Imposter type
  79674. */
  79675. static PlaneImpostor: number;
  79676. /**
  79677. * Mesh-imposter type
  79678. */
  79679. static MeshImpostor: number;
  79680. /**
  79681. * Cylinder-Imposter type
  79682. */
  79683. static CylinderImpostor: number;
  79684. /**
  79685. * Particle-Imposter type
  79686. */
  79687. static ParticleImpostor: number;
  79688. /**
  79689. * Heightmap-Imposter type
  79690. */
  79691. static HeightmapImpostor: number;
  79692. /**
  79693. * ConvexHull-Impostor type (Ammo.js plugin only)
  79694. */
  79695. static ConvexHullImpostor: number;
  79696. /**
  79697. * Rope-Imposter type
  79698. */
  79699. static RopeImpostor: number;
  79700. /**
  79701. * Cloth-Imposter type
  79702. */
  79703. static ClothImpostor: number;
  79704. /**
  79705. * Softbody-Imposter type
  79706. */
  79707. static SoftbodyImpostor: number;
  79708. }
  79709. }
  79710. declare module BABYLON {
  79711. /**
  79712. * Class used to represent a specific level of detail of a mesh
  79713. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79714. */
  79715. export class MeshLODLevel {
  79716. /** Defines the distance where this level should star being displayed */
  79717. distance: number;
  79718. /** Defines the mesh to use to render this level */
  79719. mesh: Nullable<Mesh>;
  79720. /**
  79721. * Creates a new LOD level
  79722. * @param distance defines the distance where this level should star being displayed
  79723. * @param mesh defines the mesh to use to render this level
  79724. */
  79725. constructor(
  79726. /** Defines the distance where this level should star being displayed */
  79727. distance: number,
  79728. /** Defines the mesh to use to render this level */
  79729. mesh: Nullable<Mesh>);
  79730. }
  79731. /**
  79732. * @hidden
  79733. **/
  79734. export class _CreationDataStorage {
  79735. closePath?: boolean;
  79736. closeArray?: boolean;
  79737. idx: number[];
  79738. dashSize: number;
  79739. gapSize: number;
  79740. path3D: Path3D;
  79741. pathArray: Vector3[][];
  79742. arc: number;
  79743. radius: number;
  79744. cap: number;
  79745. tessellation: number;
  79746. }
  79747. /**
  79748. * @hidden
  79749. **/
  79750. class _InstanceDataStorage {
  79751. visibleInstances: any;
  79752. renderIdForInstances: number[];
  79753. batchCache: _InstancesBatch;
  79754. instancesBufferSize: number;
  79755. instancesBuffer: Nullable<Buffer>;
  79756. instancesData: Float32Array;
  79757. overridenInstanceCount: number;
  79758. }
  79759. /**
  79760. * @hidden
  79761. **/
  79762. export class _InstancesBatch {
  79763. mustReturn: boolean;
  79764. visibleInstances: Nullable<InstancedMesh[]>[];
  79765. renderSelf: boolean[];
  79766. }
  79767. /**
  79768. * Class used to represent renderable models
  79769. */
  79770. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  79771. /**
  79772. * Mesh side orientation : usually the external or front surface
  79773. */
  79774. static readonly FRONTSIDE: number;
  79775. /**
  79776. * Mesh side orientation : usually the internal or back surface
  79777. */
  79778. static readonly BACKSIDE: number;
  79779. /**
  79780. * Mesh side orientation : both internal and external or front and back surfaces
  79781. */
  79782. static readonly DOUBLESIDE: number;
  79783. /**
  79784. * Mesh side orientation : by default, `FRONTSIDE`
  79785. */
  79786. static readonly DEFAULTSIDE: number;
  79787. /**
  79788. * Mesh cap setting : no cap
  79789. */
  79790. static readonly NO_CAP: number;
  79791. /**
  79792. * Mesh cap setting : one cap at the beginning of the mesh
  79793. */
  79794. static readonly CAP_START: number;
  79795. /**
  79796. * Mesh cap setting : one cap at the end of the mesh
  79797. */
  79798. static readonly CAP_END: number;
  79799. /**
  79800. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  79801. */
  79802. static readonly CAP_ALL: number;
  79803. /**
  79804. * Gets the default side orientation.
  79805. * @param orientation the orientation to value to attempt to get
  79806. * @returns the default orientation
  79807. * @hidden
  79808. */
  79809. static _GetDefaultSideOrientation(orientation?: number): number;
  79810. private _onBeforeRenderObservable;
  79811. private _onBeforeBindObservable;
  79812. private _onAfterRenderObservable;
  79813. private _onBeforeDrawObservable;
  79814. /**
  79815. * An event triggered before rendering the mesh
  79816. */
  79817. readonly onBeforeRenderObservable: Observable<Mesh>;
  79818. /**
  79819. * An event triggered before binding the mesh
  79820. */
  79821. readonly onBeforeBindObservable: Observable<Mesh>;
  79822. /**
  79823. * An event triggered after rendering the mesh
  79824. */
  79825. readonly onAfterRenderObservable: Observable<Mesh>;
  79826. /**
  79827. * An event triggered before drawing the mesh
  79828. */
  79829. readonly onBeforeDrawObservable: Observable<Mesh>;
  79830. private _onBeforeDrawObserver;
  79831. /**
  79832. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  79833. */
  79834. onBeforeDraw: () => void;
  79835. /**
  79836. * Gets the delay loading state of the mesh (when delay loading is turned on)
  79837. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  79838. */
  79839. delayLoadState: number;
  79840. /**
  79841. * Gets the list of instances created from this mesh
  79842. * it is not supposed to be modified manually.
  79843. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  79844. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79845. */
  79846. instances: InstancedMesh[];
  79847. /**
  79848. * Gets the file containing delay loading data for this mesh
  79849. */
  79850. delayLoadingFile: string;
  79851. /** @hidden */
  79852. _binaryInfo: any;
  79853. private _LODLevels;
  79854. /**
  79855. * User defined function used to change how LOD level selection is done
  79856. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79857. */
  79858. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  79859. private _morphTargetManager;
  79860. /**
  79861. * Gets or sets the morph target manager
  79862. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79863. */
  79864. morphTargetManager: Nullable<MorphTargetManager>;
  79865. /** @hidden */
  79866. _creationDataStorage: Nullable<_CreationDataStorage>;
  79867. /** @hidden */
  79868. _geometry: Nullable<Geometry>;
  79869. /** @hidden */
  79870. _delayInfo: Array<string>;
  79871. /** @hidden */
  79872. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  79873. /** @hidden */
  79874. _instanceDataStorage: _InstanceDataStorage;
  79875. private _effectiveMaterial;
  79876. /** @hidden */
  79877. _shouldGenerateFlatShading: boolean;
  79878. private _preActivateId;
  79879. /** @hidden */
  79880. _originalBuilderSideOrientation: number;
  79881. /**
  79882. * Use this property to change the original side orientation defined at construction time
  79883. */
  79884. overrideMaterialSideOrientation: Nullable<number>;
  79885. private _areNormalsFrozen;
  79886. private _sourcePositions;
  79887. private _sourceNormals;
  79888. private _source;
  79889. private meshMap;
  79890. /**
  79891. * Gets the source mesh (the one used to clone this one from)
  79892. */
  79893. readonly source: Nullable<Mesh>;
  79894. /**
  79895. * Gets or sets a boolean indicating that this mesh does not use index buffer
  79896. */
  79897. isUnIndexed: boolean;
  79898. /**
  79899. * @constructor
  79900. * @param name The value used by scene.getMeshByName() to do a lookup.
  79901. * @param scene The scene to add this mesh to.
  79902. * @param parent The parent of this mesh, if it has one
  79903. * @param source An optional Mesh from which geometry is shared, cloned.
  79904. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79905. * When false, achieved by calling a clone(), also passing False.
  79906. * This will make creation of children, recursive.
  79907. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  79908. */
  79909. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  79910. /**
  79911. * Gets the class name
  79912. * @returns the string "Mesh".
  79913. */
  79914. getClassName(): string;
  79915. /** @hidden */
  79916. readonly _isMesh: boolean;
  79917. /**
  79918. * Returns a description of this mesh
  79919. * @param fullDetails define if full details about this mesh must be used
  79920. * @returns a descriptive string representing this mesh
  79921. */
  79922. toString(fullDetails?: boolean): string;
  79923. /** @hidden */
  79924. _unBindEffect(): void;
  79925. /**
  79926. * Gets a boolean indicating if this mesh has LOD
  79927. */
  79928. readonly hasLODLevels: boolean;
  79929. /**
  79930. * Gets the list of MeshLODLevel associated with the current mesh
  79931. * @returns an array of MeshLODLevel
  79932. */
  79933. getLODLevels(): MeshLODLevel[];
  79934. private _sortLODLevels;
  79935. /**
  79936. * Add a mesh as LOD level triggered at the given distance.
  79937. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79938. * @param distance The distance from the center of the object to show this level
  79939. * @param mesh The mesh to be added as LOD level (can be null)
  79940. * @return This mesh (for chaining)
  79941. */
  79942. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  79943. /**
  79944. * Returns the LOD level mesh at the passed distance or null if not found.
  79945. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79946. * @param distance The distance from the center of the object to show this level
  79947. * @returns a Mesh or `null`
  79948. */
  79949. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  79950. /**
  79951. * Remove a mesh from the LOD array
  79952. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79953. * @param mesh defines the mesh to be removed
  79954. * @return This mesh (for chaining)
  79955. */
  79956. removeLODLevel(mesh: Mesh): Mesh;
  79957. /**
  79958. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  79959. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  79960. * @param camera defines the camera to use to compute distance
  79961. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  79962. * @return This mesh (for chaining)
  79963. */
  79964. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  79965. /**
  79966. * Gets the mesh internal Geometry object
  79967. */
  79968. readonly geometry: Nullable<Geometry>;
  79969. /**
  79970. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  79971. * @returns the total number of vertices
  79972. */
  79973. getTotalVertices(): number;
  79974. /**
  79975. * Returns the content of an associated vertex buffer
  79976. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79977. * - VertexBuffer.PositionKind
  79978. * - VertexBuffer.UVKind
  79979. * - VertexBuffer.UV2Kind
  79980. * - VertexBuffer.UV3Kind
  79981. * - VertexBuffer.UV4Kind
  79982. * - VertexBuffer.UV5Kind
  79983. * - VertexBuffer.UV6Kind
  79984. * - VertexBuffer.ColorKind
  79985. * - VertexBuffer.MatricesIndicesKind
  79986. * - VertexBuffer.MatricesIndicesExtraKind
  79987. * - VertexBuffer.MatricesWeightsKind
  79988. * - VertexBuffer.MatricesWeightsExtraKind
  79989. * @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
  79990. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  79991. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  79992. */
  79993. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79994. /**
  79995. * Returns the mesh VertexBuffer object from the requested `kind`
  79996. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79997. * - VertexBuffer.PositionKind
  79998. * - VertexBuffer.UVKind
  79999. * - VertexBuffer.UV2Kind
  80000. * - VertexBuffer.UV3Kind
  80001. * - VertexBuffer.UV4Kind
  80002. * - VertexBuffer.UV5Kind
  80003. * - VertexBuffer.UV6Kind
  80004. * - VertexBuffer.ColorKind
  80005. * - VertexBuffer.MatricesIndicesKind
  80006. * - VertexBuffer.MatricesIndicesExtraKind
  80007. * - VertexBuffer.MatricesWeightsKind
  80008. * - VertexBuffer.MatricesWeightsExtraKind
  80009. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  80010. */
  80011. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80012. /**
  80013. * Tests if a specific vertex buffer is associated with this mesh
  80014. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80015. * - VertexBuffer.PositionKind
  80016. * - VertexBuffer.UVKind
  80017. * - VertexBuffer.UV2Kind
  80018. * - VertexBuffer.UV3Kind
  80019. * - VertexBuffer.UV4Kind
  80020. * - VertexBuffer.UV5Kind
  80021. * - VertexBuffer.UV6Kind
  80022. * - VertexBuffer.ColorKind
  80023. * - VertexBuffer.MatricesIndicesKind
  80024. * - VertexBuffer.MatricesIndicesExtraKind
  80025. * - VertexBuffer.MatricesWeightsKind
  80026. * - VertexBuffer.MatricesWeightsExtraKind
  80027. * @returns a boolean
  80028. */
  80029. isVerticesDataPresent(kind: string): boolean;
  80030. /**
  80031. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  80032. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80033. * - VertexBuffer.PositionKind
  80034. * - VertexBuffer.UVKind
  80035. * - VertexBuffer.UV2Kind
  80036. * - VertexBuffer.UV3Kind
  80037. * - VertexBuffer.UV4Kind
  80038. * - VertexBuffer.UV5Kind
  80039. * - VertexBuffer.UV6Kind
  80040. * - VertexBuffer.ColorKind
  80041. * - VertexBuffer.MatricesIndicesKind
  80042. * - VertexBuffer.MatricesIndicesExtraKind
  80043. * - VertexBuffer.MatricesWeightsKind
  80044. * - VertexBuffer.MatricesWeightsExtraKind
  80045. * @returns a boolean
  80046. */
  80047. isVertexBufferUpdatable(kind: string): boolean;
  80048. /**
  80049. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  80050. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80051. * - VertexBuffer.PositionKind
  80052. * - VertexBuffer.UVKind
  80053. * - VertexBuffer.UV2Kind
  80054. * - VertexBuffer.UV3Kind
  80055. * - VertexBuffer.UV4Kind
  80056. * - VertexBuffer.UV5Kind
  80057. * - VertexBuffer.UV6Kind
  80058. * - VertexBuffer.ColorKind
  80059. * - VertexBuffer.MatricesIndicesKind
  80060. * - VertexBuffer.MatricesIndicesExtraKind
  80061. * - VertexBuffer.MatricesWeightsKind
  80062. * - VertexBuffer.MatricesWeightsExtraKind
  80063. * @returns an array of strings
  80064. */
  80065. getVerticesDataKinds(): string[];
  80066. /**
  80067. * Returns a positive integer : the total number of indices in this mesh geometry.
  80068. * @returns the numner of indices or zero if the mesh has no geometry.
  80069. */
  80070. getTotalIndices(): number;
  80071. /**
  80072. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80073. * @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.
  80074. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80075. * @returns the indices array or an empty array if the mesh has no geometry
  80076. */
  80077. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80078. readonly isBlocked: boolean;
  80079. /**
  80080. * Determine if the current mesh is ready to be rendered
  80081. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80082. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  80083. * @returns true if all associated assets are ready (material, textures, shaders)
  80084. */
  80085. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  80086. /**
  80087. * 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.
  80088. */
  80089. readonly areNormalsFrozen: boolean;
  80090. /**
  80091. * 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.
  80092. * @returns the current mesh
  80093. */
  80094. freezeNormals(): Mesh;
  80095. /**
  80096. * 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
  80097. * @returns the current mesh
  80098. */
  80099. unfreezeNormals(): Mesh;
  80100. /**
  80101. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  80102. */
  80103. overridenInstanceCount: number;
  80104. /** @hidden */
  80105. _preActivate(): Mesh;
  80106. /** @hidden */
  80107. _preActivateForIntermediateRendering(renderId: number): Mesh;
  80108. /** @hidden */
  80109. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  80110. /**
  80111. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80112. * This means the mesh underlying bounding box and sphere are recomputed.
  80113. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80114. * @returns the current mesh
  80115. */
  80116. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  80117. /** @hidden */
  80118. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  80119. /**
  80120. * This function will subdivide the mesh into multiple submeshes
  80121. * @param count defines the expected number of submeshes
  80122. */
  80123. subdivide(count: number): void;
  80124. /**
  80125. * Copy a FloatArray into a specific associated vertex buffer
  80126. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80127. * - VertexBuffer.PositionKind
  80128. * - VertexBuffer.UVKind
  80129. * - VertexBuffer.UV2Kind
  80130. * - VertexBuffer.UV3Kind
  80131. * - VertexBuffer.UV4Kind
  80132. * - VertexBuffer.UV5Kind
  80133. * - VertexBuffer.UV6Kind
  80134. * - VertexBuffer.ColorKind
  80135. * - VertexBuffer.MatricesIndicesKind
  80136. * - VertexBuffer.MatricesIndicesExtraKind
  80137. * - VertexBuffer.MatricesWeightsKind
  80138. * - VertexBuffer.MatricesWeightsExtraKind
  80139. * @param data defines the data source
  80140. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80141. * @param stride defines the data stride size (can be null)
  80142. * @returns the current mesh
  80143. */
  80144. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  80145. /**
  80146. * Flags an associated vertex buffer as updatable
  80147. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  80148. * - VertexBuffer.PositionKind
  80149. * - VertexBuffer.UVKind
  80150. * - VertexBuffer.UV2Kind
  80151. * - VertexBuffer.UV3Kind
  80152. * - VertexBuffer.UV4Kind
  80153. * - VertexBuffer.UV5Kind
  80154. * - VertexBuffer.UV6Kind
  80155. * - VertexBuffer.ColorKind
  80156. * - VertexBuffer.MatricesIndicesKind
  80157. * - VertexBuffer.MatricesIndicesExtraKind
  80158. * - VertexBuffer.MatricesWeightsKind
  80159. * - VertexBuffer.MatricesWeightsExtraKind
  80160. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80161. */
  80162. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  80163. /**
  80164. * Sets the mesh global Vertex Buffer
  80165. * @param buffer defines the buffer to use
  80166. * @returns the current mesh
  80167. */
  80168. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  80169. /**
  80170. * Update a specific associated vertex buffer
  80171. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80172. * - VertexBuffer.PositionKind
  80173. * - VertexBuffer.UVKind
  80174. * - VertexBuffer.UV2Kind
  80175. * - VertexBuffer.UV3Kind
  80176. * - VertexBuffer.UV4Kind
  80177. * - VertexBuffer.UV5Kind
  80178. * - VertexBuffer.UV6Kind
  80179. * - VertexBuffer.ColorKind
  80180. * - VertexBuffer.MatricesIndicesKind
  80181. * - VertexBuffer.MatricesIndicesExtraKind
  80182. * - VertexBuffer.MatricesWeightsKind
  80183. * - VertexBuffer.MatricesWeightsExtraKind
  80184. * @param data defines the data source
  80185. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80186. * @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)
  80187. * @returns the current mesh
  80188. */
  80189. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  80190. /**
  80191. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  80192. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  80193. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  80194. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  80195. * @returns the current mesh
  80196. */
  80197. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  80198. /**
  80199. * Creates a un-shared specific occurence of the geometry for the mesh.
  80200. * @returns the current mesh
  80201. */
  80202. makeGeometryUnique(): Mesh;
  80203. /**
  80204. * Set the index buffer of this mesh
  80205. * @param indices defines the source data
  80206. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  80207. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  80208. * @returns the current mesh
  80209. */
  80210. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  80211. /**
  80212. * Update the current index buffer
  80213. * @param indices defines the source data
  80214. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  80215. * @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)
  80216. * @returns the current mesh
  80217. */
  80218. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  80219. /**
  80220. * Invert the geometry to move from a right handed system to a left handed one.
  80221. * @returns the current mesh
  80222. */
  80223. toLeftHanded(): Mesh;
  80224. /** @hidden */
  80225. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  80226. /** @hidden */
  80227. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  80228. /**
  80229. * Registers for this mesh a javascript function called just before the rendering process
  80230. * @param func defines the function to call before rendering this mesh
  80231. * @returns the current mesh
  80232. */
  80233. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80234. /**
  80235. * Disposes a previously registered javascript function called before the rendering
  80236. * @param func defines the function to remove
  80237. * @returns the current mesh
  80238. */
  80239. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80240. /**
  80241. * Registers for this mesh a javascript function called just after the rendering is complete
  80242. * @param func defines the function to call after rendering this mesh
  80243. * @returns the current mesh
  80244. */
  80245. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80246. /**
  80247. * Disposes a previously registered javascript function called after the rendering.
  80248. * @param func defines the function to remove
  80249. * @returns the current mesh
  80250. */
  80251. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80252. /** @hidden */
  80253. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  80254. /** @hidden */
  80255. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  80256. /** @hidden */
  80257. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  80258. /**
  80259. * 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
  80260. * @param subMesh defines the subMesh to render
  80261. * @param enableAlphaMode defines if alpha mode can be changed
  80262. * @returns the current mesh
  80263. */
  80264. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  80265. private _onBeforeDraw;
  80266. /**
  80267. * Renormalize the mesh and patch it up if there are no weights
  80268. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  80269. * However in the case of zero weights then we set just a single influence to 1.
  80270. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  80271. */
  80272. cleanMatrixWeights(): void;
  80273. private normalizeSkinFourWeights;
  80274. private normalizeSkinWeightsAndExtra;
  80275. /**
  80276. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  80277. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  80278. * the user know there was an issue with importing the mesh
  80279. * @returns a validation object with skinned, valid and report string
  80280. */
  80281. validateSkinning(): {
  80282. skinned: boolean;
  80283. valid: boolean;
  80284. report: string;
  80285. };
  80286. /** @hidden */
  80287. _checkDelayState(): Mesh;
  80288. private _queueLoad;
  80289. /**
  80290. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80291. * A mesh is in the frustum if its bounding box intersects the frustum
  80292. * @param frustumPlanes defines the frustum to test
  80293. * @returns true if the mesh is in the frustum planes
  80294. */
  80295. isInFrustum(frustumPlanes: Plane[]): boolean;
  80296. /**
  80297. * Sets the mesh material by the material or multiMaterial `id` property
  80298. * @param id is a string identifying the material or the multiMaterial
  80299. * @returns the current mesh
  80300. */
  80301. setMaterialByID(id: string): Mesh;
  80302. /**
  80303. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  80304. * @returns an array of IAnimatable
  80305. */
  80306. getAnimatables(): IAnimatable[];
  80307. /**
  80308. * Modifies the mesh geometry according to the passed transformation matrix.
  80309. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  80310. * The mesh normals are modified using the same transformation.
  80311. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80312. * @param transform defines the transform matrix to use
  80313. * @see http://doc.babylonjs.com/resources/baking_transformations
  80314. * @returns the current mesh
  80315. */
  80316. bakeTransformIntoVertices(transform: Matrix): Mesh;
  80317. /**
  80318. * Modifies the mesh geometry according to its own current World Matrix.
  80319. * The mesh World Matrix is then reset.
  80320. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  80321. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80322. * @see http://doc.babylonjs.com/resources/baking_transformations
  80323. * @returns the current mesh
  80324. */
  80325. bakeCurrentTransformIntoVertices(): Mesh;
  80326. /** @hidden */
  80327. readonly _positions: Nullable<Vector3[]>;
  80328. /** @hidden */
  80329. _resetPointsArrayCache(): Mesh;
  80330. /** @hidden */
  80331. _generatePointsArray(): boolean;
  80332. /**
  80333. * Returns a new Mesh object generated from the current mesh properties.
  80334. * This method must not get confused with createInstance()
  80335. * @param name is a string, the name given to the new mesh
  80336. * @param newParent can be any Node object (default `null`)
  80337. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  80338. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  80339. * @returns a new mesh
  80340. */
  80341. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  80342. /**
  80343. * Releases resources associated with this mesh.
  80344. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80345. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80346. */
  80347. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80348. /**
  80349. * Modifies the mesh geometry according to a displacement map.
  80350. * 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.
  80351. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80352. * @param url is a string, the URL from the image file is to be downloaded.
  80353. * @param minHeight is the lower limit of the displacement.
  80354. * @param maxHeight is the upper limit of the displacement.
  80355. * @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.
  80356. * @param uvOffset is an optional vector2 used to offset UV.
  80357. * @param uvScale is an optional vector2 used to scale UV.
  80358. * @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.
  80359. * @returns the Mesh.
  80360. */
  80361. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80362. /**
  80363. * Modifies the mesh geometry according to a displacementMap buffer.
  80364. * 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.
  80365. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80366. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  80367. * @param heightMapWidth is the width of the buffer image.
  80368. * @param heightMapHeight is the height of the buffer image.
  80369. * @param minHeight is the lower limit of the displacement.
  80370. * @param maxHeight is the upper limit of the displacement.
  80371. * @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.
  80372. * @param uvOffset is an optional vector2 used to offset UV.
  80373. * @param uvScale is an optional vector2 used to scale UV.
  80374. * @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.
  80375. * @returns the Mesh.
  80376. */
  80377. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80378. /**
  80379. * Modify the mesh to get a flat shading rendering.
  80380. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  80381. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  80382. * @returns current mesh
  80383. */
  80384. convertToFlatShadedMesh(): Mesh;
  80385. /**
  80386. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  80387. * In other words, more vertices, no more indices and a single bigger VBO.
  80388. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  80389. * @returns current mesh
  80390. */
  80391. convertToUnIndexedMesh(): Mesh;
  80392. /**
  80393. * Inverses facet orientations.
  80394. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80395. * @param flipNormals will also inverts the normals
  80396. * @returns current mesh
  80397. */
  80398. flipFaces(flipNormals?: boolean): Mesh;
  80399. /**
  80400. * Increase the number of facets and hence vertices in a mesh
  80401. * Vertex normals are interpolated from existing vertex normals
  80402. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80403. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  80404. */
  80405. increaseVertices(numberPerEdge: number): void;
  80406. /**
  80407. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  80408. * This will undo any application of covertToFlatShadedMesh
  80409. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80410. */
  80411. forceSharedVertices(): void;
  80412. /** @hidden */
  80413. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  80414. /** @hidden */
  80415. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  80416. /**
  80417. * Creates a new InstancedMesh object from the mesh model.
  80418. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80419. * @param name defines the name of the new instance
  80420. * @returns a new InstancedMesh
  80421. */
  80422. createInstance(name: string): InstancedMesh;
  80423. /**
  80424. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  80425. * After this call, all the mesh instances have the same submeshes than the current mesh.
  80426. * @returns the current mesh
  80427. */
  80428. synchronizeInstances(): Mesh;
  80429. /**
  80430. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  80431. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  80432. * This should be used together with the simplification to avoid disappearing triangles.
  80433. * @param successCallback an optional success callback to be called after the optimization finished.
  80434. * @returns the current mesh
  80435. */
  80436. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  80437. /**
  80438. * Serialize current mesh
  80439. * @param serializationObject defines the object which will receive the serialization data
  80440. */
  80441. serialize(serializationObject: any): void;
  80442. /** @hidden */
  80443. _syncGeometryWithMorphTargetManager(): void;
  80444. /** @hidden */
  80445. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  80446. /**
  80447. * Returns a new Mesh object parsed from the source provided.
  80448. * @param parsedMesh is the source
  80449. * @param scene defines the hosting scene
  80450. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  80451. * @returns a new Mesh
  80452. */
  80453. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  80454. /**
  80455. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  80456. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80457. * @param name defines the name of the mesh to create
  80458. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  80459. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  80460. * @param closePath creates a seam between the first and the last points of each path of the path array
  80461. * @param offset is taken in account only if the `pathArray` is containing a single path
  80462. * @param scene defines the hosting scene
  80463. * @param updatable defines if the mesh must be flagged as updatable
  80464. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80465. * @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)
  80466. * @returns a new Mesh
  80467. */
  80468. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80469. /**
  80470. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  80471. * @param name defines the name of the mesh to create
  80472. * @param radius sets the radius size (float) of the polygon (default 0.5)
  80473. * @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
  80474. * @param scene defines the hosting scene
  80475. * @param updatable defines if the mesh must be flagged as updatable
  80476. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80477. * @returns a new Mesh
  80478. */
  80479. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80480. /**
  80481. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  80482. * @param name defines the name of the mesh to create
  80483. * @param size sets the size (float) of each box side (default 1)
  80484. * @param scene defines the hosting scene
  80485. * @param updatable defines if the mesh must be flagged as updatable
  80486. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80487. * @returns a new Mesh
  80488. */
  80489. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80490. /**
  80491. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  80492. * @param name defines the name of the mesh to create
  80493. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80494. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80495. * @param scene defines the hosting scene
  80496. * @param updatable defines if the mesh must be flagged as updatable
  80497. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80498. * @returns a new Mesh
  80499. */
  80500. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80501. /**
  80502. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  80503. * @param name defines the name of the mesh to create
  80504. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80505. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80506. * @param scene defines the hosting scene
  80507. * @returns a new Mesh
  80508. */
  80509. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  80510. /**
  80511. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  80512. * @param name defines the name of the mesh to create
  80513. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  80514. * @param diameterTop set the top cap diameter (floats, default 1)
  80515. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  80516. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  80517. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  80518. * @param scene defines the hosting scene
  80519. * @param updatable defines if the mesh must be flagged as updatable
  80520. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80521. * @returns a new Mesh
  80522. */
  80523. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  80524. /**
  80525. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  80526. * @param name defines the name of the mesh to create
  80527. * @param diameter sets the diameter size (float) of the torus (default 1)
  80528. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  80529. * @param tessellation sets the number of torus sides (postive integer, default 16)
  80530. * @param scene defines the hosting scene
  80531. * @param updatable defines if the mesh must be flagged as updatable
  80532. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80533. * @returns a new Mesh
  80534. */
  80535. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80536. /**
  80537. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  80538. * @param name defines the name of the mesh to create
  80539. * @param radius sets the global radius size (float) of the torus knot (default 2)
  80540. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  80541. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  80542. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  80543. * @param p the number of windings on X axis (positive integers, default 2)
  80544. * @param q the number of windings on Y axis (positive integers, default 3)
  80545. * @param scene defines the hosting scene
  80546. * @param updatable defines if the mesh must be flagged as updatable
  80547. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80548. * @returns a new Mesh
  80549. */
  80550. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80551. /**
  80552. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  80553. * @param name defines the name of the mesh to create
  80554. * @param points is an array successive Vector3
  80555. * @param scene defines the hosting scene
  80556. * @param updatable defines if the mesh must be flagged as updatable
  80557. * @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).
  80558. * @returns a new Mesh
  80559. */
  80560. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  80561. /**
  80562. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  80563. * @param name defines the name of the mesh to create
  80564. * @param points is an array successive Vector3
  80565. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  80566. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  80567. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  80568. * @param scene defines the hosting scene
  80569. * @param updatable defines if the mesh must be flagged as updatable
  80570. * @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)
  80571. * @returns a new Mesh
  80572. */
  80573. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  80574. /**
  80575. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  80576. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  80577. * 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.
  80578. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80579. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80580. * Remember you can only change the shape positions, not their number when updating a polygon.
  80581. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  80582. * @param name defines the name of the mesh to create
  80583. * @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
  80584. * @param scene defines the hosting scene
  80585. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80586. * @param updatable defines if the mesh must be flagged as updatable
  80587. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80588. * @param earcutInjection can be used to inject your own earcut reference
  80589. * @returns a new Mesh
  80590. */
  80591. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80592. /**
  80593. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  80594. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  80595. * @param name defines the name of the mesh to create
  80596. * @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
  80597. * @param depth defines the height of extrusion
  80598. * @param scene defines the hosting scene
  80599. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80600. * @param updatable defines if the mesh must be flagged as updatable
  80601. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80602. * @param earcutInjection can be used to inject your own earcut reference
  80603. * @returns a new Mesh
  80604. */
  80605. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80606. /**
  80607. * Creates an extruded shape mesh.
  80608. * 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
  80609. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80610. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80611. * @param name defines the name of the mesh to create
  80612. * @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
  80613. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80614. * @param scale is the value to scale the shape
  80615. * @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
  80616. * @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
  80617. * @param scene defines the hosting scene
  80618. * @param updatable defines if the mesh must be flagged as updatable
  80619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80620. * @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)
  80621. * @returns a new Mesh
  80622. */
  80623. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80624. /**
  80625. * Creates an custom extruded shape mesh.
  80626. * The custom extrusion is a parametric shape.
  80627. * It has no predefined shape. Its final shape will depend on the input parameters.
  80628. * Please consider using the same method from the MeshBuilder class instead
  80629. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80630. * @param name defines the name of the mesh to create
  80631. * @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
  80632. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80633. * @param scaleFunction is a custom Javascript function called on each path point
  80634. * @param rotationFunction is a custom Javascript function called on each path point
  80635. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  80636. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  80637. * @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
  80638. * @param scene defines the hosting scene
  80639. * @param updatable defines if the mesh must be flagged as updatable
  80640. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80641. * @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)
  80642. * @returns a new Mesh
  80643. */
  80644. 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;
  80645. /**
  80646. * Creates lathe mesh.
  80647. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  80648. * Please consider using the same method from the MeshBuilder class instead
  80649. * @param name defines the name of the mesh to create
  80650. * @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
  80651. * @param radius is the radius value of the lathe
  80652. * @param tessellation is the side number of the lathe.
  80653. * @param scene defines the hosting scene
  80654. * @param updatable defines if the mesh must be flagged as updatable
  80655. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80656. * @returns a new Mesh
  80657. */
  80658. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80659. /**
  80660. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  80661. * @param name defines the name of the mesh to create
  80662. * @param size sets the size (float) of both sides of the plane at once (default 1)
  80663. * @param scene defines the hosting scene
  80664. * @param updatable defines if the mesh must be flagged as updatable
  80665. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80666. * @returns a new Mesh
  80667. */
  80668. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80669. /**
  80670. * Creates a ground mesh.
  80671. * Please consider using the same method from the MeshBuilder class instead
  80672. * @param name defines the name of the mesh to create
  80673. * @param width set the width of the ground
  80674. * @param height set the height of the ground
  80675. * @param subdivisions sets the number of subdivisions per side
  80676. * @param scene defines the hosting scene
  80677. * @param updatable defines if the mesh must be flagged as updatable
  80678. * @returns a new Mesh
  80679. */
  80680. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  80681. /**
  80682. * Creates a tiled ground mesh.
  80683. * Please consider using the same method from the MeshBuilder class instead
  80684. * @param name defines the name of the mesh to create
  80685. * @param xmin set the ground minimum X coordinate
  80686. * @param zmin set the ground minimum Y coordinate
  80687. * @param xmax set the ground maximum X coordinate
  80688. * @param zmax set the ground maximum Z coordinate
  80689. * @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
  80690. * @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
  80691. * @param scene defines the hosting scene
  80692. * @param updatable defines if the mesh must be flagged as updatable
  80693. * @returns a new Mesh
  80694. */
  80695. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  80696. w: number;
  80697. h: number;
  80698. }, precision: {
  80699. w: number;
  80700. h: number;
  80701. }, scene: Scene, updatable?: boolean): Mesh;
  80702. /**
  80703. * Creates a ground mesh from a height map.
  80704. * Please consider using the same method from the MeshBuilder class instead
  80705. * @see http://doc.babylonjs.com/babylon101/height_map
  80706. * @param name defines the name of the mesh to create
  80707. * @param url sets the URL of the height map image resource
  80708. * @param width set the ground width size
  80709. * @param height set the ground height size
  80710. * @param subdivisions sets the number of subdivision per side
  80711. * @param minHeight is the minimum altitude on the ground
  80712. * @param maxHeight is the maximum altitude on the ground
  80713. * @param scene defines the hosting scene
  80714. * @param updatable defines if the mesh must be flagged as updatable
  80715. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  80716. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  80717. * @returns a new Mesh
  80718. */
  80719. 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;
  80720. /**
  80721. * Creates a tube mesh.
  80722. * The tube is a parametric shape.
  80723. * It has no predefined shape. Its final shape will depend on the input parameters.
  80724. * Please consider using the same method from the MeshBuilder class instead
  80725. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80726. * @param name defines the name of the mesh to create
  80727. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  80728. * @param radius sets the tube radius size
  80729. * @param tessellation is the number of sides on the tubular surface
  80730. * @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
  80731. * @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
  80732. * @param scene defines the hosting scene
  80733. * @param updatable defines if the mesh must be flagged as updatable
  80734. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80735. * @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)
  80736. * @returns a new Mesh
  80737. */
  80738. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  80739. (i: number, distance: number): number;
  80740. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80741. /**
  80742. * Creates a polyhedron mesh.
  80743. * Please consider using the same method from the MeshBuilder class instead.
  80744. * * 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
  80745. * * The parameter `size` (positive float, default 1) sets the polygon size
  80746. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  80747. * * 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`
  80748. * * 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
  80749. * * 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)`)
  80750. * * 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
  80751. * * 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
  80752. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80753. * * If you create a double-sided mesh, you can choose what parts of 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
  80754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80755. * @param name defines the name of the mesh to create
  80756. * @param options defines the options used to create the mesh
  80757. * @param scene defines the hosting scene
  80758. * @returns a new Mesh
  80759. */
  80760. static CreatePolyhedron(name: string, options: {
  80761. type?: number;
  80762. size?: number;
  80763. sizeX?: number;
  80764. sizeY?: number;
  80765. sizeZ?: number;
  80766. custom?: any;
  80767. faceUV?: Vector4[];
  80768. faceColors?: Color4[];
  80769. updatable?: boolean;
  80770. sideOrientation?: number;
  80771. }, scene: Scene): Mesh;
  80772. /**
  80773. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  80774. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  80775. * * 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`)
  80776. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  80777. * * 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
  80778. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80779. * * If you create a double-sided mesh, you can choose what parts of 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
  80780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80781. * @param name defines the name of the mesh
  80782. * @param options defines the options used to create the mesh
  80783. * @param scene defines the hosting scene
  80784. * @returns a new Mesh
  80785. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  80786. */
  80787. static CreateIcoSphere(name: string, options: {
  80788. radius?: number;
  80789. flat?: boolean;
  80790. subdivisions?: number;
  80791. sideOrientation?: number;
  80792. updatable?: boolean;
  80793. }, scene: Scene): Mesh;
  80794. /**
  80795. * Creates a decal mesh.
  80796. * Please consider using the same method from the MeshBuilder class instead.
  80797. * A decal is a mesh usually applied as a model onto the surface of another mesh
  80798. * @param name defines the name of the mesh
  80799. * @param sourceMesh defines the mesh receiving the decal
  80800. * @param position sets the position of the decal in world coordinates
  80801. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  80802. * @param size sets the decal scaling
  80803. * @param angle sets the angle to rotate the decal
  80804. * @returns a new Mesh
  80805. */
  80806. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  80807. /**
  80808. * Prepare internal position array for software CPU skinning
  80809. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  80810. */
  80811. setPositionsForCPUSkinning(): Float32Array;
  80812. /**
  80813. * Prepare internal normal array for software CPU skinning
  80814. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  80815. */
  80816. setNormalsForCPUSkinning(): Float32Array;
  80817. /**
  80818. * Updates the vertex buffer by applying transformation from the bones
  80819. * @param skeleton defines the skeleton to apply to current mesh
  80820. * @returns the current mesh
  80821. */
  80822. applySkeleton(skeleton: Skeleton): Mesh;
  80823. /**
  80824. * 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
  80825. * @param meshes defines the list of meshes to scan
  80826. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  80827. */
  80828. static MinMax(meshes: AbstractMesh[]): {
  80829. min: Vector3;
  80830. max: Vector3;
  80831. };
  80832. /**
  80833. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  80834. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  80835. * @returns a vector3
  80836. */
  80837. static Center(meshesOrMinMaxVector: {
  80838. min: Vector3;
  80839. max: Vector3;
  80840. } | AbstractMesh[]): Vector3;
  80841. /**
  80842. * Merge the array of meshes into a single mesh for performance reasons.
  80843. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  80844. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  80845. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  80846. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  80847. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  80848. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  80849. * @returns a new mesh
  80850. */
  80851. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  80852. /** @hidden */
  80853. addInstance(instance: InstancedMesh): void;
  80854. /** @hidden */
  80855. removeInstance(instance: InstancedMesh): void;
  80856. }
  80857. }
  80858. declare module BABYLON {
  80859. /**
  80860. * Base class for the main features of a material in Babylon.js
  80861. */
  80862. export class Material implements IAnimatable {
  80863. /**
  80864. * Returns the triangle fill mode
  80865. */
  80866. static readonly TriangleFillMode: number;
  80867. /**
  80868. * Returns the wireframe mode
  80869. */
  80870. static readonly WireFrameFillMode: number;
  80871. /**
  80872. * Returns the point fill mode
  80873. */
  80874. static readonly PointFillMode: number;
  80875. /**
  80876. * Returns the point list draw mode
  80877. */
  80878. static readonly PointListDrawMode: number;
  80879. /**
  80880. * Returns the line list draw mode
  80881. */
  80882. static readonly LineListDrawMode: number;
  80883. /**
  80884. * Returns the line loop draw mode
  80885. */
  80886. static readonly LineLoopDrawMode: number;
  80887. /**
  80888. * Returns the line strip draw mode
  80889. */
  80890. static readonly LineStripDrawMode: number;
  80891. /**
  80892. * Returns the triangle strip draw mode
  80893. */
  80894. static readonly TriangleStripDrawMode: number;
  80895. /**
  80896. * Returns the triangle fan draw mode
  80897. */
  80898. static readonly TriangleFanDrawMode: number;
  80899. /**
  80900. * Stores the clock-wise side orientation
  80901. */
  80902. static readonly ClockWiseSideOrientation: number;
  80903. /**
  80904. * Stores the counter clock-wise side orientation
  80905. */
  80906. static readonly CounterClockWiseSideOrientation: number;
  80907. /**
  80908. * The dirty texture flag value
  80909. */
  80910. static readonly TextureDirtyFlag: number;
  80911. /**
  80912. * The dirty light flag value
  80913. */
  80914. static readonly LightDirtyFlag: number;
  80915. /**
  80916. * The dirty fresnel flag value
  80917. */
  80918. static readonly FresnelDirtyFlag: number;
  80919. /**
  80920. * The dirty attribute flag value
  80921. */
  80922. static readonly AttributesDirtyFlag: number;
  80923. /**
  80924. * The dirty misc flag value
  80925. */
  80926. static readonly MiscDirtyFlag: number;
  80927. /**
  80928. * The all dirty flag value
  80929. */
  80930. static readonly AllDirtyFlag: number;
  80931. /**
  80932. * The ID of the material
  80933. */
  80934. id: string;
  80935. /**
  80936. * Gets or sets the unique id of the material
  80937. */
  80938. uniqueId: number;
  80939. /**
  80940. * The name of the material
  80941. */
  80942. name: string;
  80943. /**
  80944. * Gets or sets user defined metadata
  80945. */
  80946. metadata: any;
  80947. /**
  80948. * For internal use only. Please do not use.
  80949. */
  80950. reservedDataStore: any;
  80951. /**
  80952. * Specifies if the ready state should be checked on each call
  80953. */
  80954. checkReadyOnEveryCall: boolean;
  80955. /**
  80956. * Specifies if the ready state should be checked once
  80957. */
  80958. checkReadyOnlyOnce: boolean;
  80959. /**
  80960. * The state of the material
  80961. */
  80962. state: string;
  80963. /**
  80964. * The alpha value of the material
  80965. */
  80966. protected _alpha: number;
  80967. /**
  80968. * List of inspectable custom properties (used by the Inspector)
  80969. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80970. */
  80971. inspectableCustomProperties: IInspectable[];
  80972. /**
  80973. * Sets the alpha value of the material
  80974. */
  80975. /**
  80976. * Gets the alpha value of the material
  80977. */
  80978. alpha: number;
  80979. /**
  80980. * Specifies if back face culling is enabled
  80981. */
  80982. protected _backFaceCulling: boolean;
  80983. /**
  80984. * Sets the back-face culling state
  80985. */
  80986. /**
  80987. * Gets the back-face culling state
  80988. */
  80989. backFaceCulling: boolean;
  80990. /**
  80991. * Stores the value for side orientation
  80992. */
  80993. sideOrientation: number;
  80994. /**
  80995. * Callback triggered when the material is compiled
  80996. */
  80997. onCompiled: (effect: Effect) => void;
  80998. /**
  80999. * Callback triggered when an error occurs
  81000. */
  81001. onError: (effect: Effect, errors: string) => void;
  81002. /**
  81003. * Callback triggered to get the render target textures
  81004. */
  81005. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  81006. /**
  81007. * Gets a boolean indicating that current material needs to register RTT
  81008. */
  81009. readonly hasRenderTargetTextures: boolean;
  81010. /**
  81011. * Specifies if the material should be serialized
  81012. */
  81013. doNotSerialize: boolean;
  81014. /**
  81015. * @hidden
  81016. */
  81017. _storeEffectOnSubMeshes: boolean;
  81018. /**
  81019. * Stores the animations for the material
  81020. */
  81021. animations: Array<Animation>;
  81022. /**
  81023. * An event triggered when the material is disposed
  81024. */
  81025. onDisposeObservable: Observable<Material>;
  81026. /**
  81027. * An observer which watches for dispose events
  81028. */
  81029. private _onDisposeObserver;
  81030. private _onUnBindObservable;
  81031. /**
  81032. * Called during a dispose event
  81033. */
  81034. onDispose: () => void;
  81035. private _onBindObservable;
  81036. /**
  81037. * An event triggered when the material is bound
  81038. */
  81039. readonly onBindObservable: Observable<AbstractMesh>;
  81040. /**
  81041. * An observer which watches for bind events
  81042. */
  81043. private _onBindObserver;
  81044. /**
  81045. * Called during a bind event
  81046. */
  81047. onBind: (Mesh: AbstractMesh) => void;
  81048. /**
  81049. * An event triggered when the material is unbound
  81050. */
  81051. readonly onUnBindObservable: Observable<Material>;
  81052. /**
  81053. * Stores the value of the alpha mode
  81054. */
  81055. private _alphaMode;
  81056. /**
  81057. * Sets the value of the alpha mode.
  81058. *
  81059. * | Value | Type | Description |
  81060. * | --- | --- | --- |
  81061. * | 0 | ALPHA_DISABLE | |
  81062. * | 1 | ALPHA_ADD | |
  81063. * | 2 | ALPHA_COMBINE | |
  81064. * | 3 | ALPHA_SUBTRACT | |
  81065. * | 4 | ALPHA_MULTIPLY | |
  81066. * | 5 | ALPHA_MAXIMIZED | |
  81067. * | 6 | ALPHA_ONEONE | |
  81068. * | 7 | ALPHA_PREMULTIPLIED | |
  81069. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  81070. * | 9 | ALPHA_INTERPOLATE | |
  81071. * | 10 | ALPHA_SCREENMODE | |
  81072. *
  81073. */
  81074. /**
  81075. * Gets the value of the alpha mode
  81076. */
  81077. alphaMode: number;
  81078. /**
  81079. * Stores the state of the need depth pre-pass value
  81080. */
  81081. private _needDepthPrePass;
  81082. /**
  81083. * Sets the need depth pre-pass value
  81084. */
  81085. /**
  81086. * Gets the depth pre-pass value
  81087. */
  81088. needDepthPrePass: boolean;
  81089. /**
  81090. * Specifies if depth writing should be disabled
  81091. */
  81092. disableDepthWrite: boolean;
  81093. /**
  81094. * Specifies if depth writing should be forced
  81095. */
  81096. forceDepthWrite: boolean;
  81097. /**
  81098. * Specifies if there should be a separate pass for culling
  81099. */
  81100. separateCullingPass: boolean;
  81101. /**
  81102. * Stores the state specifing if fog should be enabled
  81103. */
  81104. private _fogEnabled;
  81105. /**
  81106. * Sets the state for enabling fog
  81107. */
  81108. /**
  81109. * Gets the value of the fog enabled state
  81110. */
  81111. fogEnabled: boolean;
  81112. /**
  81113. * Stores the size of points
  81114. */
  81115. pointSize: number;
  81116. /**
  81117. * Stores the z offset value
  81118. */
  81119. zOffset: number;
  81120. /**
  81121. * Gets a value specifying if wireframe mode is enabled
  81122. */
  81123. /**
  81124. * Sets the state of wireframe mode
  81125. */
  81126. wireframe: boolean;
  81127. /**
  81128. * Gets the value specifying if point clouds are enabled
  81129. */
  81130. /**
  81131. * Sets the state of point cloud mode
  81132. */
  81133. pointsCloud: boolean;
  81134. /**
  81135. * Gets the material fill mode
  81136. */
  81137. /**
  81138. * Sets the material fill mode
  81139. */
  81140. fillMode: number;
  81141. /**
  81142. * @hidden
  81143. * Stores the effects for the material
  81144. */
  81145. _effect: Nullable<Effect>;
  81146. /**
  81147. * @hidden
  81148. * Specifies if the material was previously ready
  81149. */
  81150. _wasPreviouslyReady: boolean;
  81151. /**
  81152. * Specifies if uniform buffers should be used
  81153. */
  81154. private _useUBO;
  81155. /**
  81156. * Stores a reference to the scene
  81157. */
  81158. private _scene;
  81159. /**
  81160. * Stores the fill mode state
  81161. */
  81162. private _fillMode;
  81163. /**
  81164. * Specifies if the depth write state should be cached
  81165. */
  81166. private _cachedDepthWriteState;
  81167. /**
  81168. * Stores the uniform buffer
  81169. */
  81170. protected _uniformBuffer: UniformBuffer;
  81171. /** @hidden */
  81172. _indexInSceneMaterialArray: number;
  81173. /** @hidden */
  81174. meshMap: Nullable<{
  81175. [id: string]: AbstractMesh | undefined;
  81176. }>;
  81177. /**
  81178. * Creates a material instance
  81179. * @param name defines the name of the material
  81180. * @param scene defines the scene to reference
  81181. * @param doNotAdd specifies if the material should be added to the scene
  81182. */
  81183. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  81184. /**
  81185. * Returns a string representation of the current material
  81186. * @param fullDetails defines a boolean indicating which levels of logging is desired
  81187. * @returns a string with material information
  81188. */
  81189. toString(fullDetails?: boolean): string;
  81190. /**
  81191. * Gets the class name of the material
  81192. * @returns a string with the class name of the material
  81193. */
  81194. getClassName(): string;
  81195. /**
  81196. * Specifies if updates for the material been locked
  81197. */
  81198. readonly isFrozen: boolean;
  81199. /**
  81200. * Locks updates for the material
  81201. */
  81202. freeze(): void;
  81203. /**
  81204. * Unlocks updates for the material
  81205. */
  81206. unfreeze(): void;
  81207. /**
  81208. * Specifies if the material is ready to be used
  81209. * @param mesh defines the mesh to check
  81210. * @param useInstances specifies if instances should be used
  81211. * @returns a boolean indicating if the material is ready to be used
  81212. */
  81213. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  81214. /**
  81215. * Specifies that the submesh is ready to be used
  81216. * @param mesh defines the mesh to check
  81217. * @param subMesh defines which submesh to check
  81218. * @param useInstances specifies that instances should be used
  81219. * @returns a boolean indicating that the submesh is ready or not
  81220. */
  81221. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  81222. /**
  81223. * Returns the material effect
  81224. * @returns the effect associated with the material
  81225. */
  81226. getEffect(): Nullable<Effect>;
  81227. /**
  81228. * Returns the current scene
  81229. * @returns a Scene
  81230. */
  81231. getScene(): Scene;
  81232. /**
  81233. * Specifies if the material will require alpha blending
  81234. * @returns a boolean specifying if alpha blending is needed
  81235. */
  81236. needAlphaBlending(): boolean;
  81237. /**
  81238. * Specifies if the mesh will require alpha blending
  81239. * @param mesh defines the mesh to check
  81240. * @returns a boolean specifying if alpha blending is needed for the mesh
  81241. */
  81242. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  81243. /**
  81244. * Specifies if this material should be rendered in alpha test mode
  81245. * @returns a boolean specifying if an alpha test is needed.
  81246. */
  81247. needAlphaTesting(): boolean;
  81248. /**
  81249. * Gets the texture used for the alpha test
  81250. * @returns the texture to use for alpha testing
  81251. */
  81252. getAlphaTestTexture(): Nullable<BaseTexture>;
  81253. /**
  81254. * Marks the material to indicate that it needs to be re-calculated
  81255. */
  81256. markDirty(): void;
  81257. /** @hidden */
  81258. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  81259. /**
  81260. * Binds the material to the mesh
  81261. * @param world defines the world transformation matrix
  81262. * @param mesh defines the mesh to bind the material to
  81263. */
  81264. bind(world: Matrix, mesh?: Mesh): void;
  81265. /**
  81266. * Binds the submesh to the material
  81267. * @param world defines the world transformation matrix
  81268. * @param mesh defines the mesh containing the submesh
  81269. * @param subMesh defines the submesh to bind the material to
  81270. */
  81271. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  81272. /**
  81273. * Binds the world matrix to the material
  81274. * @param world defines the world transformation matrix
  81275. */
  81276. bindOnlyWorldMatrix(world: Matrix): void;
  81277. /**
  81278. * Binds the scene's uniform buffer to the effect.
  81279. * @param effect defines the effect to bind to the scene uniform buffer
  81280. * @param sceneUbo defines the uniform buffer storing scene data
  81281. */
  81282. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  81283. /**
  81284. * Binds the view matrix to the effect
  81285. * @param effect defines the effect to bind the view matrix to
  81286. */
  81287. bindView(effect: Effect): void;
  81288. /**
  81289. * Binds the view projection matrix to the effect
  81290. * @param effect defines the effect to bind the view projection matrix to
  81291. */
  81292. bindViewProjection(effect: Effect): void;
  81293. /**
  81294. * Specifies if material alpha testing should be turned on for the mesh
  81295. * @param mesh defines the mesh to check
  81296. */
  81297. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  81298. /**
  81299. * Processes to execute after binding the material to a mesh
  81300. * @param mesh defines the rendered mesh
  81301. */
  81302. protected _afterBind(mesh?: Mesh): void;
  81303. /**
  81304. * Unbinds the material from the mesh
  81305. */
  81306. unbind(): void;
  81307. /**
  81308. * Gets the active textures from the material
  81309. * @returns an array of textures
  81310. */
  81311. getActiveTextures(): BaseTexture[];
  81312. /**
  81313. * Specifies if the material uses a texture
  81314. * @param texture defines the texture to check against the material
  81315. * @returns a boolean specifying if the material uses the texture
  81316. */
  81317. hasTexture(texture: BaseTexture): boolean;
  81318. /**
  81319. * Makes a duplicate of the material, and gives it a new name
  81320. * @param name defines the new name for the duplicated material
  81321. * @returns the cloned material
  81322. */
  81323. clone(name: string): Nullable<Material>;
  81324. /**
  81325. * Gets the meshes bound to the material
  81326. * @returns an array of meshes bound to the material
  81327. */
  81328. getBindedMeshes(): AbstractMesh[];
  81329. /**
  81330. * Force shader compilation
  81331. * @param mesh defines the mesh associated with this material
  81332. * @param onCompiled defines a function to execute once the material is compiled
  81333. * @param options defines the options to configure the compilation
  81334. */
  81335. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  81336. clipPlane: boolean;
  81337. }>): void;
  81338. /**
  81339. * Force shader compilation
  81340. * @param mesh defines the mesh that will use this material
  81341. * @param options defines additional options for compiling the shaders
  81342. * @returns a promise that resolves when the compilation completes
  81343. */
  81344. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  81345. clipPlane: boolean;
  81346. }>): Promise<void>;
  81347. private static readonly _ImageProcessingDirtyCallBack;
  81348. private static readonly _TextureDirtyCallBack;
  81349. private static readonly _FresnelDirtyCallBack;
  81350. private static readonly _MiscDirtyCallBack;
  81351. private static readonly _LightsDirtyCallBack;
  81352. private static readonly _AttributeDirtyCallBack;
  81353. private static _FresnelAndMiscDirtyCallBack;
  81354. private static _TextureAndMiscDirtyCallBack;
  81355. private static readonly _DirtyCallbackArray;
  81356. private static readonly _RunDirtyCallBacks;
  81357. /**
  81358. * Marks a define in the material to indicate that it needs to be re-computed
  81359. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  81360. */
  81361. markAsDirty(flag: number): void;
  81362. /**
  81363. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  81364. * @param func defines a function which checks material defines against the submeshes
  81365. */
  81366. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  81367. /**
  81368. * Indicates that image processing needs to be re-calculated for all submeshes
  81369. */
  81370. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  81371. /**
  81372. * Indicates that textures need to be re-calculated for all submeshes
  81373. */
  81374. protected _markAllSubMeshesAsTexturesDirty(): void;
  81375. /**
  81376. * Indicates that fresnel needs to be re-calculated for all submeshes
  81377. */
  81378. protected _markAllSubMeshesAsFresnelDirty(): void;
  81379. /**
  81380. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  81381. */
  81382. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  81383. /**
  81384. * Indicates that lights need to be re-calculated for all submeshes
  81385. */
  81386. protected _markAllSubMeshesAsLightsDirty(): void;
  81387. /**
  81388. * Indicates that attributes need to be re-calculated for all submeshes
  81389. */
  81390. protected _markAllSubMeshesAsAttributesDirty(): void;
  81391. /**
  81392. * Indicates that misc needs to be re-calculated for all submeshes
  81393. */
  81394. protected _markAllSubMeshesAsMiscDirty(): void;
  81395. /**
  81396. * Indicates that textures and misc need to be re-calculated for all submeshes
  81397. */
  81398. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  81399. /**
  81400. * Disposes the material
  81401. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81402. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  81403. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  81404. */
  81405. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  81406. /** @hidden */
  81407. private releaseVertexArrayObject;
  81408. /**
  81409. * Serializes this material
  81410. * @returns the serialized material object
  81411. */
  81412. serialize(): any;
  81413. /**
  81414. * Creates a material from parsed material data
  81415. * @param parsedMaterial defines parsed material data
  81416. * @param scene defines the hosting scene
  81417. * @param rootUrl defines the root URL to use to load textures
  81418. * @returns a new material
  81419. */
  81420. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  81421. }
  81422. }
  81423. declare module BABYLON {
  81424. /**
  81425. * Base class for submeshes
  81426. */
  81427. export class BaseSubMesh {
  81428. /** @hidden */
  81429. _materialDefines: Nullable<MaterialDefines>;
  81430. /** @hidden */
  81431. _materialEffect: Nullable<Effect>;
  81432. /**
  81433. * Gets associated effect
  81434. */
  81435. readonly effect: Nullable<Effect>;
  81436. /**
  81437. * Sets associated effect (effect used to render this submesh)
  81438. * @param effect defines the effect to associate with
  81439. * @param defines defines the set of defines used to compile this effect
  81440. */
  81441. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  81442. }
  81443. /**
  81444. * Defines a subdivision inside a mesh
  81445. */
  81446. export class SubMesh extends BaseSubMesh implements ICullable {
  81447. /** the material index to use */
  81448. materialIndex: number;
  81449. /** vertex index start */
  81450. verticesStart: number;
  81451. /** vertices count */
  81452. verticesCount: number;
  81453. /** index start */
  81454. indexStart: number;
  81455. /** indices count */
  81456. indexCount: number;
  81457. /** @hidden */
  81458. _linesIndexCount: number;
  81459. private _mesh;
  81460. private _renderingMesh;
  81461. private _boundingInfo;
  81462. private _linesIndexBuffer;
  81463. /** @hidden */
  81464. _lastColliderWorldVertices: Nullable<Vector3[]>;
  81465. /** @hidden */
  81466. _trianglePlanes: Plane[];
  81467. /** @hidden */
  81468. _lastColliderTransformMatrix: Matrix;
  81469. /** @hidden */
  81470. _renderId: number;
  81471. /** @hidden */
  81472. _alphaIndex: number;
  81473. /** @hidden */
  81474. _distanceToCamera: number;
  81475. /** @hidden */
  81476. _id: number;
  81477. private _currentMaterial;
  81478. /**
  81479. * Add a new submesh to a mesh
  81480. * @param materialIndex defines the material index to use
  81481. * @param verticesStart defines vertex index start
  81482. * @param verticesCount defines vertices count
  81483. * @param indexStart defines index start
  81484. * @param indexCount defines indices count
  81485. * @param mesh defines the parent mesh
  81486. * @param renderingMesh defines an optional rendering mesh
  81487. * @param createBoundingBox defines if bounding box should be created for this submesh
  81488. * @returns the new submesh
  81489. */
  81490. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  81491. /**
  81492. * Creates a new submesh
  81493. * @param materialIndex defines the material index to use
  81494. * @param verticesStart defines vertex index start
  81495. * @param verticesCount defines vertices count
  81496. * @param indexStart defines index start
  81497. * @param indexCount defines indices count
  81498. * @param mesh defines the parent mesh
  81499. * @param renderingMesh defines an optional rendering mesh
  81500. * @param createBoundingBox defines if bounding box should be created for this submesh
  81501. */
  81502. constructor(
  81503. /** the material index to use */
  81504. materialIndex: number,
  81505. /** vertex index start */
  81506. verticesStart: number,
  81507. /** vertices count */
  81508. verticesCount: number,
  81509. /** index start */
  81510. indexStart: number,
  81511. /** indices count */
  81512. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  81513. /**
  81514. * Returns true if this submesh covers the entire parent mesh
  81515. * @ignorenaming
  81516. */
  81517. readonly IsGlobal: boolean;
  81518. /**
  81519. * Returns the submesh BoudingInfo object
  81520. * @returns current bounding info (or mesh's one if the submesh is global)
  81521. */
  81522. getBoundingInfo(): BoundingInfo;
  81523. /**
  81524. * Sets the submesh BoundingInfo
  81525. * @param boundingInfo defines the new bounding info to use
  81526. * @returns the SubMesh
  81527. */
  81528. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  81529. /**
  81530. * Returns the mesh of the current submesh
  81531. * @return the parent mesh
  81532. */
  81533. getMesh(): AbstractMesh;
  81534. /**
  81535. * Returns the rendering mesh of the submesh
  81536. * @returns the rendering mesh (could be different from parent mesh)
  81537. */
  81538. getRenderingMesh(): Mesh;
  81539. /**
  81540. * Returns the submesh material
  81541. * @returns null or the current material
  81542. */
  81543. getMaterial(): Nullable<Material>;
  81544. /**
  81545. * Sets a new updated BoundingInfo object to the submesh
  81546. * @returns the SubMesh
  81547. */
  81548. refreshBoundingInfo(): SubMesh;
  81549. /** @hidden */
  81550. _checkCollision(collider: Collider): boolean;
  81551. /**
  81552. * Updates the submesh BoundingInfo
  81553. * @param world defines the world matrix to use to update the bounding info
  81554. * @returns the submesh
  81555. */
  81556. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  81557. /**
  81558. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  81559. * @param frustumPlanes defines the frustum planes
  81560. * @returns true if the submesh is intersecting with the frustum
  81561. */
  81562. isInFrustum(frustumPlanes: Plane[]): boolean;
  81563. /**
  81564. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  81565. * @param frustumPlanes defines the frustum planes
  81566. * @returns true if the submesh is inside the frustum
  81567. */
  81568. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81569. /**
  81570. * Renders the submesh
  81571. * @param enableAlphaMode defines if alpha needs to be used
  81572. * @returns the submesh
  81573. */
  81574. render(enableAlphaMode: boolean): SubMesh;
  81575. /**
  81576. * @hidden
  81577. */
  81578. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  81579. /**
  81580. * Checks if the submesh intersects with a ray
  81581. * @param ray defines the ray to test
  81582. * @returns true is the passed ray intersects the submesh bounding box
  81583. */
  81584. canIntersects(ray: Ray): boolean;
  81585. /**
  81586. * Intersects current submesh with a ray
  81587. * @param ray defines the ray to test
  81588. * @param positions defines mesh's positions array
  81589. * @param indices defines mesh's indices array
  81590. * @param fastCheck defines if only bounding info should be used
  81591. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81592. * @returns intersection info or null if no intersection
  81593. */
  81594. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  81595. /** @hidden */
  81596. private _intersectLines;
  81597. /** @hidden */
  81598. private _intersectTriangles;
  81599. /** @hidden */
  81600. _rebuild(): void;
  81601. /**
  81602. * Creates a new submesh from the passed mesh
  81603. * @param newMesh defines the new hosting mesh
  81604. * @param newRenderingMesh defines an optional rendering mesh
  81605. * @returns the new submesh
  81606. */
  81607. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  81608. /**
  81609. * Release associated resources
  81610. */
  81611. dispose(): void;
  81612. /**
  81613. * Gets the class name
  81614. * @returns the string "SubMesh".
  81615. */
  81616. getClassName(): string;
  81617. /**
  81618. * Creates a new submesh from indices data
  81619. * @param materialIndex the index of the main mesh material
  81620. * @param startIndex the index where to start the copy in the mesh indices array
  81621. * @param indexCount the number of indices to copy then from the startIndex
  81622. * @param mesh the main mesh to create the submesh from
  81623. * @param renderingMesh the optional rendering mesh
  81624. * @returns a new submesh
  81625. */
  81626. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  81627. }
  81628. }
  81629. declare module BABYLON {
  81630. /**
  81631. * Class used to store geometry data (vertex buffers + index buffer)
  81632. */
  81633. export class Geometry implements IGetSetVerticesData {
  81634. /**
  81635. * Gets or sets the ID of the geometry
  81636. */
  81637. id: string;
  81638. /**
  81639. * Gets or sets the unique ID of the geometry
  81640. */
  81641. uniqueId: number;
  81642. /**
  81643. * Gets the delay loading state of the geometry (none by default which means not delayed)
  81644. */
  81645. delayLoadState: number;
  81646. /**
  81647. * Gets the file containing the data to load when running in delay load state
  81648. */
  81649. delayLoadingFile: Nullable<string>;
  81650. /**
  81651. * Callback called when the geometry is updated
  81652. */
  81653. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  81654. private _scene;
  81655. private _engine;
  81656. private _meshes;
  81657. private _totalVertices;
  81658. /** @hidden */
  81659. _indices: IndicesArray;
  81660. /** @hidden */
  81661. _vertexBuffers: {
  81662. [key: string]: VertexBuffer;
  81663. };
  81664. private _isDisposed;
  81665. private _extend;
  81666. private _boundingBias;
  81667. /** @hidden */
  81668. _delayInfo: Array<string>;
  81669. private _indexBuffer;
  81670. private _indexBufferIsUpdatable;
  81671. /** @hidden */
  81672. _boundingInfo: Nullable<BoundingInfo>;
  81673. /** @hidden */
  81674. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  81675. /** @hidden */
  81676. _softwareSkinningFrameId: number;
  81677. private _vertexArrayObjects;
  81678. private _updatable;
  81679. /** @hidden */
  81680. _positions: Nullable<Vector3[]>;
  81681. /**
  81682. * 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
  81683. */
  81684. /**
  81685. * 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
  81686. */
  81687. boundingBias: Vector2;
  81688. /**
  81689. * Static function used to attach a new empty geometry to a mesh
  81690. * @param mesh defines the mesh to attach the geometry to
  81691. * @returns the new Geometry
  81692. */
  81693. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  81694. /**
  81695. * Creates a new geometry
  81696. * @param id defines the unique ID
  81697. * @param scene defines the hosting scene
  81698. * @param vertexData defines the VertexData used to get geometry data
  81699. * @param updatable defines if geometry must be updatable (false by default)
  81700. * @param mesh defines the mesh that will be associated with the geometry
  81701. */
  81702. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  81703. /**
  81704. * Gets the current extend of the geometry
  81705. */
  81706. readonly extend: {
  81707. minimum: Vector3;
  81708. maximum: Vector3;
  81709. };
  81710. /**
  81711. * Gets the hosting scene
  81712. * @returns the hosting Scene
  81713. */
  81714. getScene(): Scene;
  81715. /**
  81716. * Gets the hosting engine
  81717. * @returns the hosting Engine
  81718. */
  81719. getEngine(): Engine;
  81720. /**
  81721. * Defines if the geometry is ready to use
  81722. * @returns true if the geometry is ready to be used
  81723. */
  81724. isReady(): boolean;
  81725. /**
  81726. * Gets a value indicating that the geometry should not be serialized
  81727. */
  81728. readonly doNotSerialize: boolean;
  81729. /** @hidden */
  81730. _rebuild(): void;
  81731. /**
  81732. * Affects all geometry data in one call
  81733. * @param vertexData defines the geometry data
  81734. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81735. */
  81736. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  81737. /**
  81738. * Set specific vertex data
  81739. * @param kind defines the data kind (Position, normal, etc...)
  81740. * @param data defines the vertex data to use
  81741. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81742. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81743. */
  81744. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  81745. /**
  81746. * Removes a specific vertex data
  81747. * @param kind defines the data kind (Position, normal, etc...)
  81748. */
  81749. removeVerticesData(kind: string): void;
  81750. /**
  81751. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81752. * @param buffer defines the vertex buffer to use
  81753. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81754. */
  81755. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  81756. /**
  81757. * Update a specific vertex buffer
  81758. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81759. * It will do nothing if the buffer is not updatable
  81760. * @param kind defines the data kind (Position, normal, etc...)
  81761. * @param data defines the data to use
  81762. * @param offset defines the offset in the target buffer where to store the data
  81763. * @param useBytes set to true if the offset is in bytes
  81764. */
  81765. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  81766. /**
  81767. * Update a specific vertex buffer
  81768. * This function will create a new buffer if the current one is not updatable
  81769. * @param kind defines the data kind (Position, normal, etc...)
  81770. * @param data defines the data to use
  81771. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81772. */
  81773. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  81774. private _updateBoundingInfo;
  81775. /** @hidden */
  81776. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  81777. /**
  81778. * Gets total number of vertices
  81779. * @returns the total number of vertices
  81780. */
  81781. getTotalVertices(): number;
  81782. /**
  81783. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81784. * @param kind defines the data kind (Position, normal, etc...)
  81785. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81786. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81787. * @returns a float array containing vertex data
  81788. */
  81789. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81790. /**
  81791. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81792. * @param kind defines the data kind (Position, normal, etc...)
  81793. * @returns true if the vertex buffer with the specified kind is updatable
  81794. */
  81795. isVertexBufferUpdatable(kind: string): boolean;
  81796. /**
  81797. * Gets a specific vertex buffer
  81798. * @param kind defines the data kind (Position, normal, etc...)
  81799. * @returns a VertexBuffer
  81800. */
  81801. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81802. /**
  81803. * Returns all vertex buffers
  81804. * @return an object holding all vertex buffers indexed by kind
  81805. */
  81806. getVertexBuffers(): Nullable<{
  81807. [key: string]: VertexBuffer;
  81808. }>;
  81809. /**
  81810. * Gets a boolean indicating if specific vertex buffer is present
  81811. * @param kind defines the data kind (Position, normal, etc...)
  81812. * @returns true if data is present
  81813. */
  81814. isVerticesDataPresent(kind: string): boolean;
  81815. /**
  81816. * Gets a list of all attached data kinds (Position, normal, etc...)
  81817. * @returns a list of string containing all kinds
  81818. */
  81819. getVerticesDataKinds(): string[];
  81820. /**
  81821. * Update index buffer
  81822. * @param indices defines the indices to store in the index buffer
  81823. * @param offset defines the offset in the target buffer where to store the data
  81824. * @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)
  81825. */
  81826. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  81827. /**
  81828. * Creates a new index buffer
  81829. * @param indices defines the indices to store in the index buffer
  81830. * @param totalVertices defines the total number of vertices (could be null)
  81831. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81832. */
  81833. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  81834. /**
  81835. * Return the total number of indices
  81836. * @returns the total number of indices
  81837. */
  81838. getTotalIndices(): number;
  81839. /**
  81840. * Gets the index buffer array
  81841. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81842. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81843. * @returns the index buffer array
  81844. */
  81845. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81846. /**
  81847. * Gets the index buffer
  81848. * @return the index buffer
  81849. */
  81850. getIndexBuffer(): Nullable<WebGLBuffer>;
  81851. /** @hidden */
  81852. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  81853. /**
  81854. * Release the associated resources for a specific mesh
  81855. * @param mesh defines the source mesh
  81856. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  81857. */
  81858. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  81859. /**
  81860. * Apply current geometry to a given mesh
  81861. * @param mesh defines the mesh to apply geometry to
  81862. */
  81863. applyToMesh(mesh: Mesh): void;
  81864. private _updateExtend;
  81865. private _applyToMesh;
  81866. private notifyUpdate;
  81867. /**
  81868. * Load the geometry if it was flagged as delay loaded
  81869. * @param scene defines the hosting scene
  81870. * @param onLoaded defines a callback called when the geometry is loaded
  81871. */
  81872. load(scene: Scene, onLoaded?: () => void): void;
  81873. private _queueLoad;
  81874. /**
  81875. * Invert the geometry to move from a right handed system to a left handed one.
  81876. */
  81877. toLeftHanded(): void;
  81878. /** @hidden */
  81879. _resetPointsArrayCache(): void;
  81880. /** @hidden */
  81881. _generatePointsArray(): boolean;
  81882. /**
  81883. * Gets a value indicating if the geometry is disposed
  81884. * @returns true if the geometry was disposed
  81885. */
  81886. isDisposed(): boolean;
  81887. private _disposeVertexArrayObjects;
  81888. /**
  81889. * Free all associated resources
  81890. */
  81891. dispose(): void;
  81892. /**
  81893. * Clone the current geometry into a new geometry
  81894. * @param id defines the unique ID of the new geometry
  81895. * @returns a new geometry object
  81896. */
  81897. copy(id: string): Geometry;
  81898. /**
  81899. * Serialize the current geometry info (and not the vertices data) into a JSON object
  81900. * @return a JSON representation of the current geometry data (without the vertices data)
  81901. */
  81902. serialize(): any;
  81903. private toNumberArray;
  81904. /**
  81905. * Serialize all vertices data into a JSON oject
  81906. * @returns a JSON representation of the current geometry data
  81907. */
  81908. serializeVerticeData(): any;
  81909. /**
  81910. * Extracts a clone of a mesh geometry
  81911. * @param mesh defines the source mesh
  81912. * @param id defines the unique ID of the new geometry object
  81913. * @returns the new geometry object
  81914. */
  81915. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  81916. /**
  81917. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  81918. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  81919. * Be aware Math.random() could cause collisions, but:
  81920. * "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"
  81921. * @returns a string containing a new GUID
  81922. */
  81923. static RandomId(): string;
  81924. /** @hidden */
  81925. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  81926. private static _CleanMatricesWeights;
  81927. /**
  81928. * Create a new geometry from persisted data (Using .babylon file format)
  81929. * @param parsedVertexData defines the persisted data
  81930. * @param scene defines the hosting scene
  81931. * @param rootUrl defines the root url to use to load assets (like delayed data)
  81932. * @returns the new geometry object
  81933. */
  81934. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  81935. }
  81936. }
  81937. declare module BABYLON {
  81938. /**
  81939. * Define an interface for all classes that will get and set the data on vertices
  81940. */
  81941. export interface IGetSetVerticesData {
  81942. /**
  81943. * Gets a boolean indicating if specific vertex data is present
  81944. * @param kind defines the vertex data kind to use
  81945. * @returns true is data kind is present
  81946. */
  81947. isVerticesDataPresent(kind: string): boolean;
  81948. /**
  81949. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81950. * @param kind defines the data kind (Position, normal, etc...)
  81951. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81952. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81953. * @returns a float array containing vertex data
  81954. */
  81955. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81956. /**
  81957. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81958. * @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.
  81959. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81960. * @returns the indices array or an empty array if the mesh has no geometry
  81961. */
  81962. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81963. /**
  81964. * Set specific vertex data
  81965. * @param kind defines the data kind (Position, normal, etc...)
  81966. * @param data defines the vertex data to use
  81967. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81968. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81969. */
  81970. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  81971. /**
  81972. * Update a specific associated vertex buffer
  81973. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  81974. * - VertexBuffer.PositionKind
  81975. * - VertexBuffer.UVKind
  81976. * - VertexBuffer.UV2Kind
  81977. * - VertexBuffer.UV3Kind
  81978. * - VertexBuffer.UV4Kind
  81979. * - VertexBuffer.UV5Kind
  81980. * - VertexBuffer.UV6Kind
  81981. * - VertexBuffer.ColorKind
  81982. * - VertexBuffer.MatricesIndicesKind
  81983. * - VertexBuffer.MatricesIndicesExtraKind
  81984. * - VertexBuffer.MatricesWeightsKind
  81985. * - VertexBuffer.MatricesWeightsExtraKind
  81986. * @param data defines the data source
  81987. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  81988. * @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)
  81989. */
  81990. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  81991. /**
  81992. * Creates a new index buffer
  81993. * @param indices defines the indices to store in the index buffer
  81994. * @param totalVertices defines the total number of vertices (could be null)
  81995. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81996. */
  81997. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  81998. }
  81999. /**
  82000. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  82001. */
  82002. export class VertexData {
  82003. /**
  82004. * Mesh side orientation : usually the external or front surface
  82005. */
  82006. static readonly FRONTSIDE: number;
  82007. /**
  82008. * Mesh side orientation : usually the internal or back surface
  82009. */
  82010. static readonly BACKSIDE: number;
  82011. /**
  82012. * Mesh side orientation : both internal and external or front and back surfaces
  82013. */
  82014. static readonly DOUBLESIDE: number;
  82015. /**
  82016. * Mesh side orientation : by default, `FRONTSIDE`
  82017. */
  82018. static readonly DEFAULTSIDE: number;
  82019. /**
  82020. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  82021. */
  82022. positions: Nullable<FloatArray>;
  82023. /**
  82024. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  82025. */
  82026. normals: Nullable<FloatArray>;
  82027. /**
  82028. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  82029. */
  82030. tangents: Nullable<FloatArray>;
  82031. /**
  82032. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82033. */
  82034. uvs: Nullable<FloatArray>;
  82035. /**
  82036. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82037. */
  82038. uvs2: Nullable<FloatArray>;
  82039. /**
  82040. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82041. */
  82042. uvs3: Nullable<FloatArray>;
  82043. /**
  82044. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82045. */
  82046. uvs4: Nullable<FloatArray>;
  82047. /**
  82048. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82049. */
  82050. uvs5: Nullable<FloatArray>;
  82051. /**
  82052. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82053. */
  82054. uvs6: Nullable<FloatArray>;
  82055. /**
  82056. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  82057. */
  82058. colors: Nullable<FloatArray>;
  82059. /**
  82060. * 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).
  82061. */
  82062. matricesIndices: Nullable<FloatArray>;
  82063. /**
  82064. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  82065. */
  82066. matricesWeights: Nullable<FloatArray>;
  82067. /**
  82068. * An array extending the number of possible indices
  82069. */
  82070. matricesIndicesExtra: Nullable<FloatArray>;
  82071. /**
  82072. * An array extending the number of possible weights when the number of indices is extended
  82073. */
  82074. matricesWeightsExtra: Nullable<FloatArray>;
  82075. /**
  82076. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  82077. */
  82078. indices: Nullable<IndicesArray>;
  82079. /**
  82080. * Uses the passed data array to set the set the values for the specified kind of data
  82081. * @param data a linear array of floating numbers
  82082. * @param kind the type of data that is being set, eg positions, colors etc
  82083. */
  82084. set(data: FloatArray, kind: string): void;
  82085. /**
  82086. * Associates the vertexData to the passed Mesh.
  82087. * Sets it as updatable or not (default `false`)
  82088. * @param mesh the mesh the vertexData is applied to
  82089. * @param updatable when used and having the value true allows new data to update the vertexData
  82090. * @returns the VertexData
  82091. */
  82092. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  82093. /**
  82094. * Associates the vertexData to the passed Geometry.
  82095. * Sets it as updatable or not (default `false`)
  82096. * @param geometry the geometry the vertexData is applied to
  82097. * @param updatable when used and having the value true allows new data to update the vertexData
  82098. * @returns VertexData
  82099. */
  82100. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  82101. /**
  82102. * Updates the associated mesh
  82103. * @param mesh the mesh to be updated
  82104. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82105. * @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
  82106. * @returns VertexData
  82107. */
  82108. updateMesh(mesh: Mesh): VertexData;
  82109. /**
  82110. * Updates the associated geometry
  82111. * @param geometry the geometry to be updated
  82112. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82113. * @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
  82114. * @returns VertexData.
  82115. */
  82116. updateGeometry(geometry: Geometry): VertexData;
  82117. private _applyTo;
  82118. private _update;
  82119. /**
  82120. * Transforms each position and each normal of the vertexData according to the passed Matrix
  82121. * @param matrix the transforming matrix
  82122. * @returns the VertexData
  82123. */
  82124. transform(matrix: Matrix): VertexData;
  82125. /**
  82126. * Merges the passed VertexData into the current one
  82127. * @param other the VertexData to be merged into the current one
  82128. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  82129. * @returns the modified VertexData
  82130. */
  82131. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  82132. private _mergeElement;
  82133. private _validate;
  82134. /**
  82135. * Serializes the VertexData
  82136. * @returns a serialized object
  82137. */
  82138. serialize(): any;
  82139. /**
  82140. * Extracts the vertexData from a mesh
  82141. * @param mesh the mesh from which to extract the VertexData
  82142. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  82143. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82144. * @returns the object VertexData associated to the passed mesh
  82145. */
  82146. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82147. /**
  82148. * Extracts the vertexData from the geometry
  82149. * @param geometry the geometry from which to extract the VertexData
  82150. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  82151. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82152. * @returns the object VertexData associated to the passed mesh
  82153. */
  82154. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82155. private static _ExtractFrom;
  82156. /**
  82157. * Creates the VertexData for a Ribbon
  82158. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  82159. * * pathArray array of paths, each of which an array of successive Vector3
  82160. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  82161. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  82162. * * 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
  82163. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82164. * * 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)
  82165. * * 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)
  82166. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  82167. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  82168. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  82169. * @returns the VertexData of the ribbon
  82170. */
  82171. static CreateRibbon(options: {
  82172. pathArray: Vector3[][];
  82173. closeArray?: boolean;
  82174. closePath?: boolean;
  82175. offset?: number;
  82176. sideOrientation?: number;
  82177. frontUVs?: Vector4;
  82178. backUVs?: Vector4;
  82179. invertUV?: boolean;
  82180. uvs?: Vector2[];
  82181. colors?: Color4[];
  82182. }): VertexData;
  82183. /**
  82184. * Creates the VertexData for a box
  82185. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82186. * * size sets the width, height and depth of the box to the value of size, optional default 1
  82187. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  82188. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  82189. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  82190. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  82191. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  82192. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82193. * * 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)
  82194. * * 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)
  82195. * @returns the VertexData of the box
  82196. */
  82197. static CreateBox(options: {
  82198. size?: number;
  82199. width?: number;
  82200. height?: number;
  82201. depth?: number;
  82202. faceUV?: Vector4[];
  82203. faceColors?: Color4[];
  82204. sideOrientation?: number;
  82205. frontUVs?: Vector4;
  82206. backUVs?: Vector4;
  82207. }): VertexData;
  82208. /**
  82209. * Creates the VertexData for an ellipsoid, defaults to a sphere
  82210. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82211. * * segments sets the number of horizontal strips optional, default 32
  82212. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  82213. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  82214. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  82215. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  82216. * * 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
  82217. * * 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
  82218. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82219. * * 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)
  82220. * * 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)
  82221. * @returns the VertexData of the ellipsoid
  82222. */
  82223. static CreateSphere(options: {
  82224. segments?: number;
  82225. diameter?: number;
  82226. diameterX?: number;
  82227. diameterY?: number;
  82228. diameterZ?: number;
  82229. arc?: number;
  82230. slice?: number;
  82231. sideOrientation?: number;
  82232. frontUVs?: Vector4;
  82233. backUVs?: Vector4;
  82234. }): VertexData;
  82235. /**
  82236. * Creates the VertexData for a cylinder, cone or prism
  82237. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82238. * * height sets the height (y direction) of the cylinder, optional, default 2
  82239. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  82240. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  82241. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  82242. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82243. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  82244. * * 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
  82245. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82246. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82247. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  82248. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  82249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82250. * * 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)
  82251. * * 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)
  82252. * @returns the VertexData of the cylinder, cone or prism
  82253. */
  82254. static CreateCylinder(options: {
  82255. height?: number;
  82256. diameterTop?: number;
  82257. diameterBottom?: number;
  82258. diameter?: number;
  82259. tessellation?: number;
  82260. subdivisions?: number;
  82261. arc?: number;
  82262. faceColors?: Color4[];
  82263. faceUV?: Vector4[];
  82264. hasRings?: boolean;
  82265. enclose?: boolean;
  82266. sideOrientation?: number;
  82267. frontUVs?: Vector4;
  82268. backUVs?: Vector4;
  82269. }): VertexData;
  82270. /**
  82271. * Creates the VertexData for a torus
  82272. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82273. * * diameter the diameter of the torus, optional default 1
  82274. * * thickness the diameter of the tube forming the torus, optional default 0.5
  82275. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82276. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82277. * * 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)
  82278. * * 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)
  82279. * @returns the VertexData of the torus
  82280. */
  82281. static CreateTorus(options: {
  82282. diameter?: number;
  82283. thickness?: number;
  82284. tessellation?: number;
  82285. sideOrientation?: number;
  82286. frontUVs?: Vector4;
  82287. backUVs?: Vector4;
  82288. }): VertexData;
  82289. /**
  82290. * Creates the VertexData of the LineSystem
  82291. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  82292. * - lines an array of lines, each line being an array of successive Vector3
  82293. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  82294. * @returns the VertexData of the LineSystem
  82295. */
  82296. static CreateLineSystem(options: {
  82297. lines: Vector3[][];
  82298. colors?: Nullable<Color4[][]>;
  82299. }): VertexData;
  82300. /**
  82301. * Create the VertexData for a DashedLines
  82302. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  82303. * - points an array successive Vector3
  82304. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  82305. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  82306. * - dashNb the intended total number of dashes, optional, default 200
  82307. * @returns the VertexData for the DashedLines
  82308. */
  82309. static CreateDashedLines(options: {
  82310. points: Vector3[];
  82311. dashSize?: number;
  82312. gapSize?: number;
  82313. dashNb?: number;
  82314. }): VertexData;
  82315. /**
  82316. * Creates the VertexData for a Ground
  82317. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82318. * - width the width (x direction) of the ground, optional, default 1
  82319. * - height the height (z direction) of the ground, optional, default 1
  82320. * - subdivisions the number of subdivisions per side, optional, default 1
  82321. * @returns the VertexData of the Ground
  82322. */
  82323. static CreateGround(options: {
  82324. width?: number;
  82325. height?: number;
  82326. subdivisions?: number;
  82327. subdivisionsX?: number;
  82328. subdivisionsY?: number;
  82329. }): VertexData;
  82330. /**
  82331. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  82332. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82333. * * xmin the ground minimum X coordinate, optional, default -1
  82334. * * zmin the ground minimum Z coordinate, optional, default -1
  82335. * * xmax the ground maximum X coordinate, optional, default 1
  82336. * * zmax the ground maximum Z coordinate, optional, default 1
  82337. * * 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}
  82338. * * 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}
  82339. * @returns the VertexData of the TiledGround
  82340. */
  82341. static CreateTiledGround(options: {
  82342. xmin: number;
  82343. zmin: number;
  82344. xmax: number;
  82345. zmax: number;
  82346. subdivisions?: {
  82347. w: number;
  82348. h: number;
  82349. };
  82350. precision?: {
  82351. w: number;
  82352. h: number;
  82353. };
  82354. }): VertexData;
  82355. /**
  82356. * Creates the VertexData of the Ground designed from a heightmap
  82357. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  82358. * * width the width (x direction) of the ground
  82359. * * height the height (z direction) of the ground
  82360. * * subdivisions the number of subdivisions per side
  82361. * * minHeight the minimum altitude on the ground, optional, default 0
  82362. * * maxHeight the maximum altitude on the ground, optional default 1
  82363. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  82364. * * buffer the array holding the image color data
  82365. * * bufferWidth the width of image
  82366. * * bufferHeight the height of image
  82367. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  82368. * @returns the VertexData of the Ground designed from a heightmap
  82369. */
  82370. static CreateGroundFromHeightMap(options: {
  82371. width: number;
  82372. height: number;
  82373. subdivisions: number;
  82374. minHeight: number;
  82375. maxHeight: number;
  82376. colorFilter: Color3;
  82377. buffer: Uint8Array;
  82378. bufferWidth: number;
  82379. bufferHeight: number;
  82380. alphaFilter: number;
  82381. }): VertexData;
  82382. /**
  82383. * Creates the VertexData for a Plane
  82384. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  82385. * * size sets the width and height of the plane to the value of size, optional default 1
  82386. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  82387. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  82388. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82389. * * 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)
  82390. * * 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)
  82391. * @returns the VertexData of the box
  82392. */
  82393. static CreatePlane(options: {
  82394. size?: number;
  82395. width?: number;
  82396. height?: number;
  82397. sideOrientation?: number;
  82398. frontUVs?: Vector4;
  82399. backUVs?: Vector4;
  82400. }): VertexData;
  82401. /**
  82402. * Creates the VertexData of the Disc or regular Polygon
  82403. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  82404. * * radius the radius of the disc, optional default 0.5
  82405. * * tessellation the number of polygon sides, optional, default 64
  82406. * * 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
  82407. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82408. * * 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)
  82409. * * 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)
  82410. * @returns the VertexData of the box
  82411. */
  82412. static CreateDisc(options: {
  82413. radius?: number;
  82414. tessellation?: number;
  82415. arc?: number;
  82416. sideOrientation?: number;
  82417. frontUVs?: Vector4;
  82418. backUVs?: Vector4;
  82419. }): VertexData;
  82420. /**
  82421. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  82422. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  82423. * @param polygon a mesh built from polygonTriangulation.build()
  82424. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82425. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82426. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82427. * @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)
  82428. * @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)
  82429. * @returns the VertexData of the Polygon
  82430. */
  82431. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  82432. /**
  82433. * Creates the VertexData of the IcoSphere
  82434. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  82435. * * radius the radius of the IcoSphere, optional default 1
  82436. * * radiusX allows stretching in the x direction, optional, default radius
  82437. * * radiusY allows stretching in the y direction, optional, default radius
  82438. * * radiusZ allows stretching in the z direction, optional, default radius
  82439. * * flat when true creates a flat shaded mesh, optional, default true
  82440. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82442. * * 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)
  82443. * * 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)
  82444. * @returns the VertexData of the IcoSphere
  82445. */
  82446. static CreateIcoSphere(options: {
  82447. radius?: number;
  82448. radiusX?: number;
  82449. radiusY?: number;
  82450. radiusZ?: number;
  82451. flat?: boolean;
  82452. subdivisions?: number;
  82453. sideOrientation?: number;
  82454. frontUVs?: Vector4;
  82455. backUVs?: Vector4;
  82456. }): VertexData;
  82457. /**
  82458. * Creates the VertexData for a Polyhedron
  82459. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  82460. * * type provided types are:
  82461. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  82462. * * 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)
  82463. * * size the size of the IcoSphere, optional default 1
  82464. * * sizeX allows stretching in the x direction, optional, default size
  82465. * * sizeY allows stretching in the y direction, optional, default size
  82466. * * sizeZ allows stretching in the z direction, optional, default size
  82467. * * 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
  82468. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82469. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82470. * * flat when true creates a flat shaded mesh, optional, default true
  82471. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82472. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82473. * * 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)
  82474. * * 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)
  82475. * @returns the VertexData of the Polyhedron
  82476. */
  82477. static CreatePolyhedron(options: {
  82478. type?: number;
  82479. size?: number;
  82480. sizeX?: number;
  82481. sizeY?: number;
  82482. sizeZ?: number;
  82483. custom?: any;
  82484. faceUV?: Vector4[];
  82485. faceColors?: Color4[];
  82486. flat?: boolean;
  82487. sideOrientation?: number;
  82488. frontUVs?: Vector4;
  82489. backUVs?: Vector4;
  82490. }): VertexData;
  82491. /**
  82492. * Creates the VertexData for a TorusKnot
  82493. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  82494. * * radius the radius of the torus knot, optional, default 2
  82495. * * tube the thickness of the tube, optional, default 0.5
  82496. * * radialSegments the number of sides on each tube segments, optional, default 32
  82497. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  82498. * * p the number of windings around the z axis, optional, default 2
  82499. * * q the number of windings around the x axis, optional, default 3
  82500. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82501. * * 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)
  82502. * * 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)
  82503. * @returns the VertexData of the Torus Knot
  82504. */
  82505. static CreateTorusKnot(options: {
  82506. radius?: number;
  82507. tube?: number;
  82508. radialSegments?: number;
  82509. tubularSegments?: number;
  82510. p?: number;
  82511. q?: number;
  82512. sideOrientation?: number;
  82513. frontUVs?: Vector4;
  82514. backUVs?: Vector4;
  82515. }): VertexData;
  82516. /**
  82517. * Compute normals for given positions and indices
  82518. * @param positions an array of vertex positions, [...., x, y, z, ......]
  82519. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  82520. * @param normals an array of vertex normals, [...., x, y, z, ......]
  82521. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  82522. * * facetNormals : optional array of facet normals (vector3)
  82523. * * facetPositions : optional array of facet positions (vector3)
  82524. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  82525. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  82526. * * bInfo : optional bounding info, required for facetPartitioning computation
  82527. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  82528. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  82529. * * useRightHandedSystem: optional boolean to for right handed system computation
  82530. * * depthSort : optional boolean to enable the facet depth sort computation
  82531. * * distanceTo : optional Vector3 to compute the facet depth from this location
  82532. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  82533. */
  82534. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  82535. facetNormals?: any;
  82536. facetPositions?: any;
  82537. facetPartitioning?: any;
  82538. ratio?: number;
  82539. bInfo?: any;
  82540. bbSize?: Vector3;
  82541. subDiv?: any;
  82542. useRightHandedSystem?: boolean;
  82543. depthSort?: boolean;
  82544. distanceTo?: Vector3;
  82545. depthSortedFacets?: any;
  82546. }): void;
  82547. /** @hidden */
  82548. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  82549. /**
  82550. * Applies VertexData created from the imported parameters to the geometry
  82551. * @param parsedVertexData the parsed data from an imported file
  82552. * @param geometry the geometry to apply the VertexData to
  82553. */
  82554. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  82555. }
  82556. }
  82557. declare module BABYLON {
  82558. /**
  82559. * Class containing static functions to help procedurally build meshes
  82560. */
  82561. export class DiscBuilder {
  82562. /**
  82563. * Creates a plane polygonal mesh. By default, this is a disc
  82564. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  82565. * * 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
  82566. * * 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
  82567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  82569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82570. * @param name defines the name of the mesh
  82571. * @param options defines the options used to create the mesh
  82572. * @param scene defines the hosting scene
  82573. * @returns the plane polygonal mesh
  82574. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  82575. */
  82576. static CreateDisc(name: string, options: {
  82577. radius?: number;
  82578. tessellation?: number;
  82579. arc?: number;
  82580. updatable?: boolean;
  82581. sideOrientation?: number;
  82582. frontUVs?: Vector4;
  82583. backUVs?: Vector4;
  82584. }, scene?: Nullable<Scene>): Mesh;
  82585. }
  82586. }
  82587. declare module BABYLON {
  82588. /**
  82589. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  82590. *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.
  82591. * The SPS is also a particle system. It provides some methods to manage the particles.
  82592. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  82593. *
  82594. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  82595. */
  82596. export class SolidParticleSystem implements IDisposable {
  82597. /**
  82598. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  82599. * Example : var p = SPS.particles[i];
  82600. */
  82601. particles: SolidParticle[];
  82602. /**
  82603. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  82604. */
  82605. nbParticles: number;
  82606. /**
  82607. * If the particles must ever face the camera (default false). Useful for planar particles.
  82608. */
  82609. billboard: boolean;
  82610. /**
  82611. * Recompute normals when adding a shape
  82612. */
  82613. recomputeNormals: boolean;
  82614. /**
  82615. * This a counter ofr your own usage. It's not set by any SPS functions.
  82616. */
  82617. counter: number;
  82618. /**
  82619. * The SPS name. This name is also given to the underlying mesh.
  82620. */
  82621. name: string;
  82622. /**
  82623. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  82624. */
  82625. mesh: Mesh;
  82626. /**
  82627. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  82628. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  82629. */
  82630. vars: any;
  82631. /**
  82632. * This array is populated when the SPS is set as 'pickable'.
  82633. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  82634. * Each element of this array is an object `{idx: int, faceId: int}`.
  82635. * `idx` is the picked particle index in the `SPS.particles` array
  82636. * `faceId` is the picked face index counted within this particle.
  82637. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  82638. */
  82639. pickedParticles: {
  82640. idx: number;
  82641. faceId: number;
  82642. }[];
  82643. /**
  82644. * This array is populated when `enableDepthSort` is set to true.
  82645. * Each element of this array is an instance of the class DepthSortedParticle.
  82646. */
  82647. depthSortedParticles: DepthSortedParticle[];
  82648. /**
  82649. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  82650. * @hidden
  82651. */
  82652. _bSphereOnly: boolean;
  82653. /**
  82654. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  82655. * @hidden
  82656. */
  82657. _bSphereRadiusFactor: number;
  82658. private _scene;
  82659. private _positions;
  82660. private _indices;
  82661. private _normals;
  82662. private _colors;
  82663. private _uvs;
  82664. private _indices32;
  82665. private _positions32;
  82666. private _normals32;
  82667. private _fixedNormal32;
  82668. private _colors32;
  82669. private _uvs32;
  82670. private _index;
  82671. private _updatable;
  82672. private _pickable;
  82673. private _isVisibilityBoxLocked;
  82674. private _alwaysVisible;
  82675. private _depthSort;
  82676. private _shapeCounter;
  82677. private _copy;
  82678. private _color;
  82679. private _computeParticleColor;
  82680. private _computeParticleTexture;
  82681. private _computeParticleRotation;
  82682. private _computeParticleVertex;
  82683. private _computeBoundingBox;
  82684. private _depthSortParticles;
  82685. private _camera;
  82686. private _mustUnrotateFixedNormals;
  82687. private _particlesIntersect;
  82688. private _needs32Bits;
  82689. /**
  82690. * Creates a SPS (Solid Particle System) object.
  82691. * @param name (String) is the SPS name, this will be the underlying mesh name.
  82692. * @param scene (Scene) is the scene in which the SPS is added.
  82693. * @param options defines the options of the sps e.g.
  82694. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  82695. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  82696. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  82697. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  82698. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  82699. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  82700. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  82701. */
  82702. constructor(name: string, scene: Scene, options?: {
  82703. updatable?: boolean;
  82704. isPickable?: boolean;
  82705. enableDepthSort?: boolean;
  82706. particleIntersection?: boolean;
  82707. boundingSphereOnly?: boolean;
  82708. bSphereRadiusFactor?: number;
  82709. });
  82710. /**
  82711. * Builds the SPS underlying mesh. Returns a standard Mesh.
  82712. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  82713. * @returns the created mesh
  82714. */
  82715. buildMesh(): Mesh;
  82716. /**
  82717. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  82718. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  82719. * Thus the particles generated from `digest()` have their property `position` set yet.
  82720. * @param mesh ( Mesh ) is the mesh to be digested
  82721. * @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
  82722. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  82723. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  82724. * @returns the current SPS
  82725. */
  82726. digest(mesh: Mesh, options?: {
  82727. facetNb?: number;
  82728. number?: number;
  82729. delta?: number;
  82730. }): SolidParticleSystem;
  82731. private _unrotateFixedNormals;
  82732. private _resetCopy;
  82733. private _meshBuilder;
  82734. private _posToShape;
  82735. private _uvsToShapeUV;
  82736. private _addParticle;
  82737. /**
  82738. * Adds some particles to the SPS from the model shape. Returns the shape id.
  82739. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  82740. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  82741. * @param nb (positive integer) the number of particles to be created from this model
  82742. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  82743. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  82744. * @returns the number of shapes in the system
  82745. */
  82746. addShape(mesh: Mesh, nb: number, options?: {
  82747. positionFunction?: any;
  82748. vertexFunction?: any;
  82749. }): number;
  82750. private _rebuildParticle;
  82751. /**
  82752. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  82753. * @returns the SPS.
  82754. */
  82755. rebuildMesh(): SolidParticleSystem;
  82756. /**
  82757. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  82758. * This method calls `updateParticle()` for each particle of the SPS.
  82759. * For an animated SPS, it is usually called within the render loop.
  82760. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  82761. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  82762. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  82763. * @returns the SPS.
  82764. */
  82765. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  82766. /**
  82767. * Disposes the SPS.
  82768. */
  82769. dispose(): void;
  82770. /**
  82771. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  82772. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82773. * @returns the SPS.
  82774. */
  82775. refreshVisibleSize(): SolidParticleSystem;
  82776. /**
  82777. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  82778. * @param size the size (float) of the visibility box
  82779. * note : this doesn't lock the SPS mesh bounding box.
  82780. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82781. */
  82782. setVisibilityBox(size: number): void;
  82783. /**
  82784. * Gets whether the SPS as always visible or not
  82785. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82786. */
  82787. /**
  82788. * Sets the SPS as always visible or not
  82789. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82790. */
  82791. isAlwaysVisible: boolean;
  82792. /**
  82793. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82794. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82795. */
  82796. /**
  82797. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82798. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82799. */
  82800. isVisibilityBoxLocked: boolean;
  82801. /**
  82802. * Tells to `setParticles()` to compute the particle rotations or not.
  82803. * Default value : true. The SPS is faster when it's set to false.
  82804. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82805. */
  82806. /**
  82807. * Gets if `setParticles()` computes the particle rotations or not.
  82808. * Default value : true. The SPS is faster when it's set to false.
  82809. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82810. */
  82811. computeParticleRotation: boolean;
  82812. /**
  82813. * Tells to `setParticles()` to compute the particle colors or not.
  82814. * Default value : true. The SPS is faster when it's set to false.
  82815. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82816. */
  82817. /**
  82818. * Gets if `setParticles()` computes the particle colors or not.
  82819. * Default value : true. The SPS is faster when it's set to false.
  82820. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82821. */
  82822. computeParticleColor: boolean;
  82823. /**
  82824. * Gets if `setParticles()` computes the particle textures or not.
  82825. * Default value : true. The SPS is faster when it's set to false.
  82826. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  82827. */
  82828. computeParticleTexture: boolean;
  82829. /**
  82830. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  82831. * Default value : false. The SPS is faster when it's set to false.
  82832. * Note : the particle custom vertex positions aren't stored values.
  82833. */
  82834. /**
  82835. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  82836. * Default value : false. The SPS is faster when it's set to false.
  82837. * Note : the particle custom vertex positions aren't stored values.
  82838. */
  82839. computeParticleVertex: boolean;
  82840. /**
  82841. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  82842. */
  82843. /**
  82844. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  82845. */
  82846. computeBoundingBox: boolean;
  82847. /**
  82848. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  82849. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82850. * Default : `true`
  82851. */
  82852. /**
  82853. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  82854. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82855. * Default : `true`
  82856. */
  82857. depthSortParticles: boolean;
  82858. /**
  82859. * This function does nothing. It may be overwritten to set all the particle first values.
  82860. * The SPS doesn't call this function, you may have to call it by your own.
  82861. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82862. */
  82863. initParticles(): void;
  82864. /**
  82865. * This function does nothing. It may be overwritten to recycle a particle.
  82866. * The SPS doesn't call this function, you may have to call it by your own.
  82867. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82868. * @param particle The particle to recycle
  82869. * @returns the recycled particle
  82870. */
  82871. recycleParticle(particle: SolidParticle): SolidParticle;
  82872. /**
  82873. * Updates a particle : this function should be overwritten by the user.
  82874. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  82875. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82876. * @example : just set a particle position or velocity and recycle conditions
  82877. * @param particle The particle to update
  82878. * @returns the updated particle
  82879. */
  82880. updateParticle(particle: SolidParticle): SolidParticle;
  82881. /**
  82882. * Updates a vertex of a particle : it can be overwritten by the user.
  82883. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  82884. * @param particle the current particle
  82885. * @param vertex the current index of the current particle
  82886. * @param pt the index of the current vertex in the particle shape
  82887. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  82888. * @example : just set a vertex particle position
  82889. * @returns the updated vertex
  82890. */
  82891. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  82892. /**
  82893. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  82894. * This does nothing and may be overwritten by the user.
  82895. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82896. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82897. * @param update the boolean update value actually passed to setParticles()
  82898. */
  82899. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82900. /**
  82901. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  82902. * This will be passed three parameters.
  82903. * This does nothing and may be overwritten by the user.
  82904. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82905. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82906. * @param update the boolean update value actually passed to setParticles()
  82907. */
  82908. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82909. }
  82910. }
  82911. declare module BABYLON {
  82912. /**
  82913. * Represents one particle of a solid particle system.
  82914. */
  82915. export class SolidParticle {
  82916. /**
  82917. * particle global index
  82918. */
  82919. idx: number;
  82920. /**
  82921. * The color of the particle
  82922. */
  82923. color: Nullable<Color4>;
  82924. /**
  82925. * The world space position of the particle.
  82926. */
  82927. position: Vector3;
  82928. /**
  82929. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  82930. */
  82931. rotation: Vector3;
  82932. /**
  82933. * The world space rotation quaternion of the particle.
  82934. */
  82935. rotationQuaternion: Nullable<Quaternion>;
  82936. /**
  82937. * The scaling of the particle.
  82938. */
  82939. scaling: Vector3;
  82940. /**
  82941. * The uvs of the particle.
  82942. */
  82943. uvs: Vector4;
  82944. /**
  82945. * The current speed of the particle.
  82946. */
  82947. velocity: Vector3;
  82948. /**
  82949. * The pivot point in the particle local space.
  82950. */
  82951. pivot: Vector3;
  82952. /**
  82953. * Must the particle be translated from its pivot point in its local space ?
  82954. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  82955. * Default : false
  82956. */
  82957. translateFromPivot: boolean;
  82958. /**
  82959. * Is the particle active or not ?
  82960. */
  82961. alive: boolean;
  82962. /**
  82963. * Is the particle visible or not ?
  82964. */
  82965. isVisible: boolean;
  82966. /**
  82967. * Index of this particle in the global "positions" array (Internal use)
  82968. * @hidden
  82969. */
  82970. _pos: number;
  82971. /**
  82972. * @hidden Index of this particle in the global "indices" array (Internal use)
  82973. */
  82974. _ind: number;
  82975. /**
  82976. * @hidden ModelShape of this particle (Internal use)
  82977. */
  82978. _model: ModelShape;
  82979. /**
  82980. * ModelShape id of this particle
  82981. */
  82982. shapeId: number;
  82983. /**
  82984. * Index of the particle in its shape id (Internal use)
  82985. */
  82986. idxInShape: number;
  82987. /**
  82988. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  82989. */
  82990. _modelBoundingInfo: BoundingInfo;
  82991. /**
  82992. * @hidden Particle BoundingInfo object (Internal use)
  82993. */
  82994. _boundingInfo: BoundingInfo;
  82995. /**
  82996. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  82997. */
  82998. _sps: SolidParticleSystem;
  82999. /**
  83000. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  83001. */
  83002. _stillInvisible: boolean;
  83003. /**
  83004. * @hidden Last computed particle rotation matrix
  83005. */
  83006. _rotationMatrix: number[];
  83007. /**
  83008. * Parent particle Id, if any.
  83009. * Default null.
  83010. */
  83011. parentId: Nullable<number>;
  83012. /**
  83013. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  83014. * The possible values are :
  83015. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83016. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83017. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83018. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83019. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83020. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  83021. * */
  83022. cullingStrategy: number;
  83023. /**
  83024. * @hidden Internal global position in the SPS.
  83025. */
  83026. _globalPosition: Vector3;
  83027. /**
  83028. * Creates a Solid Particle object.
  83029. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  83030. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  83031. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  83032. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  83033. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  83034. * @param shapeId (integer) is the model shape identifier in the SPS.
  83035. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  83036. * @param sps defines the sps it is associated to
  83037. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  83038. */
  83039. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  83040. /**
  83041. * Legacy support, changed scale to scaling
  83042. */
  83043. /**
  83044. * Legacy support, changed scale to scaling
  83045. */
  83046. scale: Vector3;
  83047. /**
  83048. * Legacy support, changed quaternion to rotationQuaternion
  83049. */
  83050. /**
  83051. * Legacy support, changed quaternion to rotationQuaternion
  83052. */
  83053. quaternion: Nullable<Quaternion>;
  83054. /**
  83055. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  83056. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  83057. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  83058. * @returns true if it intersects
  83059. */
  83060. intersectsMesh(target: Mesh | SolidParticle): boolean;
  83061. /**
  83062. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  83063. * A particle is in the frustum if its bounding box intersects the frustum
  83064. * @param frustumPlanes defines the frustum to test
  83065. * @returns true if the particle is in the frustum planes
  83066. */
  83067. isInFrustum(frustumPlanes: Plane[]): boolean;
  83068. /**
  83069. * get the rotation matrix of the particle
  83070. * @hidden
  83071. */
  83072. getRotationMatrix(m: Matrix): void;
  83073. }
  83074. /**
  83075. * Represents the shape of the model used by one particle of a solid particle system.
  83076. * SPS internal tool, don't use it manually.
  83077. */
  83078. export class ModelShape {
  83079. /**
  83080. * The shape id
  83081. * @hidden
  83082. */
  83083. shapeID: number;
  83084. /**
  83085. * flat array of model positions (internal use)
  83086. * @hidden
  83087. */
  83088. _shape: Vector3[];
  83089. /**
  83090. * flat array of model UVs (internal use)
  83091. * @hidden
  83092. */
  83093. _shapeUV: number[];
  83094. /**
  83095. * length of the shape in the model indices array (internal use)
  83096. * @hidden
  83097. */
  83098. _indicesLength: number;
  83099. /**
  83100. * Custom position function (internal use)
  83101. * @hidden
  83102. */
  83103. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  83104. /**
  83105. * Custom vertex function (internal use)
  83106. * @hidden
  83107. */
  83108. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  83109. /**
  83110. * 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.
  83111. * SPS internal tool, don't use it manually.
  83112. * @hidden
  83113. */
  83114. 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>);
  83115. }
  83116. /**
  83117. * Represents a Depth Sorted Particle in the solid particle system.
  83118. */
  83119. export class DepthSortedParticle {
  83120. /**
  83121. * Index of the particle in the "indices" array
  83122. */
  83123. ind: number;
  83124. /**
  83125. * Length of the particle shape in the "indices" array
  83126. */
  83127. indicesLength: number;
  83128. /**
  83129. * Squared distance from the particle to the camera
  83130. */
  83131. sqDistance: number;
  83132. }
  83133. }
  83134. declare module BABYLON {
  83135. /**
  83136. * Class used to store all common mesh properties
  83137. */
  83138. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  83139. /** No occlusion */
  83140. static OCCLUSION_TYPE_NONE: number;
  83141. /** Occlusion set to optimisitic */
  83142. static OCCLUSION_TYPE_OPTIMISTIC: number;
  83143. /** Occlusion set to strict */
  83144. static OCCLUSION_TYPE_STRICT: number;
  83145. /** Use an accurante occlusion algorithm */
  83146. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  83147. /** Use a conservative occlusion algorithm */
  83148. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  83149. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  83150. * Test order :
  83151. * Is the bounding sphere outside the frustum ?
  83152. * If not, are the bounding box vertices outside the frustum ?
  83153. * It not, then the cullable object is in the frustum.
  83154. */
  83155. static readonly CULLINGSTRATEGY_STANDARD: number;
  83156. /** Culling strategy : Bounding Sphere Only.
  83157. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  83158. * It's also less accurate than the standard because some not visible objects can still be selected.
  83159. * Test : is the bounding sphere outside the frustum ?
  83160. * If not, then the cullable object is in the frustum.
  83161. */
  83162. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  83163. /** Culling strategy : Optimistic Inclusion.
  83164. * This in an inclusion test first, then the standard exclusion test.
  83165. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  83166. * 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.
  83167. * Anyway, it's as accurate as the standard strategy.
  83168. * Test :
  83169. * Is the cullable object bounding sphere center in the frustum ?
  83170. * If not, apply the default culling strategy.
  83171. */
  83172. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  83173. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  83174. * This in an inclusion test first, then the bounding sphere only exclusion test.
  83175. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  83176. * 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.
  83177. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  83178. * Test :
  83179. * Is the cullable object bounding sphere center in the frustum ?
  83180. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  83181. */
  83182. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  83183. /**
  83184. * No billboard
  83185. */
  83186. static readonly BILLBOARDMODE_NONE: number;
  83187. /** Billboard on X axis */
  83188. static readonly BILLBOARDMODE_X: number;
  83189. /** Billboard on Y axis */
  83190. static readonly BILLBOARDMODE_Y: number;
  83191. /** Billboard on Z axis */
  83192. static readonly BILLBOARDMODE_Z: number;
  83193. /** Billboard on all axes */
  83194. static readonly BILLBOARDMODE_ALL: number;
  83195. private _facetData;
  83196. /**
  83197. * The culling strategy to use to check whether the mesh must be rendered or not.
  83198. * This value can be changed at any time and will be used on the next render mesh selection.
  83199. * The possible values are :
  83200. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83201. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83202. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83203. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83204. * Please read each static variable documentation to get details about the culling process.
  83205. * */
  83206. cullingStrategy: number;
  83207. /**
  83208. * Gets the number of facets in the mesh
  83209. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83210. */
  83211. readonly facetNb: number;
  83212. /**
  83213. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  83214. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83215. */
  83216. partitioningSubdivisions: number;
  83217. /**
  83218. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  83219. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  83220. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83221. */
  83222. partitioningBBoxRatio: number;
  83223. /**
  83224. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  83225. * Works only for updatable meshes.
  83226. * Doesn't work with multi-materials
  83227. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83228. */
  83229. mustDepthSortFacets: boolean;
  83230. /**
  83231. * The location (Vector3) where the facet depth sort must be computed from.
  83232. * By default, the active camera position.
  83233. * Used only when facet depth sort is enabled
  83234. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83235. */
  83236. facetDepthSortFrom: Vector3;
  83237. /**
  83238. * gets a boolean indicating if facetData is enabled
  83239. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83240. */
  83241. readonly isFacetDataEnabled: boolean;
  83242. /** @hidden */
  83243. _updateNonUniformScalingState(value: boolean): boolean;
  83244. /**
  83245. * An event triggered when this mesh collides with another one
  83246. */
  83247. onCollideObservable: Observable<AbstractMesh>;
  83248. private _onCollideObserver;
  83249. /** Set a function to call when this mesh collides with another one */
  83250. onCollide: () => void;
  83251. /**
  83252. * An event triggered when the collision's position changes
  83253. */
  83254. onCollisionPositionChangeObservable: Observable<Vector3>;
  83255. private _onCollisionPositionChangeObserver;
  83256. /** Set a function to call when the collision's position changes */
  83257. onCollisionPositionChange: () => void;
  83258. /**
  83259. * An event triggered when material is changed
  83260. */
  83261. onMaterialChangedObservable: Observable<AbstractMesh>;
  83262. /**
  83263. * Gets or sets the orientation for POV movement & rotation
  83264. */
  83265. definedFacingForward: boolean;
  83266. /** @hidden */
  83267. _occlusionQuery: Nullable<WebGLQuery>;
  83268. private _visibility;
  83269. /**
  83270. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83271. */
  83272. /**
  83273. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83274. */
  83275. visibility: number;
  83276. /** Gets or sets the alpha index used to sort transparent meshes
  83277. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  83278. */
  83279. alphaIndex: number;
  83280. /**
  83281. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  83282. */
  83283. isVisible: boolean;
  83284. /**
  83285. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83286. */
  83287. isPickable: boolean;
  83288. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  83289. showSubMeshesBoundingBox: boolean;
  83290. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  83291. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  83292. */
  83293. isBlocker: boolean;
  83294. /**
  83295. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  83296. */
  83297. enablePointerMoveEvents: boolean;
  83298. /**
  83299. * Specifies the rendering group id for this mesh (0 by default)
  83300. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83301. */
  83302. renderingGroupId: number;
  83303. private _material;
  83304. /** Gets or sets current material */
  83305. material: Nullable<Material>;
  83306. private _receiveShadows;
  83307. /**
  83308. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  83309. * @see http://doc.babylonjs.com/babylon101/shadows
  83310. */
  83311. receiveShadows: boolean;
  83312. /** Defines color to use when rendering outline */
  83313. outlineColor: Color3;
  83314. /** Define width to use when rendering outline */
  83315. outlineWidth: number;
  83316. /** Defines color to use when rendering overlay */
  83317. overlayColor: Color3;
  83318. /** Defines alpha to use when rendering overlay */
  83319. overlayAlpha: number;
  83320. private _hasVertexAlpha;
  83321. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  83322. hasVertexAlpha: boolean;
  83323. private _useVertexColors;
  83324. /** 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) */
  83325. useVertexColors: boolean;
  83326. private _computeBonesUsingShaders;
  83327. /**
  83328. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  83329. */
  83330. computeBonesUsingShaders: boolean;
  83331. private _numBoneInfluencers;
  83332. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  83333. numBoneInfluencers: number;
  83334. private _applyFog;
  83335. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  83336. applyFog: boolean;
  83337. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  83338. useOctreeForRenderingSelection: boolean;
  83339. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  83340. useOctreeForPicking: boolean;
  83341. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  83342. useOctreeForCollisions: boolean;
  83343. private _layerMask;
  83344. /**
  83345. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  83346. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  83347. */
  83348. layerMask: number;
  83349. /**
  83350. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  83351. */
  83352. alwaysSelectAsActiveMesh: boolean;
  83353. /**
  83354. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  83355. */
  83356. doNotSyncBoundingInfo: boolean;
  83357. /**
  83358. * Gets or sets the current action manager
  83359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83360. */
  83361. actionManager: Nullable<AbstractActionManager>;
  83362. private _checkCollisions;
  83363. private _collisionMask;
  83364. private _collisionGroup;
  83365. /**
  83366. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  83367. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83368. */
  83369. ellipsoid: Vector3;
  83370. /**
  83371. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  83372. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83373. */
  83374. ellipsoidOffset: Vector3;
  83375. private _collider;
  83376. private _oldPositionForCollisions;
  83377. private _diffPositionForCollisions;
  83378. /**
  83379. * Gets or sets a collision mask used to mask collisions (default is -1).
  83380. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83381. */
  83382. collisionMask: number;
  83383. /**
  83384. * Gets or sets the current collision group mask (-1 by default).
  83385. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83386. */
  83387. collisionGroup: number;
  83388. /**
  83389. * Defines edge width used when edgesRenderer is enabled
  83390. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83391. */
  83392. edgesWidth: number;
  83393. /**
  83394. * Defines edge color used when edgesRenderer is enabled
  83395. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83396. */
  83397. edgesColor: Color4;
  83398. /** @hidden */
  83399. _edgesRenderer: Nullable<IEdgesRenderer>;
  83400. /** @hidden */
  83401. _masterMesh: Nullable<AbstractMesh>;
  83402. /** @hidden */
  83403. _boundingInfo: Nullable<BoundingInfo>;
  83404. /** @hidden */
  83405. _renderId: number;
  83406. /**
  83407. * Gets or sets the list of subMeshes
  83408. * @see http://doc.babylonjs.com/how_to/multi_materials
  83409. */
  83410. subMeshes: SubMesh[];
  83411. /** @hidden */
  83412. _intersectionsInProgress: AbstractMesh[];
  83413. /** @hidden */
  83414. _unIndexed: boolean;
  83415. /** @hidden */
  83416. _lightSources: Light[];
  83417. /** @hidden */
  83418. readonly _positions: Nullable<Vector3[]>;
  83419. /** @hidden */
  83420. _waitingActions: any;
  83421. /** @hidden */
  83422. _waitingFreezeWorldMatrix: Nullable<boolean>;
  83423. private _skeleton;
  83424. /** @hidden */
  83425. _bonesTransformMatrices: Nullable<Float32Array>;
  83426. /**
  83427. * Gets or sets a skeleton to apply skining transformations
  83428. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  83429. */
  83430. skeleton: Nullable<Skeleton>;
  83431. /**
  83432. * An event triggered when the mesh is rebuilt.
  83433. */
  83434. onRebuildObservable: Observable<AbstractMesh>;
  83435. /**
  83436. * Creates a new AbstractMesh
  83437. * @param name defines the name of the mesh
  83438. * @param scene defines the hosting scene
  83439. */
  83440. constructor(name: string, scene?: Nullable<Scene>);
  83441. /**
  83442. * Returns the string "AbstractMesh"
  83443. * @returns "AbstractMesh"
  83444. */
  83445. getClassName(): string;
  83446. /**
  83447. * Gets a string representation of the current mesh
  83448. * @param fullDetails defines a boolean indicating if full details must be included
  83449. * @returns a string representation of the current mesh
  83450. */
  83451. toString(fullDetails?: boolean): string;
  83452. /**
  83453. * @hidden
  83454. */
  83455. protected _getEffectiveParent(): Nullable<Node>;
  83456. /** @hidden */
  83457. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83458. /** @hidden */
  83459. _rebuild(): void;
  83460. /** @hidden */
  83461. _resyncLightSources(): void;
  83462. /** @hidden */
  83463. _resyncLighSource(light: Light): void;
  83464. /** @hidden */
  83465. _unBindEffect(): void;
  83466. /** @hidden */
  83467. _removeLightSource(light: Light): void;
  83468. private _markSubMeshesAsDirty;
  83469. /** @hidden */
  83470. _markSubMeshesAsLightDirty(): void;
  83471. /** @hidden */
  83472. _markSubMeshesAsAttributesDirty(): void;
  83473. /** @hidden */
  83474. _markSubMeshesAsMiscDirty(): void;
  83475. /**
  83476. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  83477. */
  83478. scaling: Vector3;
  83479. /**
  83480. * Returns true if the mesh is blocked. Implemented by child classes
  83481. */
  83482. readonly isBlocked: boolean;
  83483. /**
  83484. * Returns the mesh itself by default. Implemented by child classes
  83485. * @param camera defines the camera to use to pick the right LOD level
  83486. * @returns the currentAbstractMesh
  83487. */
  83488. getLOD(camera: Camera): Nullable<AbstractMesh>;
  83489. /**
  83490. * Returns 0 by default. Implemented by child classes
  83491. * @returns an integer
  83492. */
  83493. getTotalVertices(): number;
  83494. /**
  83495. * Returns a positive integer : the total number of indices in this mesh geometry.
  83496. * @returns the numner of indices or zero if the mesh has no geometry.
  83497. */
  83498. getTotalIndices(): number;
  83499. /**
  83500. * Returns null by default. Implemented by child classes
  83501. * @returns null
  83502. */
  83503. getIndices(): Nullable<IndicesArray>;
  83504. /**
  83505. * Returns the array of the requested vertex data kind. Implemented by child classes
  83506. * @param kind defines the vertex data kind to use
  83507. * @returns null
  83508. */
  83509. getVerticesData(kind: string): Nullable<FloatArray>;
  83510. /**
  83511. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83512. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83513. * Note that a new underlying VertexBuffer object is created each call.
  83514. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83515. * @param kind defines vertex data kind:
  83516. * * VertexBuffer.PositionKind
  83517. * * VertexBuffer.UVKind
  83518. * * VertexBuffer.UV2Kind
  83519. * * VertexBuffer.UV3Kind
  83520. * * VertexBuffer.UV4Kind
  83521. * * VertexBuffer.UV5Kind
  83522. * * VertexBuffer.UV6Kind
  83523. * * VertexBuffer.ColorKind
  83524. * * VertexBuffer.MatricesIndicesKind
  83525. * * VertexBuffer.MatricesIndicesExtraKind
  83526. * * VertexBuffer.MatricesWeightsKind
  83527. * * VertexBuffer.MatricesWeightsExtraKind
  83528. * @param data defines the data source
  83529. * @param updatable defines if the data must be flagged as updatable (or static)
  83530. * @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
  83531. * @returns the current mesh
  83532. */
  83533. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  83534. /**
  83535. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83536. * If the mesh has no geometry, it is simply returned as it is.
  83537. * @param kind defines vertex data kind:
  83538. * * VertexBuffer.PositionKind
  83539. * * VertexBuffer.UVKind
  83540. * * VertexBuffer.UV2Kind
  83541. * * VertexBuffer.UV3Kind
  83542. * * VertexBuffer.UV4Kind
  83543. * * VertexBuffer.UV5Kind
  83544. * * VertexBuffer.UV6Kind
  83545. * * VertexBuffer.ColorKind
  83546. * * VertexBuffer.MatricesIndicesKind
  83547. * * VertexBuffer.MatricesIndicesExtraKind
  83548. * * VertexBuffer.MatricesWeightsKind
  83549. * * VertexBuffer.MatricesWeightsExtraKind
  83550. * @param data defines the data source
  83551. * @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
  83552. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  83553. * @returns the current mesh
  83554. */
  83555. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  83556. /**
  83557. * Sets the mesh indices,
  83558. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83559. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  83560. * @param totalVertices Defines the total number of vertices
  83561. * @returns the current mesh
  83562. */
  83563. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  83564. /**
  83565. * Gets a boolean indicating if specific vertex data is present
  83566. * @param kind defines the vertex data kind to use
  83567. * @returns true is data kind is present
  83568. */
  83569. isVerticesDataPresent(kind: string): boolean;
  83570. /**
  83571. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  83572. * @returns a BoundingInfo
  83573. */
  83574. getBoundingInfo(): BoundingInfo;
  83575. /**
  83576. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83577. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83578. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83579. * @returns the current mesh
  83580. */
  83581. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  83582. /**
  83583. * Overwrite the current bounding info
  83584. * @param boundingInfo defines the new bounding info
  83585. * @returns the current mesh
  83586. */
  83587. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  83588. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  83589. readonly useBones: boolean;
  83590. /** @hidden */
  83591. _preActivate(): void;
  83592. /** @hidden */
  83593. _preActivateForIntermediateRendering(renderId: number): void;
  83594. /** @hidden */
  83595. _activate(renderId: number): void;
  83596. /**
  83597. * Gets the current world matrix
  83598. * @returns a Matrix
  83599. */
  83600. getWorldMatrix(): Matrix;
  83601. /** @hidden */
  83602. _getWorldMatrixDeterminant(): number;
  83603. /**
  83604. * Perform relative position change from the point of view of behind the front of the mesh.
  83605. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83606. * Supports definition of mesh facing forward or backward
  83607. * @param amountRight defines the distance on the right axis
  83608. * @param amountUp defines the distance on the up axis
  83609. * @param amountForward defines the distance on the forward axis
  83610. * @returns the current mesh
  83611. */
  83612. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  83613. /**
  83614. * Calculate relative position change from the point of view of behind the front of the mesh.
  83615. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83616. * Supports definition of mesh facing forward or backward
  83617. * @param amountRight defines the distance on the right axis
  83618. * @param amountUp defines the distance on the up axis
  83619. * @param amountForward defines the distance on the forward axis
  83620. * @returns the new displacement vector
  83621. */
  83622. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  83623. /**
  83624. * Perform relative rotation change from the point of view of behind the front of the mesh.
  83625. * Supports definition of mesh facing forward or backward
  83626. * @param flipBack defines the flip
  83627. * @param twirlClockwise defines the twirl
  83628. * @param tiltRight defines the tilt
  83629. * @returns the current mesh
  83630. */
  83631. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  83632. /**
  83633. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  83634. * Supports definition of mesh facing forward or backward.
  83635. * @param flipBack defines the flip
  83636. * @param twirlClockwise defines the twirl
  83637. * @param tiltRight defines the tilt
  83638. * @returns the new rotation vector
  83639. */
  83640. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  83641. /**
  83642. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  83643. * @param includeDescendants Include bounding info from descendants as well (true by default)
  83644. * @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
  83645. * @returns the new bounding vectors
  83646. */
  83647. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  83648. min: Vector3;
  83649. max: Vector3;
  83650. };
  83651. /**
  83652. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83653. * This means the mesh underlying bounding box and sphere are recomputed.
  83654. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83655. * @returns the current mesh
  83656. */
  83657. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  83658. /** @hidden */
  83659. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  83660. /** @hidden */
  83661. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  83662. /** @hidden */
  83663. _updateBoundingInfo(): AbstractMesh;
  83664. /** @hidden */
  83665. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  83666. /** @hidden */
  83667. protected _afterComputeWorldMatrix(): void;
  83668. /** @hidden */
  83669. readonly _effectiveMesh: AbstractMesh;
  83670. /**
  83671. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83672. * A mesh is in the frustum if its bounding box intersects the frustum
  83673. * @param frustumPlanes defines the frustum to test
  83674. * @returns true if the mesh is in the frustum planes
  83675. */
  83676. isInFrustum(frustumPlanes: Plane[]): boolean;
  83677. /**
  83678. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  83679. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  83680. * @param frustumPlanes defines the frustum to test
  83681. * @returns true if the mesh is completely in the frustum planes
  83682. */
  83683. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83684. /**
  83685. * True if the mesh intersects another mesh or a SolidParticle object
  83686. * @param mesh defines a target mesh or SolidParticle to test
  83687. * @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)
  83688. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  83689. * @returns true if there is an intersection
  83690. */
  83691. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  83692. /**
  83693. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  83694. * @param point defines the point to test
  83695. * @returns true if there is an intersection
  83696. */
  83697. intersectsPoint(point: Vector3): boolean;
  83698. /**
  83699. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  83700. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83701. */
  83702. checkCollisions: boolean;
  83703. /**
  83704. * Gets Collider object used to compute collisions (not physics)
  83705. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83706. */
  83707. readonly collider: Collider;
  83708. /**
  83709. * Move the mesh using collision engine
  83710. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83711. * @param displacement defines the requested displacement vector
  83712. * @returns the current mesh
  83713. */
  83714. moveWithCollisions(displacement: Vector3): AbstractMesh;
  83715. private _onCollisionPositionChange;
  83716. /** @hidden */
  83717. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  83718. /** @hidden */
  83719. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  83720. /** @hidden */
  83721. _checkCollision(collider: Collider): AbstractMesh;
  83722. /** @hidden */
  83723. _generatePointsArray(): boolean;
  83724. /**
  83725. * Checks if the passed Ray intersects with the mesh
  83726. * @param ray defines the ray to use
  83727. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  83728. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  83729. * @returns the picking info
  83730. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83731. */
  83732. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  83733. /**
  83734. * Clones the current mesh
  83735. * @param name defines the mesh name
  83736. * @param newParent defines the new mesh parent
  83737. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  83738. * @returns the new mesh
  83739. */
  83740. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83741. /**
  83742. * Disposes all the submeshes of the current meshnp
  83743. * @returns the current mesh
  83744. */
  83745. releaseSubMeshes(): AbstractMesh;
  83746. /**
  83747. * Releases resources associated with this abstract mesh.
  83748. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83749. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83750. */
  83751. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83752. /**
  83753. * Adds the passed mesh as a child to the current mesh
  83754. * @param mesh defines the child mesh
  83755. * @returns the current mesh
  83756. */
  83757. addChild(mesh: AbstractMesh): AbstractMesh;
  83758. /**
  83759. * Removes the passed mesh from the current mesh children list
  83760. * @param mesh defines the child mesh
  83761. * @returns the current mesh
  83762. */
  83763. removeChild(mesh: AbstractMesh): AbstractMesh;
  83764. /** @hidden */
  83765. private _initFacetData;
  83766. /**
  83767. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  83768. * This method can be called within the render loop.
  83769. * 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
  83770. * @returns the current mesh
  83771. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83772. */
  83773. updateFacetData(): AbstractMesh;
  83774. /**
  83775. * Returns the facetLocalNormals array.
  83776. * The normals are expressed in the mesh local spac
  83777. * @returns an array of Vector3
  83778. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83779. */
  83780. getFacetLocalNormals(): Vector3[];
  83781. /**
  83782. * Returns the facetLocalPositions array.
  83783. * The facet positions are expressed in the mesh local space
  83784. * @returns an array of Vector3
  83785. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83786. */
  83787. getFacetLocalPositions(): Vector3[];
  83788. /**
  83789. * Returns the facetLocalPartioning array
  83790. * @returns an array of array of numbers
  83791. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83792. */
  83793. getFacetLocalPartitioning(): number[][];
  83794. /**
  83795. * Returns the i-th facet position in the world system.
  83796. * This method allocates a new Vector3 per call
  83797. * @param i defines the facet index
  83798. * @returns a new Vector3
  83799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83800. */
  83801. getFacetPosition(i: number): Vector3;
  83802. /**
  83803. * Sets the reference Vector3 with the i-th facet position in the world system
  83804. * @param i defines the facet index
  83805. * @param ref defines the target vector
  83806. * @returns the current mesh
  83807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83808. */
  83809. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  83810. /**
  83811. * Returns the i-th facet normal in the world system.
  83812. * This method allocates a new Vector3 per call
  83813. * @param i defines the facet index
  83814. * @returns a new Vector3
  83815. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83816. */
  83817. getFacetNormal(i: number): Vector3;
  83818. /**
  83819. * Sets the reference Vector3 with the i-th facet normal in the world system
  83820. * @param i defines the facet index
  83821. * @param ref defines the target vector
  83822. * @returns the current mesh
  83823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83824. */
  83825. getFacetNormalToRef(i: number, ref: Vector3): this;
  83826. /**
  83827. * 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)
  83828. * @param x defines x coordinate
  83829. * @param y defines y coordinate
  83830. * @param z defines z coordinate
  83831. * @returns the array of facet indexes
  83832. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83833. */
  83834. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  83835. /**
  83836. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  83837. * @param projected sets as the (x,y,z) world projection on the facet
  83838. * @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
  83839. * @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
  83840. * @param x defines x coordinate
  83841. * @param y defines y coordinate
  83842. * @param z defines z coordinate
  83843. * @returns the face index if found (or null instead)
  83844. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83845. */
  83846. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83847. /**
  83848. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  83849. * @param projected sets as the (x,y,z) local projection on the facet
  83850. * @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
  83851. * @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
  83852. * @param x defines x coordinate
  83853. * @param y defines y coordinate
  83854. * @param z defines z coordinate
  83855. * @returns the face index if found (or null instead)
  83856. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83857. */
  83858. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83859. /**
  83860. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  83861. * @returns the parameters
  83862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83863. */
  83864. getFacetDataParameters(): any;
  83865. /**
  83866. * Disables the feature FacetData and frees the related memory
  83867. * @returns the current mesh
  83868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83869. */
  83870. disableFacetData(): AbstractMesh;
  83871. /**
  83872. * Updates the AbstractMesh indices array
  83873. * @param indices defines the data source
  83874. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83875. * @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)
  83876. * @returns the current mesh
  83877. */
  83878. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  83879. /**
  83880. * Creates new normals data for the mesh
  83881. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  83882. * @returns the current mesh
  83883. */
  83884. createNormals(updatable: boolean): AbstractMesh;
  83885. /**
  83886. * Align the mesh with a normal
  83887. * @param normal defines the normal to use
  83888. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  83889. * @returns the current mesh
  83890. */
  83891. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  83892. /** @hidden */
  83893. _checkOcclusionQuery(): boolean;
  83894. }
  83895. }
  83896. declare module BABYLON {
  83897. /**
  83898. * Interface used to define ActionEvent
  83899. */
  83900. export interface IActionEvent {
  83901. /** The mesh or sprite that triggered the action */
  83902. source: any;
  83903. /** The X mouse cursor position at the time of the event */
  83904. pointerX: number;
  83905. /** The Y mouse cursor position at the time of the event */
  83906. pointerY: number;
  83907. /** The mesh that is currently pointed at (can be null) */
  83908. meshUnderPointer: Nullable<AbstractMesh>;
  83909. /** the original (browser) event that triggered the ActionEvent */
  83910. sourceEvent?: any;
  83911. /** additional data for the event */
  83912. additionalData?: any;
  83913. }
  83914. /**
  83915. * ActionEvent is the event being sent when an action is triggered.
  83916. */
  83917. export class ActionEvent implements IActionEvent {
  83918. /** The mesh or sprite that triggered the action */
  83919. source: any;
  83920. /** The X mouse cursor position at the time of the event */
  83921. pointerX: number;
  83922. /** The Y mouse cursor position at the time of the event */
  83923. pointerY: number;
  83924. /** The mesh that is currently pointed at (can be null) */
  83925. meshUnderPointer: Nullable<AbstractMesh>;
  83926. /** the original (browser) event that triggered the ActionEvent */
  83927. sourceEvent?: any;
  83928. /** additional data for the event */
  83929. additionalData?: any;
  83930. /**
  83931. * Creates a new ActionEvent
  83932. * @param source The mesh or sprite that triggered the action
  83933. * @param pointerX The X mouse cursor position at the time of the event
  83934. * @param pointerY The Y mouse cursor position at the time of the event
  83935. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  83936. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  83937. * @param additionalData additional data for the event
  83938. */
  83939. constructor(
  83940. /** The mesh or sprite that triggered the action */
  83941. source: any,
  83942. /** The X mouse cursor position at the time of the event */
  83943. pointerX: number,
  83944. /** The Y mouse cursor position at the time of the event */
  83945. pointerY: number,
  83946. /** The mesh that is currently pointed at (can be null) */
  83947. meshUnderPointer: Nullable<AbstractMesh>,
  83948. /** the original (browser) event that triggered the ActionEvent */
  83949. sourceEvent?: any,
  83950. /** additional data for the event */
  83951. additionalData?: any);
  83952. /**
  83953. * Helper function to auto-create an ActionEvent from a source mesh.
  83954. * @param source The source mesh that triggered the event
  83955. * @param evt The original (browser) event
  83956. * @param additionalData additional data for the event
  83957. * @returns the new ActionEvent
  83958. */
  83959. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  83960. /**
  83961. * Helper function to auto-create an ActionEvent from a source sprite
  83962. * @param source The source sprite that triggered the event
  83963. * @param scene Scene associated with the sprite
  83964. * @param evt The original (browser) event
  83965. * @param additionalData additional data for the event
  83966. * @returns the new ActionEvent
  83967. */
  83968. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  83969. /**
  83970. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  83971. * @param scene the scene where the event occurred
  83972. * @param evt The original (browser) event
  83973. * @returns the new ActionEvent
  83974. */
  83975. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  83976. /**
  83977. * Helper function to auto-create an ActionEvent from a primitive
  83978. * @param prim defines the target primitive
  83979. * @param pointerPos defines the pointer position
  83980. * @param evt The original (browser) event
  83981. * @param additionalData additional data for the event
  83982. * @returns the new ActionEvent
  83983. */
  83984. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  83985. }
  83986. }
  83987. declare module BABYLON {
  83988. /**
  83989. * Abstract class used to decouple action Manager from scene and meshes.
  83990. * Do not instantiate.
  83991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83992. */
  83993. export abstract class AbstractActionManager implements IDisposable {
  83994. /** Gets the list of active triggers */
  83995. static Triggers: {
  83996. [key: string]: number;
  83997. };
  83998. /** Gets the cursor to use when hovering items */
  83999. hoverCursor: string;
  84000. /** Gets the list of actions */
  84001. actions: IAction[];
  84002. /**
  84003. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  84004. */
  84005. isRecursive: boolean;
  84006. /**
  84007. * Releases all associated resources
  84008. */
  84009. abstract dispose(): void;
  84010. /**
  84011. * Does this action manager has pointer triggers
  84012. */
  84013. abstract readonly hasPointerTriggers: boolean;
  84014. /**
  84015. * Does this action manager has pick triggers
  84016. */
  84017. abstract readonly hasPickTriggers: boolean;
  84018. /**
  84019. * Process a specific trigger
  84020. * @param trigger defines the trigger to process
  84021. * @param evt defines the event details to be processed
  84022. */
  84023. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  84024. /**
  84025. * Does this action manager handles actions of any of the given triggers
  84026. * @param triggers defines the triggers to be tested
  84027. * @return a boolean indicating whether one (or more) of the triggers is handled
  84028. */
  84029. abstract hasSpecificTriggers(triggers: number[]): boolean;
  84030. /**
  84031. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  84032. * speed.
  84033. * @param triggerA defines the trigger to be tested
  84034. * @param triggerB defines the trigger to be tested
  84035. * @return a boolean indicating whether one (or more) of the triggers is handled
  84036. */
  84037. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  84038. /**
  84039. * Does this action manager handles actions of a given trigger
  84040. * @param trigger defines the trigger to be tested
  84041. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  84042. * @return whether the trigger is handled
  84043. */
  84044. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  84045. /**
  84046. * Serialize this manager to a JSON object
  84047. * @param name defines the property name to store this manager
  84048. * @returns a JSON representation of this manager
  84049. */
  84050. abstract serialize(name: string): any;
  84051. /**
  84052. * Registers an action to this action manager
  84053. * @param action defines the action to be registered
  84054. * @return the action amended (prepared) after registration
  84055. */
  84056. abstract registerAction(action: IAction): Nullable<IAction>;
  84057. /**
  84058. * Unregisters an action to this action manager
  84059. * @param action defines the action to be unregistered
  84060. * @return a boolean indicating whether the action has been unregistered
  84061. */
  84062. abstract unregisterAction(action: IAction): Boolean;
  84063. /**
  84064. * Does exist one action manager with at least one trigger
  84065. **/
  84066. static readonly HasTriggers: boolean;
  84067. /**
  84068. * Does exist one action manager with at least one pick trigger
  84069. **/
  84070. static readonly HasPickTriggers: boolean;
  84071. /**
  84072. * Does exist one action manager that handles actions of a given trigger
  84073. * @param trigger defines the trigger to be tested
  84074. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  84075. **/
  84076. static HasSpecificTrigger(trigger: number): boolean;
  84077. }
  84078. }
  84079. declare module BABYLON {
  84080. /**
  84081. * Defines how a node can be built from a string name.
  84082. */
  84083. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  84084. /**
  84085. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  84086. */
  84087. export class Node implements IBehaviorAware<Node> {
  84088. /** @hidden */
  84089. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  84090. private static _NodeConstructors;
  84091. /**
  84092. * Add a new node constructor
  84093. * @param type defines the type name of the node to construct
  84094. * @param constructorFunc defines the constructor function
  84095. */
  84096. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  84097. /**
  84098. * Returns a node constructor based on type name
  84099. * @param type defines the type name
  84100. * @param name defines the new node name
  84101. * @param scene defines the hosting scene
  84102. * @param options defines optional options to transmit to constructors
  84103. * @returns the new constructor or null
  84104. */
  84105. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  84106. /**
  84107. * Gets or sets the name of the node
  84108. */
  84109. name: string;
  84110. /**
  84111. * Gets or sets the id of the node
  84112. */
  84113. id: string;
  84114. /**
  84115. * Gets or sets the unique id of the node
  84116. */
  84117. uniqueId: number;
  84118. /**
  84119. * Gets or sets a string used to store user defined state for the node
  84120. */
  84121. state: string;
  84122. /**
  84123. * Gets or sets an object used to store user defined information for the node
  84124. */
  84125. metadata: any;
  84126. /**
  84127. * For internal use only. Please do not use.
  84128. */
  84129. reservedDataStore: any;
  84130. /**
  84131. * List of inspectable custom properties (used by the Inspector)
  84132. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84133. */
  84134. inspectableCustomProperties: IInspectable[];
  84135. /**
  84136. * Gets or sets a boolean used to define if the node must be serialized
  84137. */
  84138. doNotSerialize: boolean;
  84139. /** @hidden */
  84140. _isDisposed: boolean;
  84141. /**
  84142. * Gets a list of Animations associated with the node
  84143. */
  84144. animations: Animation[];
  84145. protected _ranges: {
  84146. [name: string]: Nullable<AnimationRange>;
  84147. };
  84148. /**
  84149. * Callback raised when the node is ready to be used
  84150. */
  84151. onReady: (node: Node) => void;
  84152. private _isEnabled;
  84153. private _isParentEnabled;
  84154. private _isReady;
  84155. /** @hidden */
  84156. _currentRenderId: number;
  84157. private _parentUpdateId;
  84158. protected _childUpdateId: number;
  84159. /** @hidden */
  84160. _waitingParentId: Nullable<string>;
  84161. /** @hidden */
  84162. _scene: Scene;
  84163. /** @hidden */
  84164. _cache: any;
  84165. private _parentNode;
  84166. private _children;
  84167. /** @hidden */
  84168. _worldMatrix: Matrix;
  84169. /** @hidden */
  84170. _worldMatrixDeterminant: number;
  84171. /** @hidden */
  84172. private _sceneRootNodesIndex;
  84173. /**
  84174. * Gets a boolean indicating if the node has been disposed
  84175. * @returns true if the node was disposed
  84176. */
  84177. isDisposed(): boolean;
  84178. /**
  84179. * Gets or sets the parent of the node (without keeping the current position in the scene)
  84180. * @see https://doc.babylonjs.com/how_to/parenting
  84181. */
  84182. parent: Nullable<Node>;
  84183. private addToSceneRootNodes;
  84184. private removeFromSceneRootNodes;
  84185. private _animationPropertiesOverride;
  84186. /**
  84187. * Gets or sets the animation properties override
  84188. */
  84189. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  84190. /**
  84191. * Gets a string idenfifying the name of the class
  84192. * @returns "Node" string
  84193. */
  84194. getClassName(): string;
  84195. /** @hidden */
  84196. readonly _isNode: boolean;
  84197. /**
  84198. * An event triggered when the mesh is disposed
  84199. */
  84200. onDisposeObservable: Observable<Node>;
  84201. private _onDisposeObserver;
  84202. /**
  84203. * Sets a callback that will be raised when the node will be disposed
  84204. */
  84205. onDispose: () => void;
  84206. /**
  84207. * Creates a new Node
  84208. * @param name the name and id to be given to this node
  84209. * @param scene the scene this node will be added to
  84210. * @param addToRootNodes the node will be added to scene.rootNodes
  84211. */
  84212. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  84213. /**
  84214. * Gets the scene of the node
  84215. * @returns a scene
  84216. */
  84217. getScene(): Scene;
  84218. /**
  84219. * Gets the engine of the node
  84220. * @returns a Engine
  84221. */
  84222. getEngine(): Engine;
  84223. private _behaviors;
  84224. /**
  84225. * Attach a behavior to the node
  84226. * @see http://doc.babylonjs.com/features/behaviour
  84227. * @param behavior defines the behavior to attach
  84228. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  84229. * @returns the current Node
  84230. */
  84231. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  84232. /**
  84233. * Remove an attached behavior
  84234. * @see http://doc.babylonjs.com/features/behaviour
  84235. * @param behavior defines the behavior to attach
  84236. * @returns the current Node
  84237. */
  84238. removeBehavior(behavior: Behavior<Node>): Node;
  84239. /**
  84240. * Gets the list of attached behaviors
  84241. * @see http://doc.babylonjs.com/features/behaviour
  84242. */
  84243. readonly behaviors: Behavior<Node>[];
  84244. /**
  84245. * Gets an attached behavior by name
  84246. * @param name defines the name of the behavior to look for
  84247. * @see http://doc.babylonjs.com/features/behaviour
  84248. * @returns null if behavior was not found else the requested behavior
  84249. */
  84250. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  84251. /**
  84252. * Returns the latest update of the World matrix
  84253. * @returns a Matrix
  84254. */
  84255. getWorldMatrix(): Matrix;
  84256. /** @hidden */
  84257. _getWorldMatrixDeterminant(): number;
  84258. /**
  84259. * Returns directly the latest state of the mesh World matrix.
  84260. * A Matrix is returned.
  84261. */
  84262. readonly worldMatrixFromCache: Matrix;
  84263. /** @hidden */
  84264. _initCache(): void;
  84265. /** @hidden */
  84266. updateCache(force?: boolean): void;
  84267. /** @hidden */
  84268. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84269. /** @hidden */
  84270. _updateCache(ignoreParentClass?: boolean): void;
  84271. /** @hidden */
  84272. _isSynchronized(): boolean;
  84273. /** @hidden */
  84274. _markSyncedWithParent(): void;
  84275. /** @hidden */
  84276. isSynchronizedWithParent(): boolean;
  84277. /** @hidden */
  84278. isSynchronized(): boolean;
  84279. /**
  84280. * Is this node ready to be used/rendered
  84281. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84282. * @return true if the node is ready
  84283. */
  84284. isReady(completeCheck?: boolean): boolean;
  84285. /**
  84286. * Is this node enabled?
  84287. * 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
  84288. * @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
  84289. * @return whether this node (and its parent) is enabled
  84290. */
  84291. isEnabled(checkAncestors?: boolean): boolean;
  84292. /** @hidden */
  84293. protected _syncParentEnabledState(): void;
  84294. /**
  84295. * Set the enabled state of this node
  84296. * @param value defines the new enabled state
  84297. */
  84298. setEnabled(value: boolean): void;
  84299. /**
  84300. * Is this node a descendant of the given node?
  84301. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  84302. * @param ancestor defines the parent node to inspect
  84303. * @returns a boolean indicating if this node is a descendant of the given node
  84304. */
  84305. isDescendantOf(ancestor: Node): boolean;
  84306. /** @hidden */
  84307. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  84308. /**
  84309. * Will return all nodes that have this node as ascendant
  84310. * @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
  84311. * @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
  84312. * @return all children nodes of all types
  84313. */
  84314. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  84315. /**
  84316. * Get all child-meshes of this node
  84317. * @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)
  84318. * @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
  84319. * @returns an array of AbstractMesh
  84320. */
  84321. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  84322. /**
  84323. * Get all direct children of this node
  84324. * @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
  84325. * @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)
  84326. * @returns an array of Node
  84327. */
  84328. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  84329. /** @hidden */
  84330. _setReady(state: boolean): void;
  84331. /**
  84332. * Get an animation by name
  84333. * @param name defines the name of the animation to look for
  84334. * @returns null if not found else the requested animation
  84335. */
  84336. getAnimationByName(name: string): Nullable<Animation>;
  84337. /**
  84338. * Creates an animation range for this node
  84339. * @param name defines the name of the range
  84340. * @param from defines the starting key
  84341. * @param to defines the end key
  84342. */
  84343. createAnimationRange(name: string, from: number, to: number): void;
  84344. /**
  84345. * Delete a specific animation range
  84346. * @param name defines the name of the range to delete
  84347. * @param deleteFrames defines if animation frames from the range must be deleted as well
  84348. */
  84349. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84350. /**
  84351. * Get an animation range by name
  84352. * @param name defines the name of the animation range to look for
  84353. * @returns null if not found else the requested animation range
  84354. */
  84355. getAnimationRange(name: string): Nullable<AnimationRange>;
  84356. /**
  84357. * Gets the list of all animation ranges defined on this node
  84358. * @returns an array
  84359. */
  84360. getAnimationRanges(): Nullable<AnimationRange>[];
  84361. /**
  84362. * Will start the animation sequence
  84363. * @param name defines the range frames for animation sequence
  84364. * @param loop defines if the animation should loop (false by default)
  84365. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  84366. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  84367. * @returns the object created for this animation. If range does not exist, it will return null
  84368. */
  84369. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84370. /**
  84371. * Serialize animation ranges into a JSON compatible object
  84372. * @returns serialization object
  84373. */
  84374. serializeAnimationRanges(): any;
  84375. /**
  84376. * Computes the world matrix of the node
  84377. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84378. * @returns the world matrix
  84379. */
  84380. computeWorldMatrix(force?: boolean): Matrix;
  84381. /**
  84382. * Releases resources associated with this node.
  84383. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84384. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84385. */
  84386. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84387. /**
  84388. * Parse animation range data from a serialization object and store them into a given node
  84389. * @param node defines where to store the animation ranges
  84390. * @param parsedNode defines the serialization object to read data from
  84391. * @param scene defines the hosting scene
  84392. */
  84393. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  84394. }
  84395. }
  84396. declare module BABYLON {
  84397. /**
  84398. * Class used to store any kind of animation
  84399. */
  84400. export class Animation {
  84401. /**Name of the animation */
  84402. name: string;
  84403. /**Property to animate */
  84404. targetProperty: string;
  84405. /**The frames per second of the animation */
  84406. framePerSecond: number;
  84407. /**The data type of the animation */
  84408. dataType: number;
  84409. /**The loop mode of the animation */
  84410. loopMode?: number | undefined;
  84411. /**Specifies if blending should be enabled */
  84412. enableBlending?: boolean | undefined;
  84413. /**
  84414. * Use matrix interpolation instead of using direct key value when animating matrices
  84415. */
  84416. static AllowMatricesInterpolation: boolean;
  84417. /**
  84418. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  84419. */
  84420. static AllowMatrixDecomposeForInterpolation: boolean;
  84421. /**
  84422. * Stores the key frames of the animation
  84423. */
  84424. private _keys;
  84425. /**
  84426. * Stores the easing function of the animation
  84427. */
  84428. private _easingFunction;
  84429. /**
  84430. * @hidden Internal use only
  84431. */
  84432. _runtimeAnimations: RuntimeAnimation[];
  84433. /**
  84434. * The set of event that will be linked to this animation
  84435. */
  84436. private _events;
  84437. /**
  84438. * Stores an array of target property paths
  84439. */
  84440. targetPropertyPath: string[];
  84441. /**
  84442. * Stores the blending speed of the animation
  84443. */
  84444. blendingSpeed: number;
  84445. /**
  84446. * Stores the animation ranges for the animation
  84447. */
  84448. private _ranges;
  84449. /**
  84450. * @hidden Internal use
  84451. */
  84452. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  84453. /**
  84454. * Sets up an animation
  84455. * @param property The property to animate
  84456. * @param animationType The animation type to apply
  84457. * @param framePerSecond The frames per second of the animation
  84458. * @param easingFunction The easing function used in the animation
  84459. * @returns The created animation
  84460. */
  84461. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  84462. /**
  84463. * Create and start an animation on a node
  84464. * @param name defines the name of the global animation that will be run on all nodes
  84465. * @param node defines the root node where the animation will take place
  84466. * @param targetProperty defines property to animate
  84467. * @param framePerSecond defines the number of frame per second yo use
  84468. * @param totalFrame defines the number of frames in total
  84469. * @param from defines the initial value
  84470. * @param to defines the final value
  84471. * @param loopMode defines which loop mode you want to use (off by default)
  84472. * @param easingFunction defines the easing function to use (linear by default)
  84473. * @param onAnimationEnd defines the callback to call when animation end
  84474. * @returns the animatable created for this animation
  84475. */
  84476. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84477. /**
  84478. * Create and start an animation on a node and its descendants
  84479. * @param name defines the name of the global animation that will be run on all nodes
  84480. * @param node defines the root node where the animation will take place
  84481. * @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
  84482. * @param targetProperty defines property to animate
  84483. * @param framePerSecond defines the number of frame per second to use
  84484. * @param totalFrame defines the number of frames in total
  84485. * @param from defines the initial value
  84486. * @param to defines the final value
  84487. * @param loopMode defines which loop mode you want to use (off by default)
  84488. * @param easingFunction defines the easing function to use (linear by default)
  84489. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84490. * @returns the list of animatables created for all nodes
  84491. * @example https://www.babylonjs-playground.com/#MH0VLI
  84492. */
  84493. 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[]>;
  84494. /**
  84495. * Creates a new animation, merges it with the existing animations and starts it
  84496. * @param name Name of the animation
  84497. * @param node Node which contains the scene that begins the animations
  84498. * @param targetProperty Specifies which property to animate
  84499. * @param framePerSecond The frames per second of the animation
  84500. * @param totalFrame The total number of frames
  84501. * @param from The frame at the beginning of the animation
  84502. * @param to The frame at the end of the animation
  84503. * @param loopMode Specifies the loop mode of the animation
  84504. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  84505. * @param onAnimationEnd Callback to run once the animation is complete
  84506. * @returns Nullable animation
  84507. */
  84508. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84509. /**
  84510. * Transition property of an host to the target Value
  84511. * @param property The property to transition
  84512. * @param targetValue The target Value of the property
  84513. * @param host The object where the property to animate belongs
  84514. * @param scene Scene used to run the animation
  84515. * @param frameRate Framerate (in frame/s) to use
  84516. * @param transition The transition type we want to use
  84517. * @param duration The duration of the animation, in milliseconds
  84518. * @param onAnimationEnd Callback trigger at the end of the animation
  84519. * @returns Nullable animation
  84520. */
  84521. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  84522. /**
  84523. * Return the array of runtime animations currently using this animation
  84524. */
  84525. readonly runtimeAnimations: RuntimeAnimation[];
  84526. /**
  84527. * Specifies if any of the runtime animations are currently running
  84528. */
  84529. readonly hasRunningRuntimeAnimations: boolean;
  84530. /**
  84531. * Initializes the animation
  84532. * @param name Name of the animation
  84533. * @param targetProperty Property to animate
  84534. * @param framePerSecond The frames per second of the animation
  84535. * @param dataType The data type of the animation
  84536. * @param loopMode The loop mode of the animation
  84537. * @param enableBlending Specifies if blending should be enabled
  84538. */
  84539. constructor(
  84540. /**Name of the animation */
  84541. name: string,
  84542. /**Property to animate */
  84543. targetProperty: string,
  84544. /**The frames per second of the animation */
  84545. framePerSecond: number,
  84546. /**The data type of the animation */
  84547. dataType: number,
  84548. /**The loop mode of the animation */
  84549. loopMode?: number | undefined,
  84550. /**Specifies if blending should be enabled */
  84551. enableBlending?: boolean | undefined);
  84552. /**
  84553. * Converts the animation to a string
  84554. * @param fullDetails support for multiple levels of logging within scene loading
  84555. * @returns String form of the animation
  84556. */
  84557. toString(fullDetails?: boolean): string;
  84558. /**
  84559. * Add an event to this animation
  84560. * @param event Event to add
  84561. */
  84562. addEvent(event: AnimationEvent): void;
  84563. /**
  84564. * Remove all events found at the given frame
  84565. * @param frame The frame to remove events from
  84566. */
  84567. removeEvents(frame: number): void;
  84568. /**
  84569. * Retrieves all the events from the animation
  84570. * @returns Events from the animation
  84571. */
  84572. getEvents(): AnimationEvent[];
  84573. /**
  84574. * Creates an animation range
  84575. * @param name Name of the animation range
  84576. * @param from Starting frame of the animation range
  84577. * @param to Ending frame of the animation
  84578. */
  84579. createRange(name: string, from: number, to: number): void;
  84580. /**
  84581. * Deletes an animation range by name
  84582. * @param name Name of the animation range to delete
  84583. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  84584. */
  84585. deleteRange(name: string, deleteFrames?: boolean): void;
  84586. /**
  84587. * Gets the animation range by name, or null if not defined
  84588. * @param name Name of the animation range
  84589. * @returns Nullable animation range
  84590. */
  84591. getRange(name: string): Nullable<AnimationRange>;
  84592. /**
  84593. * Gets the key frames from the animation
  84594. * @returns The key frames of the animation
  84595. */
  84596. getKeys(): Array<IAnimationKey>;
  84597. /**
  84598. * Gets the highest frame rate of the animation
  84599. * @returns Highest frame rate of the animation
  84600. */
  84601. getHighestFrame(): number;
  84602. /**
  84603. * Gets the easing function of the animation
  84604. * @returns Easing function of the animation
  84605. */
  84606. getEasingFunction(): IEasingFunction;
  84607. /**
  84608. * Sets the easing function of the animation
  84609. * @param easingFunction A custom mathematical formula for animation
  84610. */
  84611. setEasingFunction(easingFunction: EasingFunction): void;
  84612. /**
  84613. * Interpolates a scalar linearly
  84614. * @param startValue Start value of the animation curve
  84615. * @param endValue End value of the animation curve
  84616. * @param gradient Scalar amount to interpolate
  84617. * @returns Interpolated scalar value
  84618. */
  84619. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  84620. /**
  84621. * Interpolates a scalar cubically
  84622. * @param startValue Start value of the animation curve
  84623. * @param outTangent End tangent of the animation
  84624. * @param endValue End value of the animation curve
  84625. * @param inTangent Start tangent of the animation curve
  84626. * @param gradient Scalar amount to interpolate
  84627. * @returns Interpolated scalar value
  84628. */
  84629. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  84630. /**
  84631. * Interpolates a quaternion using a spherical linear interpolation
  84632. * @param startValue Start value of the animation curve
  84633. * @param endValue End value of the animation curve
  84634. * @param gradient Scalar amount to interpolate
  84635. * @returns Interpolated quaternion value
  84636. */
  84637. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  84638. /**
  84639. * Interpolates a quaternion cubically
  84640. * @param startValue Start value of the animation curve
  84641. * @param outTangent End tangent of the animation curve
  84642. * @param endValue End value of the animation curve
  84643. * @param inTangent Start tangent of the animation curve
  84644. * @param gradient Scalar amount to interpolate
  84645. * @returns Interpolated quaternion value
  84646. */
  84647. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  84648. /**
  84649. * Interpolates a Vector3 linearl
  84650. * @param startValue Start value of the animation curve
  84651. * @param endValue End value of the animation curve
  84652. * @param gradient Scalar amount to interpolate
  84653. * @returns Interpolated scalar value
  84654. */
  84655. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  84656. /**
  84657. * Interpolates a Vector3 cubically
  84658. * @param startValue Start value of the animation curve
  84659. * @param outTangent End tangent of the animation
  84660. * @param endValue End value of the animation curve
  84661. * @param inTangent Start tangent of the animation curve
  84662. * @param gradient Scalar amount to interpolate
  84663. * @returns InterpolatedVector3 value
  84664. */
  84665. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  84666. /**
  84667. * Interpolates a Vector2 linearly
  84668. * @param startValue Start value of the animation curve
  84669. * @param endValue End value of the animation curve
  84670. * @param gradient Scalar amount to interpolate
  84671. * @returns Interpolated Vector2 value
  84672. */
  84673. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  84674. /**
  84675. * Interpolates a Vector2 cubically
  84676. * @param startValue Start value of the animation curve
  84677. * @param outTangent End tangent of the animation
  84678. * @param endValue End value of the animation curve
  84679. * @param inTangent Start tangent of the animation curve
  84680. * @param gradient Scalar amount to interpolate
  84681. * @returns Interpolated Vector2 value
  84682. */
  84683. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  84684. /**
  84685. * Interpolates a size linearly
  84686. * @param startValue Start value of the animation curve
  84687. * @param endValue End value of the animation curve
  84688. * @param gradient Scalar amount to interpolate
  84689. * @returns Interpolated Size value
  84690. */
  84691. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  84692. /**
  84693. * Interpolates a Color3 linearly
  84694. * @param startValue Start value of the animation curve
  84695. * @param endValue End value of the animation curve
  84696. * @param gradient Scalar amount to interpolate
  84697. * @returns Interpolated Color3 value
  84698. */
  84699. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  84700. /**
  84701. * @hidden Internal use only
  84702. */
  84703. _getKeyValue(value: any): any;
  84704. /**
  84705. * @hidden Internal use only
  84706. */
  84707. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  84708. /**
  84709. * Defines the function to use to interpolate matrices
  84710. * @param startValue defines the start matrix
  84711. * @param endValue defines the end matrix
  84712. * @param gradient defines the gradient between both matrices
  84713. * @param result defines an optional target matrix where to store the interpolation
  84714. * @returns the interpolated matrix
  84715. */
  84716. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  84717. /**
  84718. * Makes a copy of the animation
  84719. * @returns Cloned animation
  84720. */
  84721. clone(): Animation;
  84722. /**
  84723. * Sets the key frames of the animation
  84724. * @param values The animation key frames to set
  84725. */
  84726. setKeys(values: Array<IAnimationKey>): void;
  84727. /**
  84728. * Serializes the animation to an object
  84729. * @returns Serialized object
  84730. */
  84731. serialize(): any;
  84732. /**
  84733. * Float animation type
  84734. */
  84735. private static _ANIMATIONTYPE_FLOAT;
  84736. /**
  84737. * Vector3 animation type
  84738. */
  84739. private static _ANIMATIONTYPE_VECTOR3;
  84740. /**
  84741. * Quaternion animation type
  84742. */
  84743. private static _ANIMATIONTYPE_QUATERNION;
  84744. /**
  84745. * Matrix animation type
  84746. */
  84747. private static _ANIMATIONTYPE_MATRIX;
  84748. /**
  84749. * Color3 animation type
  84750. */
  84751. private static _ANIMATIONTYPE_COLOR3;
  84752. /**
  84753. * Vector2 animation type
  84754. */
  84755. private static _ANIMATIONTYPE_VECTOR2;
  84756. /**
  84757. * Size animation type
  84758. */
  84759. private static _ANIMATIONTYPE_SIZE;
  84760. /**
  84761. * Relative Loop Mode
  84762. */
  84763. private static _ANIMATIONLOOPMODE_RELATIVE;
  84764. /**
  84765. * Cycle Loop Mode
  84766. */
  84767. private static _ANIMATIONLOOPMODE_CYCLE;
  84768. /**
  84769. * Constant Loop Mode
  84770. */
  84771. private static _ANIMATIONLOOPMODE_CONSTANT;
  84772. /**
  84773. * Get the float animation type
  84774. */
  84775. static readonly ANIMATIONTYPE_FLOAT: number;
  84776. /**
  84777. * Get the Vector3 animation type
  84778. */
  84779. static readonly ANIMATIONTYPE_VECTOR3: number;
  84780. /**
  84781. * Get the Vector2 animation type
  84782. */
  84783. static readonly ANIMATIONTYPE_VECTOR2: number;
  84784. /**
  84785. * Get the Size animation type
  84786. */
  84787. static readonly ANIMATIONTYPE_SIZE: number;
  84788. /**
  84789. * Get the Quaternion animation type
  84790. */
  84791. static readonly ANIMATIONTYPE_QUATERNION: number;
  84792. /**
  84793. * Get the Matrix animation type
  84794. */
  84795. static readonly ANIMATIONTYPE_MATRIX: number;
  84796. /**
  84797. * Get the Color3 animation type
  84798. */
  84799. static readonly ANIMATIONTYPE_COLOR3: number;
  84800. /**
  84801. * Get the Relative Loop Mode
  84802. */
  84803. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  84804. /**
  84805. * Get the Cycle Loop Mode
  84806. */
  84807. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  84808. /**
  84809. * Get the Constant Loop Mode
  84810. */
  84811. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  84812. /** @hidden */
  84813. static _UniversalLerp(left: any, right: any, amount: number): any;
  84814. /**
  84815. * Parses an animation object and creates an animation
  84816. * @param parsedAnimation Parsed animation object
  84817. * @returns Animation object
  84818. */
  84819. static Parse(parsedAnimation: any): Animation;
  84820. /**
  84821. * Appends the serialized animations from the source animations
  84822. * @param source Source containing the animations
  84823. * @param destination Target to store the animations
  84824. */
  84825. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  84826. }
  84827. }
  84828. declare module BABYLON {
  84829. /**
  84830. * Base class of all the textures in babylon.
  84831. * It groups all the common properties the materials, post process, lights... might need
  84832. * in order to make a correct use of the texture.
  84833. */
  84834. export class BaseTexture implements IAnimatable {
  84835. /**
  84836. * Default anisotropic filtering level for the application.
  84837. * It is set to 4 as a good tradeoff between perf and quality.
  84838. */
  84839. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  84840. /**
  84841. * Gets or sets the unique id of the texture
  84842. */
  84843. uniqueId: number;
  84844. /**
  84845. * Define the name of the texture.
  84846. */
  84847. name: string;
  84848. /**
  84849. * Gets or sets an object used to store user defined information.
  84850. */
  84851. metadata: any;
  84852. /**
  84853. * For internal use only. Please do not use.
  84854. */
  84855. reservedDataStore: any;
  84856. private _hasAlpha;
  84857. /**
  84858. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  84859. */
  84860. hasAlpha: boolean;
  84861. /**
  84862. * Defines if the alpha value should be determined via the rgb values.
  84863. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  84864. */
  84865. getAlphaFromRGB: boolean;
  84866. /**
  84867. * Intensity or strength of the texture.
  84868. * It is commonly used by materials to fine tune the intensity of the texture
  84869. */
  84870. level: number;
  84871. /**
  84872. * Define the UV chanel to use starting from 0 and defaulting to 0.
  84873. * This is part of the texture as textures usually maps to one uv set.
  84874. */
  84875. coordinatesIndex: number;
  84876. private _coordinatesMode;
  84877. /**
  84878. * How a texture is mapped.
  84879. *
  84880. * | Value | Type | Description |
  84881. * | ----- | ----------------------------------- | ----------- |
  84882. * | 0 | EXPLICIT_MODE | |
  84883. * | 1 | SPHERICAL_MODE | |
  84884. * | 2 | PLANAR_MODE | |
  84885. * | 3 | CUBIC_MODE | |
  84886. * | 4 | PROJECTION_MODE | |
  84887. * | 5 | SKYBOX_MODE | |
  84888. * | 6 | INVCUBIC_MODE | |
  84889. * | 7 | EQUIRECTANGULAR_MODE | |
  84890. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  84891. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  84892. */
  84893. coordinatesMode: number;
  84894. /**
  84895. * | Value | Type | Description |
  84896. * | ----- | ------------------ | ----------- |
  84897. * | 0 | CLAMP_ADDRESSMODE | |
  84898. * | 1 | WRAP_ADDRESSMODE | |
  84899. * | 2 | MIRROR_ADDRESSMODE | |
  84900. */
  84901. wrapU: number;
  84902. /**
  84903. * | Value | Type | Description |
  84904. * | ----- | ------------------ | ----------- |
  84905. * | 0 | CLAMP_ADDRESSMODE | |
  84906. * | 1 | WRAP_ADDRESSMODE | |
  84907. * | 2 | MIRROR_ADDRESSMODE | |
  84908. */
  84909. wrapV: number;
  84910. /**
  84911. * | Value | Type | Description |
  84912. * | ----- | ------------------ | ----------- |
  84913. * | 0 | CLAMP_ADDRESSMODE | |
  84914. * | 1 | WRAP_ADDRESSMODE | |
  84915. * | 2 | MIRROR_ADDRESSMODE | |
  84916. */
  84917. wrapR: number;
  84918. /**
  84919. * With compliant hardware and browser (supporting anisotropic filtering)
  84920. * this defines the level of anisotropic filtering in the texture.
  84921. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  84922. */
  84923. anisotropicFilteringLevel: number;
  84924. /**
  84925. * Define if the texture is a cube texture or if false a 2d texture.
  84926. */
  84927. isCube: boolean;
  84928. /**
  84929. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  84930. */
  84931. is3D: boolean;
  84932. /**
  84933. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  84934. * HDR texture are usually stored in linear space.
  84935. * This only impacts the PBR and Background materials
  84936. */
  84937. gammaSpace: boolean;
  84938. /**
  84939. * Gets whether or not the texture contains RGBD data.
  84940. */
  84941. readonly isRGBD: boolean;
  84942. /**
  84943. * Is Z inverted in the texture (useful in a cube texture).
  84944. */
  84945. invertZ: boolean;
  84946. /**
  84947. * Are mip maps generated for this texture or not.
  84948. */
  84949. readonly noMipmap: boolean;
  84950. /**
  84951. * @hidden
  84952. */
  84953. lodLevelInAlpha: boolean;
  84954. /**
  84955. * With prefiltered texture, defined the offset used during the prefiltering steps.
  84956. */
  84957. lodGenerationOffset: number;
  84958. /**
  84959. * With prefiltered texture, defined the scale used during the prefiltering steps.
  84960. */
  84961. lodGenerationScale: number;
  84962. /**
  84963. * Define if the texture is a render target.
  84964. */
  84965. isRenderTarget: boolean;
  84966. /**
  84967. * Define the unique id of the texture in the scene.
  84968. */
  84969. readonly uid: string;
  84970. /**
  84971. * Return a string representation of the texture.
  84972. * @returns the texture as a string
  84973. */
  84974. toString(): string;
  84975. /**
  84976. * Get the class name of the texture.
  84977. * @returns "BaseTexture"
  84978. */
  84979. getClassName(): string;
  84980. /**
  84981. * Define the list of animation attached to the texture.
  84982. */
  84983. animations: Animation[];
  84984. /**
  84985. * An event triggered when the texture is disposed.
  84986. */
  84987. onDisposeObservable: Observable<BaseTexture>;
  84988. private _onDisposeObserver;
  84989. /**
  84990. * Callback triggered when the texture has been disposed.
  84991. * Kept for back compatibility, you can use the onDisposeObservable instead.
  84992. */
  84993. onDispose: () => void;
  84994. /**
  84995. * Define the current state of the loading sequence when in delayed load mode.
  84996. */
  84997. delayLoadState: number;
  84998. private _scene;
  84999. /** @hidden */
  85000. _texture: Nullable<InternalTexture>;
  85001. private _uid;
  85002. /**
  85003. * Define if the texture is preventinga material to render or not.
  85004. * If not and the texture is not ready, the engine will use a default black texture instead.
  85005. */
  85006. readonly isBlocking: boolean;
  85007. /**
  85008. * Instantiates a new BaseTexture.
  85009. * Base class of all the textures in babylon.
  85010. * It groups all the common properties the materials, post process, lights... might need
  85011. * in order to make a correct use of the texture.
  85012. * @param scene Define the scene the texture blongs to
  85013. */
  85014. constructor(scene: Nullable<Scene>);
  85015. /**
  85016. * Get the scene the texture belongs to.
  85017. * @returns the scene or null if undefined
  85018. */
  85019. getScene(): Nullable<Scene>;
  85020. /**
  85021. * Get the texture transform matrix used to offset tile the texture for istance.
  85022. * @returns the transformation matrix
  85023. */
  85024. getTextureMatrix(): Matrix;
  85025. /**
  85026. * Get the texture reflection matrix used to rotate/transform the reflection.
  85027. * @returns the reflection matrix
  85028. */
  85029. getReflectionTextureMatrix(): Matrix;
  85030. /**
  85031. * Get the underlying lower level texture from Babylon.
  85032. * @returns the insternal texture
  85033. */
  85034. getInternalTexture(): Nullable<InternalTexture>;
  85035. /**
  85036. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  85037. * @returns true if ready or not blocking
  85038. */
  85039. isReadyOrNotBlocking(): boolean;
  85040. /**
  85041. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  85042. * @returns true if fully ready
  85043. */
  85044. isReady(): boolean;
  85045. private _cachedSize;
  85046. /**
  85047. * Get the size of the texture.
  85048. * @returns the texture size.
  85049. */
  85050. getSize(): ISize;
  85051. /**
  85052. * Get the base size of the texture.
  85053. * It can be different from the size if the texture has been resized for POT for instance
  85054. * @returns the base size
  85055. */
  85056. getBaseSize(): ISize;
  85057. /**
  85058. * Update the sampling mode of the texture.
  85059. * Default is Trilinear mode.
  85060. *
  85061. * | Value | Type | Description |
  85062. * | ----- | ------------------ | ----------- |
  85063. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  85064. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  85065. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  85066. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  85067. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  85068. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  85069. * | 7 | NEAREST_LINEAR | |
  85070. * | 8 | NEAREST_NEAREST | |
  85071. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  85072. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  85073. * | 11 | LINEAR_LINEAR | |
  85074. * | 12 | LINEAR_NEAREST | |
  85075. *
  85076. * > _mag_: magnification filter (close to the viewer)
  85077. * > _min_: minification filter (far from the viewer)
  85078. * > _mip_: filter used between mip map levels
  85079. *@param samplingMode Define the new sampling mode of the texture
  85080. */
  85081. updateSamplingMode(samplingMode: number): void;
  85082. /**
  85083. * Scales the texture if is `canRescale()`
  85084. * @param ratio the resize factor we want to use to rescale
  85085. */
  85086. scale(ratio: number): void;
  85087. /**
  85088. * Get if the texture can rescale.
  85089. */
  85090. readonly canRescale: boolean;
  85091. /** @hidden */
  85092. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  85093. /** @hidden */
  85094. _rebuild(): void;
  85095. /**
  85096. * Triggers the load sequence in delayed load mode.
  85097. */
  85098. delayLoad(): void;
  85099. /**
  85100. * Clones the texture.
  85101. * @returns the cloned texture
  85102. */
  85103. clone(): Nullable<BaseTexture>;
  85104. /**
  85105. * Get the texture underlying type (INT, FLOAT...)
  85106. */
  85107. readonly textureType: number;
  85108. /**
  85109. * Get the texture underlying format (RGB, RGBA...)
  85110. */
  85111. readonly textureFormat: number;
  85112. /**
  85113. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  85114. * This will returns an RGBA array buffer containing either in values (0-255) or
  85115. * float values (0-1) depending of the underlying buffer type.
  85116. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  85117. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  85118. * @param buffer defines a user defined buffer to fill with data (can be null)
  85119. * @returns The Array buffer containing the pixels data.
  85120. */
  85121. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  85122. /**
  85123. * Release and destroy the underlying lower level texture aka internalTexture.
  85124. */
  85125. releaseInternalTexture(): void;
  85126. /**
  85127. * Get the polynomial representation of the texture data.
  85128. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  85129. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  85130. */
  85131. sphericalPolynomial: Nullable<SphericalPolynomial>;
  85132. /** @hidden */
  85133. readonly _lodTextureHigh: Nullable<BaseTexture>;
  85134. /** @hidden */
  85135. readonly _lodTextureMid: Nullable<BaseTexture>;
  85136. /** @hidden */
  85137. readonly _lodTextureLow: Nullable<BaseTexture>;
  85138. /**
  85139. * Dispose the texture and release its associated resources.
  85140. */
  85141. dispose(): void;
  85142. /**
  85143. * Serialize the texture into a JSON representation that can be parsed later on.
  85144. * @returns the JSON representation of the texture
  85145. */
  85146. serialize(): any;
  85147. /**
  85148. * Helper function to be called back once a list of texture contains only ready textures.
  85149. * @param textures Define the list of textures to wait for
  85150. * @param callback Define the callback triggered once the entire list will be ready
  85151. */
  85152. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  85153. }
  85154. }
  85155. declare module BABYLON {
  85156. /**
  85157. * Uniform buffer objects.
  85158. *
  85159. * Handles blocks of uniform on the GPU.
  85160. *
  85161. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85162. *
  85163. * For more information, please refer to :
  85164. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85165. */
  85166. export class UniformBuffer {
  85167. private _engine;
  85168. private _buffer;
  85169. private _data;
  85170. private _bufferData;
  85171. private _dynamic?;
  85172. private _uniformLocations;
  85173. private _uniformSizes;
  85174. private _uniformLocationPointer;
  85175. private _needSync;
  85176. private _noUBO;
  85177. private _currentEffect;
  85178. private static _MAX_UNIFORM_SIZE;
  85179. private static _tempBuffer;
  85180. /**
  85181. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85182. * This is dynamic to allow compat with webgl 1 and 2.
  85183. * You will need to pass the name of the uniform as well as the value.
  85184. */
  85185. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85186. /**
  85187. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85188. * This is dynamic to allow compat with webgl 1 and 2.
  85189. * You will need to pass the name of the uniform as well as the value.
  85190. */
  85191. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85192. /**
  85193. * Lambda to Update a single float in a uniform buffer.
  85194. * This is dynamic to allow compat with webgl 1 and 2.
  85195. * You will need to pass the name of the uniform as well as the value.
  85196. */
  85197. updateFloat: (name: string, x: number) => void;
  85198. /**
  85199. * Lambda to Update a vec2 of float in a uniform buffer.
  85200. * This is dynamic to allow compat with webgl 1 and 2.
  85201. * You will need to pass the name of the uniform as well as the value.
  85202. */
  85203. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85204. /**
  85205. * Lambda to Update a vec3 of float in a uniform buffer.
  85206. * This is dynamic to allow compat with webgl 1 and 2.
  85207. * You will need to pass the name of the uniform as well as the value.
  85208. */
  85209. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85210. /**
  85211. * Lambda to Update a vec4 of float in a uniform buffer.
  85212. * This is dynamic to allow compat with webgl 1 and 2.
  85213. * You will need to pass the name of the uniform as well as the value.
  85214. */
  85215. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85216. /**
  85217. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85218. * This is dynamic to allow compat with webgl 1 and 2.
  85219. * You will need to pass the name of the uniform as well as the value.
  85220. */
  85221. updateMatrix: (name: string, mat: Matrix) => void;
  85222. /**
  85223. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85224. * This is dynamic to allow compat with webgl 1 and 2.
  85225. * You will need to pass the name of the uniform as well as the value.
  85226. */
  85227. updateVector3: (name: string, vector: Vector3) => void;
  85228. /**
  85229. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85230. * This is dynamic to allow compat with webgl 1 and 2.
  85231. * You will need to pass the name of the uniform as well as the value.
  85232. */
  85233. updateVector4: (name: string, vector: Vector4) => void;
  85234. /**
  85235. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85236. * This is dynamic to allow compat with webgl 1 and 2.
  85237. * You will need to pass the name of the uniform as well as the value.
  85238. */
  85239. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85240. /**
  85241. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85242. * This is dynamic to allow compat with webgl 1 and 2.
  85243. * You will need to pass the name of the uniform as well as the value.
  85244. */
  85245. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85246. /**
  85247. * Instantiates a new Uniform buffer objects.
  85248. *
  85249. * Handles blocks of uniform on the GPU.
  85250. *
  85251. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85252. *
  85253. * For more information, please refer to :
  85254. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85255. * @param engine Define the engine the buffer is associated with
  85256. * @param data Define the data contained in the buffer
  85257. * @param dynamic Define if the buffer is updatable
  85258. */
  85259. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85260. /**
  85261. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85262. * or just falling back on setUniformXXX calls.
  85263. */
  85264. readonly useUbo: boolean;
  85265. /**
  85266. * Indicates if the WebGL underlying uniform buffer is in sync
  85267. * with the javascript cache data.
  85268. */
  85269. readonly isSync: boolean;
  85270. /**
  85271. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85272. * Also, a dynamic UniformBuffer will disable cache verification and always
  85273. * update the underlying WebGL uniform buffer to the GPU.
  85274. * @returns if Dynamic, otherwise false
  85275. */
  85276. isDynamic(): boolean;
  85277. /**
  85278. * The data cache on JS side.
  85279. * @returns the underlying data as a float array
  85280. */
  85281. getData(): Float32Array;
  85282. /**
  85283. * The underlying WebGL Uniform buffer.
  85284. * @returns the webgl buffer
  85285. */
  85286. getBuffer(): Nullable<WebGLBuffer>;
  85287. /**
  85288. * std140 layout specifies how to align data within an UBO structure.
  85289. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85290. * for specs.
  85291. */
  85292. private _fillAlignment;
  85293. /**
  85294. * Adds an uniform in the buffer.
  85295. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85296. * for the layout to be correct !
  85297. * @param name Name of the uniform, as used in the uniform block in the shader.
  85298. * @param size Data size, or data directly.
  85299. */
  85300. addUniform(name: string, size: number | number[]): void;
  85301. /**
  85302. * Adds a Matrix 4x4 to the uniform buffer.
  85303. * @param name Name of the uniform, as used in the uniform block in the shader.
  85304. * @param mat A 4x4 matrix.
  85305. */
  85306. addMatrix(name: string, mat: Matrix): void;
  85307. /**
  85308. * Adds a vec2 to the uniform buffer.
  85309. * @param name Name of the uniform, as used in the uniform block in the shader.
  85310. * @param x Define the x component value of the vec2
  85311. * @param y Define the y component value of the vec2
  85312. */
  85313. addFloat2(name: string, x: number, y: number): void;
  85314. /**
  85315. * Adds a vec3 to the uniform buffer.
  85316. * @param name Name of the uniform, as used in the uniform block in the shader.
  85317. * @param x Define the x component value of the vec3
  85318. * @param y Define the y component value of the vec3
  85319. * @param z Define the z component value of the vec3
  85320. */
  85321. addFloat3(name: string, x: number, y: number, z: number): void;
  85322. /**
  85323. * Adds a vec3 to the uniform buffer.
  85324. * @param name Name of the uniform, as used in the uniform block in the shader.
  85325. * @param color Define the vec3 from a Color
  85326. */
  85327. addColor3(name: string, color: Color3): void;
  85328. /**
  85329. * Adds a vec4 to the uniform buffer.
  85330. * @param name Name of the uniform, as used in the uniform block in the shader.
  85331. * @param color Define the rgb components from a Color
  85332. * @param alpha Define the a component of the vec4
  85333. */
  85334. addColor4(name: string, color: Color3, alpha: number): void;
  85335. /**
  85336. * Adds a vec3 to the uniform buffer.
  85337. * @param name Name of the uniform, as used in the uniform block in the shader.
  85338. * @param vector Define the vec3 components from a Vector
  85339. */
  85340. addVector3(name: string, vector: Vector3): void;
  85341. /**
  85342. * Adds a Matrix 3x3 to the uniform buffer.
  85343. * @param name Name of the uniform, as used in the uniform block in the shader.
  85344. */
  85345. addMatrix3x3(name: string): void;
  85346. /**
  85347. * Adds a Matrix 2x2 to the uniform buffer.
  85348. * @param name Name of the uniform, as used in the uniform block in the shader.
  85349. */
  85350. addMatrix2x2(name: string): void;
  85351. /**
  85352. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85353. */
  85354. create(): void;
  85355. /** @hidden */
  85356. _rebuild(): void;
  85357. /**
  85358. * Updates the WebGL Uniform Buffer on the GPU.
  85359. * If the `dynamic` flag is set to true, no cache comparison is done.
  85360. * Otherwise, the buffer will be updated only if the cache differs.
  85361. */
  85362. update(): void;
  85363. /**
  85364. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85365. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85366. * @param data Define the flattened data
  85367. * @param size Define the size of the data.
  85368. */
  85369. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85370. private _updateMatrix3x3ForUniform;
  85371. private _updateMatrix3x3ForEffect;
  85372. private _updateMatrix2x2ForEffect;
  85373. private _updateMatrix2x2ForUniform;
  85374. private _updateFloatForEffect;
  85375. private _updateFloatForUniform;
  85376. private _updateFloat2ForEffect;
  85377. private _updateFloat2ForUniform;
  85378. private _updateFloat3ForEffect;
  85379. private _updateFloat3ForUniform;
  85380. private _updateFloat4ForEffect;
  85381. private _updateFloat4ForUniform;
  85382. private _updateMatrixForEffect;
  85383. private _updateMatrixForUniform;
  85384. private _updateVector3ForEffect;
  85385. private _updateVector3ForUniform;
  85386. private _updateVector4ForEffect;
  85387. private _updateVector4ForUniform;
  85388. private _updateColor3ForEffect;
  85389. private _updateColor3ForUniform;
  85390. private _updateColor4ForEffect;
  85391. private _updateColor4ForUniform;
  85392. /**
  85393. * Sets a sampler uniform on the effect.
  85394. * @param name Define the name of the sampler.
  85395. * @param texture Define the texture to set in the sampler
  85396. */
  85397. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85398. /**
  85399. * Directly updates the value of the uniform in the cache AND on the GPU.
  85400. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85401. * @param data Define the flattened data
  85402. */
  85403. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85404. /**
  85405. * Binds this uniform buffer to an effect.
  85406. * @param effect Define the effect to bind the buffer to
  85407. * @param name Name of the uniform block in the shader.
  85408. */
  85409. bindToEffect(effect: Effect, name: string): void;
  85410. /**
  85411. * Disposes the uniform buffer.
  85412. */
  85413. dispose(): void;
  85414. }
  85415. }
  85416. declare module BABYLON {
  85417. /**
  85418. * This represents the required contract to create a new type of texture loader.
  85419. */
  85420. export interface IInternalTextureLoader {
  85421. /**
  85422. * Defines wether the loader supports cascade loading the different faces.
  85423. */
  85424. supportCascades: boolean;
  85425. /**
  85426. * This returns if the loader support the current file information.
  85427. * @param extension defines the file extension of the file being loaded
  85428. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85429. * @param fallback defines the fallback internal texture if any
  85430. * @param isBase64 defines whether the texture is encoded as a base64
  85431. * @param isBuffer defines whether the texture data are stored as a buffer
  85432. * @returns true if the loader can load the specified file
  85433. */
  85434. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  85435. /**
  85436. * Transform the url before loading if required.
  85437. * @param rootUrl the url of the texture
  85438. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85439. * @returns the transformed texture
  85440. */
  85441. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  85442. /**
  85443. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  85444. * @param rootUrl the url of the texture
  85445. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85446. * @returns the fallback texture
  85447. */
  85448. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  85449. /**
  85450. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  85451. * @param data contains the texture data
  85452. * @param texture defines the BabylonJS internal texture
  85453. * @param createPolynomials will be true if polynomials have been requested
  85454. * @param onLoad defines the callback to trigger once the texture is ready
  85455. * @param onError defines the callback to trigger in case of error
  85456. */
  85457. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  85458. /**
  85459. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  85460. * @param data contains the texture data
  85461. * @param texture defines the BabylonJS internal texture
  85462. * @param callback defines the method to call once ready to upload
  85463. */
  85464. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  85465. }
  85466. }
  85467. declare module BABYLON {
  85468. /**
  85469. * Creation options of the multi render target texture.
  85470. */
  85471. export interface IMultiRenderTargetOptions {
  85472. /**
  85473. * Define if the texture needs to create mip maps after render.
  85474. */
  85475. generateMipMaps?: boolean;
  85476. /**
  85477. * Define the types of all the draw buffers we want to create
  85478. */
  85479. types?: number[];
  85480. /**
  85481. * Define the sampling modes of all the draw buffers we want to create
  85482. */
  85483. samplingModes?: number[];
  85484. /**
  85485. * Define if a depth buffer is required
  85486. */
  85487. generateDepthBuffer?: boolean;
  85488. /**
  85489. * Define if a stencil buffer is required
  85490. */
  85491. generateStencilBuffer?: boolean;
  85492. /**
  85493. * Define if a depth texture is required instead of a depth buffer
  85494. */
  85495. generateDepthTexture?: boolean;
  85496. /**
  85497. * Define the number of desired draw buffers
  85498. */
  85499. textureCount?: number;
  85500. /**
  85501. * Define if aspect ratio should be adapted to the texture or stay the scene one
  85502. */
  85503. doNotChangeAspectRatio?: boolean;
  85504. /**
  85505. * Define the default type of the buffers we are creating
  85506. */
  85507. defaultType?: number;
  85508. }
  85509. /**
  85510. * A multi render target, like a render target provides the ability to render to a texture.
  85511. * Unlike the render target, it can render to several draw buffers in one draw.
  85512. * This is specially interesting in deferred rendering or for any effects requiring more than
  85513. * just one color from a single pass.
  85514. */
  85515. export class MultiRenderTarget extends RenderTargetTexture {
  85516. private _internalTextures;
  85517. private _textures;
  85518. private _multiRenderTargetOptions;
  85519. /**
  85520. * Get if draw buffers are currently supported by the used hardware and browser.
  85521. */
  85522. readonly isSupported: boolean;
  85523. /**
  85524. * Get the list of textures generated by the multi render target.
  85525. */
  85526. readonly textures: Texture[];
  85527. /**
  85528. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  85529. */
  85530. readonly depthTexture: Texture;
  85531. /**
  85532. * Set the wrapping mode on U of all the textures we are rendering to.
  85533. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85534. */
  85535. wrapU: number;
  85536. /**
  85537. * Set the wrapping mode on V of all the textures we are rendering to.
  85538. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85539. */
  85540. wrapV: number;
  85541. /**
  85542. * Instantiate a new multi render target texture.
  85543. * A multi render target, like a render target provides the ability to render to a texture.
  85544. * Unlike the render target, it can render to several draw buffers in one draw.
  85545. * This is specially interesting in deferred rendering or for any effects requiring more than
  85546. * just one color from a single pass.
  85547. * @param name Define the name of the texture
  85548. * @param size Define the size of the buffers to render to
  85549. * @param count Define the number of target we are rendering into
  85550. * @param scene Define the scene the texture belongs to
  85551. * @param options Define the options used to create the multi render target
  85552. */
  85553. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  85554. /** @hidden */
  85555. _rebuild(): void;
  85556. private _createInternalTextures;
  85557. private _createTextures;
  85558. /**
  85559. * Define the number of samples used if MSAA is enabled.
  85560. */
  85561. samples: number;
  85562. /**
  85563. * Resize all the textures in the multi render target.
  85564. * Be carrefull as it will recreate all the data in the new texture.
  85565. * @param size Define the new size
  85566. */
  85567. resize(size: any): void;
  85568. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85569. /**
  85570. * Dispose the render targets and their associated resources
  85571. */
  85572. dispose(): void;
  85573. /**
  85574. * Release all the underlying texture used as draw buffers.
  85575. */
  85576. releaseInternalTextures(): void;
  85577. }
  85578. }
  85579. declare module BABYLON {
  85580. /**
  85581. * Class used to work with sound analyzer using fast fourier transform (FFT)
  85582. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85583. */
  85584. export class Analyser {
  85585. /**
  85586. * Gets or sets the smoothing
  85587. * @ignorenaming
  85588. */
  85589. SMOOTHING: number;
  85590. /**
  85591. * Gets or sets the FFT table size
  85592. * @ignorenaming
  85593. */
  85594. FFT_SIZE: number;
  85595. /**
  85596. * Gets or sets the bar graph amplitude
  85597. * @ignorenaming
  85598. */
  85599. BARGRAPHAMPLITUDE: number;
  85600. /**
  85601. * Gets or sets the position of the debug canvas
  85602. * @ignorenaming
  85603. */
  85604. DEBUGCANVASPOS: {
  85605. x: number;
  85606. y: number;
  85607. };
  85608. /**
  85609. * Gets or sets the debug canvas size
  85610. * @ignorenaming
  85611. */
  85612. DEBUGCANVASSIZE: {
  85613. width: number;
  85614. height: number;
  85615. };
  85616. private _byteFreqs;
  85617. private _byteTime;
  85618. private _floatFreqs;
  85619. private _webAudioAnalyser;
  85620. private _debugCanvas;
  85621. private _debugCanvasContext;
  85622. private _scene;
  85623. private _registerFunc;
  85624. private _audioEngine;
  85625. /**
  85626. * Creates a new analyser
  85627. * @param scene defines hosting scene
  85628. */
  85629. constructor(scene: Scene);
  85630. /**
  85631. * Get the number of data values you will have to play with for the visualization
  85632. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  85633. * @returns a number
  85634. */
  85635. getFrequencyBinCount(): number;
  85636. /**
  85637. * Gets the current frequency data as a byte array
  85638. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85639. * @returns a Uint8Array
  85640. */
  85641. getByteFrequencyData(): Uint8Array;
  85642. /**
  85643. * Gets the current waveform as a byte array
  85644. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  85645. * @returns a Uint8Array
  85646. */
  85647. getByteTimeDomainData(): Uint8Array;
  85648. /**
  85649. * Gets the current frequency data as a float array
  85650. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85651. * @returns a Float32Array
  85652. */
  85653. getFloatFrequencyData(): Float32Array;
  85654. /**
  85655. * Renders the debug canvas
  85656. */
  85657. drawDebugCanvas(): void;
  85658. /**
  85659. * Stops rendering the debug canvas and removes it
  85660. */
  85661. stopDebugCanvas(): void;
  85662. /**
  85663. * Connects two audio nodes
  85664. * @param inputAudioNode defines first node to connect
  85665. * @param outputAudioNode defines second node to connect
  85666. */
  85667. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  85668. /**
  85669. * Releases all associated resources
  85670. */
  85671. dispose(): void;
  85672. }
  85673. }
  85674. declare module BABYLON {
  85675. /**
  85676. * This represents an audio engine and it is responsible
  85677. * to play, synchronize and analyse sounds throughout the application.
  85678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85679. */
  85680. export interface IAudioEngine extends IDisposable {
  85681. /**
  85682. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85683. */
  85684. readonly canUseWebAudio: boolean;
  85685. /**
  85686. * Gets the current AudioContext if available.
  85687. */
  85688. readonly audioContext: Nullable<AudioContext>;
  85689. /**
  85690. * The master gain node defines the global audio volume of your audio engine.
  85691. */
  85692. readonly masterGain: GainNode;
  85693. /**
  85694. * Gets whether or not mp3 are supported by your browser.
  85695. */
  85696. readonly isMP3supported: boolean;
  85697. /**
  85698. * Gets whether or not ogg are supported by your browser.
  85699. */
  85700. readonly isOGGsupported: boolean;
  85701. /**
  85702. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85703. * @ignoreNaming
  85704. */
  85705. WarnedWebAudioUnsupported: boolean;
  85706. /**
  85707. * Defines if the audio engine relies on a custom unlocked button.
  85708. * In this case, the embedded button will not be displayed.
  85709. */
  85710. useCustomUnlockedButton: boolean;
  85711. /**
  85712. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  85713. */
  85714. readonly unlocked: boolean;
  85715. /**
  85716. * Event raised when audio has been unlocked on the browser.
  85717. */
  85718. onAudioUnlockedObservable: Observable<AudioEngine>;
  85719. /**
  85720. * Event raised when audio has been locked on the browser.
  85721. */
  85722. onAudioLockedObservable: Observable<AudioEngine>;
  85723. /**
  85724. * Flags the audio engine in Locked state.
  85725. * This happens due to new browser policies preventing audio to autoplay.
  85726. */
  85727. lock(): void;
  85728. /**
  85729. * Unlocks the audio engine once a user action has been done on the dom.
  85730. * This is helpful to resume play once browser policies have been satisfied.
  85731. */
  85732. unlock(): void;
  85733. }
  85734. /**
  85735. * This represents the default audio engine used in babylon.
  85736. * It is responsible to play, synchronize and analyse sounds throughout the application.
  85737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85738. */
  85739. export class AudioEngine implements IAudioEngine {
  85740. private _audioContext;
  85741. private _audioContextInitialized;
  85742. private _muteButton;
  85743. private _hostElement;
  85744. /**
  85745. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85746. */
  85747. canUseWebAudio: boolean;
  85748. /**
  85749. * The master gain node defines the global audio volume of your audio engine.
  85750. */
  85751. masterGain: GainNode;
  85752. /**
  85753. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85754. * @ignoreNaming
  85755. */
  85756. WarnedWebAudioUnsupported: boolean;
  85757. /**
  85758. * Gets whether or not mp3 are supported by your browser.
  85759. */
  85760. isMP3supported: boolean;
  85761. /**
  85762. * Gets whether or not ogg are supported by your browser.
  85763. */
  85764. isOGGsupported: boolean;
  85765. /**
  85766. * Gets whether audio has been unlocked on the device.
  85767. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  85768. * a user interaction has happened.
  85769. */
  85770. unlocked: boolean;
  85771. /**
  85772. * Defines if the audio engine relies on a custom unlocked button.
  85773. * In this case, the embedded button will not be displayed.
  85774. */
  85775. useCustomUnlockedButton: boolean;
  85776. /**
  85777. * Event raised when audio has been unlocked on the browser.
  85778. */
  85779. onAudioUnlockedObservable: Observable<AudioEngine>;
  85780. /**
  85781. * Event raised when audio has been locked on the browser.
  85782. */
  85783. onAudioLockedObservable: Observable<AudioEngine>;
  85784. /**
  85785. * Gets the current AudioContext if available.
  85786. */
  85787. readonly audioContext: Nullable<AudioContext>;
  85788. private _connectedAnalyser;
  85789. /**
  85790. * Instantiates a new audio engine.
  85791. *
  85792. * There should be only one per page as some browsers restrict the number
  85793. * of audio contexts you can create.
  85794. * @param hostElement defines the host element where to display the mute icon if necessary
  85795. */
  85796. constructor(hostElement?: Nullable<HTMLElement>);
  85797. /**
  85798. * Flags the audio engine in Locked state.
  85799. * This happens due to new browser policies preventing audio to autoplay.
  85800. */
  85801. lock(): void;
  85802. /**
  85803. * Unlocks the audio engine once a user action has been done on the dom.
  85804. * This is helpful to resume play once browser policies have been satisfied.
  85805. */
  85806. unlock(): void;
  85807. private _resumeAudioContext;
  85808. private _initializeAudioContext;
  85809. private _tryToRun;
  85810. private _triggerRunningState;
  85811. private _triggerSuspendedState;
  85812. private _displayMuteButton;
  85813. private _moveButtonToTopLeft;
  85814. private _onResize;
  85815. private _hideMuteButton;
  85816. /**
  85817. * Destroy and release the resources associated with the audio ccontext.
  85818. */
  85819. dispose(): void;
  85820. /**
  85821. * Gets the global volume sets on the master gain.
  85822. * @returns the global volume if set or -1 otherwise
  85823. */
  85824. getGlobalVolume(): number;
  85825. /**
  85826. * Sets the global volume of your experience (sets on the master gain).
  85827. * @param newVolume Defines the new global volume of the application
  85828. */
  85829. setGlobalVolume(newVolume: number): void;
  85830. /**
  85831. * Connect the audio engine to an audio analyser allowing some amazing
  85832. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  85833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  85834. * @param analyser The analyser to connect to the engine
  85835. */
  85836. connectToAnalyser(analyser: Analyser): void;
  85837. }
  85838. }
  85839. declare module BABYLON {
  85840. /**
  85841. * Interface used to present a loading screen while loading a scene
  85842. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85843. */
  85844. export interface ILoadingScreen {
  85845. /**
  85846. * Function called to display the loading screen
  85847. */
  85848. displayLoadingUI: () => void;
  85849. /**
  85850. * Function called to hide the loading screen
  85851. */
  85852. hideLoadingUI: () => void;
  85853. /**
  85854. * Gets or sets the color to use for the background
  85855. */
  85856. loadingUIBackgroundColor: string;
  85857. /**
  85858. * Gets or sets the text to display while loading
  85859. */
  85860. loadingUIText: string;
  85861. }
  85862. /**
  85863. * Class used for the default loading screen
  85864. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85865. */
  85866. export class DefaultLoadingScreen implements ILoadingScreen {
  85867. private _renderingCanvas;
  85868. private _loadingText;
  85869. private _loadingDivBackgroundColor;
  85870. private _loadingDiv;
  85871. private _loadingTextDiv;
  85872. /**
  85873. * Creates a new default loading screen
  85874. * @param _renderingCanvas defines the canvas used to render the scene
  85875. * @param _loadingText defines the default text to display
  85876. * @param _loadingDivBackgroundColor defines the default background color
  85877. */
  85878. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  85879. /**
  85880. * Function called to display the loading screen
  85881. */
  85882. displayLoadingUI(): void;
  85883. /**
  85884. * Function called to hide the loading screen
  85885. */
  85886. hideLoadingUI(): void;
  85887. /**
  85888. * Gets or sets the text to display while loading
  85889. */
  85890. loadingUIText: string;
  85891. /**
  85892. * Gets or sets the color to use for the background
  85893. */
  85894. loadingUIBackgroundColor: string;
  85895. private _resizeLoadingUI;
  85896. }
  85897. }
  85898. declare module BABYLON {
  85899. /**
  85900. * Settings for finer control over video usage
  85901. */
  85902. export interface VideoTextureSettings {
  85903. /**
  85904. * Applies `autoplay` to video, if specified
  85905. */
  85906. autoPlay?: boolean;
  85907. /**
  85908. * Applies `loop` to video, if specified
  85909. */
  85910. loop?: boolean;
  85911. /**
  85912. * Automatically updates internal texture from video at every frame in the render loop
  85913. */
  85914. autoUpdateTexture: boolean;
  85915. /**
  85916. * Image src displayed during the video loading or until the user interacts with the video.
  85917. */
  85918. poster?: string;
  85919. }
  85920. /**
  85921. * If you want to display a video in your scene, this is the special texture for that.
  85922. * This special texture works similar to other textures, with the exception of a few parameters.
  85923. * @see https://doc.babylonjs.com/how_to/video_texture
  85924. */
  85925. export class VideoTexture extends Texture {
  85926. /**
  85927. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  85928. */
  85929. readonly autoUpdateTexture: boolean;
  85930. /**
  85931. * The video instance used by the texture internally
  85932. */
  85933. readonly video: HTMLVideoElement;
  85934. private _onUserActionRequestedObservable;
  85935. /**
  85936. * Event triggerd when a dom action is required by the user to play the video.
  85937. * This happens due to recent changes in browser policies preventing video to auto start.
  85938. */
  85939. readonly onUserActionRequestedObservable: Observable<Texture>;
  85940. private _generateMipMaps;
  85941. private _engine;
  85942. private _stillImageCaptured;
  85943. private _displayingPosterTexture;
  85944. private _settings;
  85945. private _createInternalTextureOnEvent;
  85946. /**
  85947. * Creates a video texture.
  85948. * If you want to display a video in your scene, this is the special texture for that.
  85949. * This special texture works similar to other textures, with the exception of a few parameters.
  85950. * @see https://doc.babylonjs.com/how_to/video_texture
  85951. * @param name optional name, will detect from video source, if not defined
  85952. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  85953. * @param scene is obviously the current scene.
  85954. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  85955. * @param invertY is false by default but can be used to invert video on Y axis
  85956. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  85957. * @param settings allows finer control over video usage
  85958. */
  85959. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  85960. private _getName;
  85961. private _getVideo;
  85962. private _createInternalTexture;
  85963. private reset;
  85964. /**
  85965. * @hidden Internal method to initiate `update`.
  85966. */
  85967. _rebuild(): void;
  85968. /**
  85969. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  85970. */
  85971. update(): void;
  85972. /**
  85973. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  85974. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  85975. */
  85976. updateTexture(isVisible: boolean): void;
  85977. protected _updateInternalTexture: () => void;
  85978. /**
  85979. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  85980. * @param url New url.
  85981. */
  85982. updateURL(url: string): void;
  85983. /**
  85984. * Dispose the texture and release its associated resources.
  85985. */
  85986. dispose(): void;
  85987. /**
  85988. * Creates a video texture straight from a stream.
  85989. * @param scene Define the scene the texture should be created in
  85990. * @param stream Define the stream the texture should be created from
  85991. * @returns The created video texture as a promise
  85992. */
  85993. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  85994. /**
  85995. * Creates a video texture straight from your WebCam video feed.
  85996. * @param scene Define the scene the texture should be created in
  85997. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  85998. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  85999. * @returns The created video texture as a promise
  86000. */
  86001. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86002. minWidth: number;
  86003. maxWidth: number;
  86004. minHeight: number;
  86005. maxHeight: number;
  86006. deviceId: string;
  86007. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86008. /**
  86009. * Creates a video texture straight from your WebCam video feed.
  86010. * @param scene Define the scene the texture should be created in
  86011. * @param onReady Define a callback to triggered once the texture will be ready
  86012. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86013. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86014. */
  86015. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86016. minWidth: number;
  86017. maxWidth: number;
  86018. minHeight: number;
  86019. maxHeight: number;
  86020. deviceId: string;
  86021. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86022. }
  86023. }
  86024. declare module BABYLON {
  86025. /**
  86026. * Interface for attribute information associated with buffer instanciation
  86027. */
  86028. export class InstancingAttributeInfo {
  86029. /**
  86030. * Index/offset of the attribute in the vertex shader
  86031. */
  86032. index: number;
  86033. /**
  86034. * size of the attribute, 1, 2, 3 or 4
  86035. */
  86036. attributeSize: number;
  86037. /**
  86038. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86039. * default is FLOAT
  86040. */
  86041. attribyteType: number;
  86042. /**
  86043. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86044. */
  86045. normalized: boolean;
  86046. /**
  86047. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86048. */
  86049. offset: number;
  86050. /**
  86051. * Name of the GLSL attribute, for debugging purpose only
  86052. */
  86053. attributeName: string;
  86054. }
  86055. /**
  86056. * Define options used to create a depth texture
  86057. */
  86058. export class DepthTextureCreationOptions {
  86059. /** Specifies whether or not a stencil should be allocated in the texture */
  86060. generateStencil?: boolean;
  86061. /** Specifies whether or not bilinear filtering is enable on the texture */
  86062. bilinearFiltering?: boolean;
  86063. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86064. comparisonFunction?: number;
  86065. /** Specifies if the created texture is a cube texture */
  86066. isCube?: boolean;
  86067. }
  86068. /**
  86069. * Class used to describe the capabilities of the engine relatively to the current browser
  86070. */
  86071. export class EngineCapabilities {
  86072. /** Maximum textures units per fragment shader */
  86073. maxTexturesImageUnits: number;
  86074. /** Maximum texture units per vertex shader */
  86075. maxVertexTextureImageUnits: number;
  86076. /** Maximum textures units in the entire pipeline */
  86077. maxCombinedTexturesImageUnits: number;
  86078. /** Maximum texture size */
  86079. maxTextureSize: number;
  86080. /** Maximum cube texture size */
  86081. maxCubemapTextureSize: number;
  86082. /** Maximum render texture size */
  86083. maxRenderTextureSize: number;
  86084. /** Maximum number of vertex attributes */
  86085. maxVertexAttribs: number;
  86086. /** Maximum number of varyings */
  86087. maxVaryingVectors: number;
  86088. /** Maximum number of uniforms per vertex shader */
  86089. maxVertexUniformVectors: number;
  86090. /** Maximum number of uniforms per fragment shader */
  86091. maxFragmentUniformVectors: number;
  86092. /** Defines if standard derivates (dx/dy) are supported */
  86093. standardDerivatives: boolean;
  86094. /** Defines if s3tc texture compression is supported */
  86095. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  86096. /** Defines if pvrtc texture compression is supported */
  86097. pvrtc: any;
  86098. /** Defines if etc1 texture compression is supported */
  86099. etc1: any;
  86100. /** Defines if etc2 texture compression is supported */
  86101. etc2: any;
  86102. /** Defines if astc texture compression is supported */
  86103. astc: any;
  86104. /** Defines if float textures are supported */
  86105. textureFloat: boolean;
  86106. /** Defines if vertex array objects are supported */
  86107. vertexArrayObject: boolean;
  86108. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  86109. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  86110. /** Gets the maximum level of anisotropy supported */
  86111. maxAnisotropy: number;
  86112. /** Defines if instancing is supported */
  86113. instancedArrays: boolean;
  86114. /** Defines if 32 bits indices are supported */
  86115. uintIndices: boolean;
  86116. /** Defines if high precision shaders are supported */
  86117. highPrecisionShaderSupported: boolean;
  86118. /** Defines if depth reading in the fragment shader is supported */
  86119. fragmentDepthSupported: boolean;
  86120. /** Defines if float texture linear filtering is supported*/
  86121. textureFloatLinearFiltering: boolean;
  86122. /** Defines if rendering to float textures is supported */
  86123. textureFloatRender: boolean;
  86124. /** Defines if half float textures are supported*/
  86125. textureHalfFloat: boolean;
  86126. /** Defines if half float texture linear filtering is supported*/
  86127. textureHalfFloatLinearFiltering: boolean;
  86128. /** Defines if rendering to half float textures is supported */
  86129. textureHalfFloatRender: boolean;
  86130. /** Defines if textureLOD shader command is supported */
  86131. textureLOD: boolean;
  86132. /** Defines if draw buffers extension is supported */
  86133. drawBuffersExtension: boolean;
  86134. /** Defines if depth textures are supported */
  86135. depthTextureExtension: boolean;
  86136. /** Defines if float color buffer are supported */
  86137. colorBufferFloat: boolean;
  86138. /** Gets disjoint timer query extension (null if not supported) */
  86139. timerQuery: EXT_disjoint_timer_query;
  86140. /** Defines if timestamp can be used with timer query */
  86141. canUseTimestampForTimerQuery: boolean;
  86142. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  86143. multiview: any;
  86144. /** Function used to let the system compiles shaders in background */
  86145. parallelShaderCompile: {
  86146. COMPLETION_STATUS_KHR: number;
  86147. };
  86148. }
  86149. /** Interface defining initialization parameters for Engine class */
  86150. export interface EngineOptions extends WebGLContextAttributes {
  86151. /**
  86152. * Defines if the engine should no exceed a specified device ratio
  86153. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  86154. */
  86155. limitDeviceRatio?: number;
  86156. /**
  86157. * Defines if webvr should be enabled automatically
  86158. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86159. */
  86160. autoEnableWebVR?: boolean;
  86161. /**
  86162. * Defines if webgl2 should be turned off even if supported
  86163. * @see http://doc.babylonjs.com/features/webgl2
  86164. */
  86165. disableWebGL2Support?: boolean;
  86166. /**
  86167. * Defines if webaudio should be initialized as well
  86168. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86169. */
  86170. audioEngine?: boolean;
  86171. /**
  86172. * Defines if animations should run using a deterministic lock step
  86173. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86174. */
  86175. deterministicLockstep?: boolean;
  86176. /** Defines the maximum steps to use with deterministic lock step mode */
  86177. lockstepMaxSteps?: number;
  86178. /**
  86179. * Defines that engine should ignore context lost events
  86180. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  86181. */
  86182. doNotHandleContextLost?: boolean;
  86183. /**
  86184. * Defines that engine should ignore modifying touch action attribute and style
  86185. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  86186. */
  86187. doNotHandleTouchAction?: boolean;
  86188. /**
  86189. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  86190. */
  86191. useHighPrecisionFloats?: boolean;
  86192. }
  86193. /**
  86194. * Defines the interface used by display changed events
  86195. */
  86196. export interface IDisplayChangedEventArgs {
  86197. /** Gets the vrDisplay object (if any) */
  86198. vrDisplay: Nullable<any>;
  86199. /** Gets a boolean indicating if webVR is supported */
  86200. vrSupported: boolean;
  86201. }
  86202. /**
  86203. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  86204. */
  86205. export class Engine {
  86206. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  86207. static ExceptionList: ({
  86208. key: string;
  86209. capture: string;
  86210. captureConstraint: number;
  86211. targets: string[];
  86212. } | {
  86213. key: string;
  86214. capture: null;
  86215. captureConstraint: null;
  86216. targets: string[];
  86217. })[];
  86218. /** Gets the list of created engines */
  86219. static readonly Instances: Engine[];
  86220. /**
  86221. * Gets the latest created engine
  86222. */
  86223. static readonly LastCreatedEngine: Nullable<Engine>;
  86224. /**
  86225. * Gets the latest created scene
  86226. */
  86227. static readonly LastCreatedScene: Nullable<Scene>;
  86228. /**
  86229. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  86230. * @param flag defines which part of the materials must be marked as dirty
  86231. * @param predicate defines a predicate used to filter which materials should be affected
  86232. */
  86233. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  86234. /**
  86235. * Hidden
  86236. */
  86237. static _TextureLoaders: IInternalTextureLoader[];
  86238. /** Defines that alpha blending is disabled */
  86239. static readonly ALPHA_DISABLE: number;
  86240. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  86241. static readonly ALPHA_ADD: number;
  86242. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  86243. static readonly ALPHA_COMBINE: number;
  86244. /** Defines that alpha blending to DEST - SRC * DEST */
  86245. static readonly ALPHA_SUBTRACT: number;
  86246. /** Defines that alpha blending to SRC * DEST */
  86247. static readonly ALPHA_MULTIPLY: number;
  86248. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  86249. static readonly ALPHA_MAXIMIZED: number;
  86250. /** Defines that alpha blending to SRC + DEST */
  86251. static readonly ALPHA_ONEONE: number;
  86252. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  86253. static readonly ALPHA_PREMULTIPLIED: number;
  86254. /**
  86255. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  86256. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  86257. */
  86258. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  86259. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  86260. static readonly ALPHA_INTERPOLATE: number;
  86261. /**
  86262. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  86263. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  86264. */
  86265. static readonly ALPHA_SCREENMODE: number;
  86266. /** Defines that the ressource is not delayed*/
  86267. static readonly DELAYLOADSTATE_NONE: number;
  86268. /** Defines that the ressource was successfully delay loaded */
  86269. static readonly DELAYLOADSTATE_LOADED: number;
  86270. /** Defines that the ressource is currently delay loading */
  86271. static readonly DELAYLOADSTATE_LOADING: number;
  86272. /** Defines that the ressource is delayed and has not started loading */
  86273. static readonly DELAYLOADSTATE_NOTLOADED: number;
  86274. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  86275. static readonly NEVER: number;
  86276. /** 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 */
  86277. static readonly ALWAYS: number;
  86278. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  86279. static readonly LESS: number;
  86280. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  86281. static readonly EQUAL: number;
  86282. /** 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 */
  86283. static readonly LEQUAL: number;
  86284. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  86285. static readonly GREATER: number;
  86286. /** 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 */
  86287. static readonly GEQUAL: number;
  86288. /** 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 */
  86289. static readonly NOTEQUAL: number;
  86290. /** Passed to stencilOperation to specify that stencil value must be kept */
  86291. static readonly KEEP: number;
  86292. /** Passed to stencilOperation to specify that stencil value must be replaced */
  86293. static readonly REPLACE: number;
  86294. /** Passed to stencilOperation to specify that stencil value must be incremented */
  86295. static readonly INCR: number;
  86296. /** Passed to stencilOperation to specify that stencil value must be decremented */
  86297. static readonly DECR: number;
  86298. /** Passed to stencilOperation to specify that stencil value must be inverted */
  86299. static readonly INVERT: number;
  86300. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  86301. static readonly INCR_WRAP: number;
  86302. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  86303. static readonly DECR_WRAP: number;
  86304. /** Texture is not repeating outside of 0..1 UVs */
  86305. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  86306. /** Texture is repeating outside of 0..1 UVs */
  86307. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  86308. /** Texture is repeating and mirrored */
  86309. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  86310. /** ALPHA */
  86311. static readonly TEXTUREFORMAT_ALPHA: number;
  86312. /** LUMINANCE */
  86313. static readonly TEXTUREFORMAT_LUMINANCE: number;
  86314. /** LUMINANCE_ALPHA */
  86315. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  86316. /** RGB */
  86317. static readonly TEXTUREFORMAT_RGB: number;
  86318. /** RGBA */
  86319. static readonly TEXTUREFORMAT_RGBA: number;
  86320. /** RED */
  86321. static readonly TEXTUREFORMAT_RED: number;
  86322. /** RED (2nd reference) */
  86323. static readonly TEXTUREFORMAT_R: number;
  86324. /** RG */
  86325. static readonly TEXTUREFORMAT_RG: number;
  86326. /** RED_INTEGER */
  86327. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  86328. /** RED_INTEGER (2nd reference) */
  86329. static readonly TEXTUREFORMAT_R_INTEGER: number;
  86330. /** RG_INTEGER */
  86331. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  86332. /** RGB_INTEGER */
  86333. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  86334. /** RGBA_INTEGER */
  86335. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  86336. /** UNSIGNED_BYTE */
  86337. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  86338. /** UNSIGNED_BYTE (2nd reference) */
  86339. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  86340. /** FLOAT */
  86341. static readonly TEXTURETYPE_FLOAT: number;
  86342. /** HALF_FLOAT */
  86343. static readonly TEXTURETYPE_HALF_FLOAT: number;
  86344. /** BYTE */
  86345. static readonly TEXTURETYPE_BYTE: number;
  86346. /** SHORT */
  86347. static readonly TEXTURETYPE_SHORT: number;
  86348. /** UNSIGNED_SHORT */
  86349. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  86350. /** INT */
  86351. static readonly TEXTURETYPE_INT: number;
  86352. /** UNSIGNED_INT */
  86353. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  86354. /** UNSIGNED_SHORT_4_4_4_4 */
  86355. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  86356. /** UNSIGNED_SHORT_5_5_5_1 */
  86357. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  86358. /** UNSIGNED_SHORT_5_6_5 */
  86359. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  86360. /** UNSIGNED_INT_2_10_10_10_REV */
  86361. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  86362. /** UNSIGNED_INT_24_8 */
  86363. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  86364. /** UNSIGNED_INT_10F_11F_11F_REV */
  86365. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  86366. /** UNSIGNED_INT_5_9_9_9_REV */
  86367. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  86368. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  86369. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  86370. /** nearest is mag = nearest and min = nearest and mip = linear */
  86371. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  86372. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86373. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  86374. /** Trilinear is mag = linear and min = linear and mip = linear */
  86375. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  86376. /** nearest is mag = nearest and min = nearest and mip = linear */
  86377. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  86378. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86379. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  86380. /** Trilinear is mag = linear and min = linear and mip = linear */
  86381. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  86382. /** mag = nearest and min = nearest and mip = nearest */
  86383. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  86384. /** mag = nearest and min = linear and mip = nearest */
  86385. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  86386. /** mag = nearest and min = linear and mip = linear */
  86387. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  86388. /** mag = nearest and min = linear and mip = none */
  86389. static readonly TEXTURE_NEAREST_LINEAR: number;
  86390. /** mag = nearest and min = nearest and mip = none */
  86391. static readonly TEXTURE_NEAREST_NEAREST: number;
  86392. /** mag = linear and min = nearest and mip = nearest */
  86393. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  86394. /** mag = linear and min = nearest and mip = linear */
  86395. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  86396. /** mag = linear and min = linear and mip = none */
  86397. static readonly TEXTURE_LINEAR_LINEAR: number;
  86398. /** mag = linear and min = nearest and mip = none */
  86399. static readonly TEXTURE_LINEAR_NEAREST: number;
  86400. /** Explicit coordinates mode */
  86401. static readonly TEXTURE_EXPLICIT_MODE: number;
  86402. /** Spherical coordinates mode */
  86403. static readonly TEXTURE_SPHERICAL_MODE: number;
  86404. /** Planar coordinates mode */
  86405. static readonly TEXTURE_PLANAR_MODE: number;
  86406. /** Cubic coordinates mode */
  86407. static readonly TEXTURE_CUBIC_MODE: number;
  86408. /** Projection coordinates mode */
  86409. static readonly TEXTURE_PROJECTION_MODE: number;
  86410. /** Skybox coordinates mode */
  86411. static readonly TEXTURE_SKYBOX_MODE: number;
  86412. /** Inverse Cubic coordinates mode */
  86413. static readonly TEXTURE_INVCUBIC_MODE: number;
  86414. /** Equirectangular coordinates mode */
  86415. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  86416. /** Equirectangular Fixed coordinates mode */
  86417. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  86418. /** Equirectangular Fixed Mirrored coordinates mode */
  86419. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86420. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  86421. static readonly SCALEMODE_FLOOR: number;
  86422. /** Defines that texture rescaling will look for the nearest power of 2 size */
  86423. static readonly SCALEMODE_NEAREST: number;
  86424. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  86425. static readonly SCALEMODE_CEILING: number;
  86426. /**
  86427. * Returns the current npm package of the sdk
  86428. */
  86429. static readonly NpmPackage: string;
  86430. /**
  86431. * Returns the current version of the framework
  86432. */
  86433. static readonly Version: string;
  86434. /**
  86435. * Returns a string describing the current engine
  86436. */
  86437. readonly description: string;
  86438. /**
  86439. * Gets or sets the epsilon value used by collision engine
  86440. */
  86441. static CollisionsEpsilon: number;
  86442. /**
  86443. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86444. */
  86445. static ShadersRepository: string;
  86446. /**
  86447. * Method called to create the default loading screen.
  86448. * This can be overriden in your own app.
  86449. * @param canvas The rendering canvas element
  86450. * @returns The loading screen
  86451. */
  86452. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  86453. /**
  86454. * Method called to create the default rescale post process on each engine.
  86455. */
  86456. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  86457. /**
  86458. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  86459. */
  86460. forcePOTTextures: boolean;
  86461. /**
  86462. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  86463. */
  86464. isFullscreen: boolean;
  86465. /**
  86466. * Gets a boolean indicating if the pointer is currently locked
  86467. */
  86468. isPointerLock: boolean;
  86469. /**
  86470. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  86471. */
  86472. cullBackFaces: boolean;
  86473. /**
  86474. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  86475. */
  86476. renderEvenInBackground: boolean;
  86477. /**
  86478. * Gets or sets a boolean indicating that cache can be kept between frames
  86479. */
  86480. preventCacheWipeBetweenFrames: boolean;
  86481. /**
  86482. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  86483. **/
  86484. enableOfflineSupport: boolean;
  86485. /**
  86486. * 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)
  86487. **/
  86488. disableManifestCheck: boolean;
  86489. /**
  86490. * Gets the list of created scenes
  86491. */
  86492. scenes: Scene[];
  86493. /**
  86494. * Event raised when a new scene is created
  86495. */
  86496. onNewSceneAddedObservable: Observable<Scene>;
  86497. /**
  86498. * Gets the list of created postprocesses
  86499. */
  86500. postProcesses: PostProcess[];
  86501. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  86502. validateShaderPrograms: boolean;
  86503. /**
  86504. * Observable event triggered each time the rendering canvas is resized
  86505. */
  86506. onResizeObservable: Observable<Engine>;
  86507. /**
  86508. * Observable event triggered each time the canvas loses focus
  86509. */
  86510. onCanvasBlurObservable: Observable<Engine>;
  86511. /**
  86512. * Observable event triggered each time the canvas gains focus
  86513. */
  86514. onCanvasFocusObservable: Observable<Engine>;
  86515. /**
  86516. * Observable event triggered each time the canvas receives pointerout event
  86517. */
  86518. onCanvasPointerOutObservable: Observable<PointerEvent>;
  86519. /**
  86520. * Observable event triggered before each texture is initialized
  86521. */
  86522. onBeforeTextureInitObservable: Observable<Texture>;
  86523. private _vrDisplay;
  86524. private _vrSupported;
  86525. private _oldSize;
  86526. private _oldHardwareScaleFactor;
  86527. private _vrExclusivePointerMode;
  86528. private _webVRInitPromise;
  86529. /**
  86530. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  86531. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  86532. */
  86533. readonly isInVRExclusivePointerMode: boolean;
  86534. /**
  86535. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  86536. */
  86537. disableUniformBuffers: boolean;
  86538. /** @hidden */
  86539. _uniformBuffers: UniformBuffer[];
  86540. /**
  86541. * Gets a boolean indicating that the engine supports uniform buffers
  86542. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86543. */
  86544. readonly supportsUniformBuffers: boolean;
  86545. /**
  86546. * Observable raised when the engine begins a new frame
  86547. */
  86548. onBeginFrameObservable: Observable<Engine>;
  86549. /**
  86550. * If set, will be used to request the next animation frame for the render loop
  86551. */
  86552. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  86553. /**
  86554. * Observable raised when the engine ends the current frame
  86555. */
  86556. onEndFrameObservable: Observable<Engine>;
  86557. /**
  86558. * Observable raised when the engine is about to compile a shader
  86559. */
  86560. onBeforeShaderCompilationObservable: Observable<Engine>;
  86561. /**
  86562. * Observable raised when the engine has jsut compiled a shader
  86563. */
  86564. onAfterShaderCompilationObservable: Observable<Engine>;
  86565. /** @hidden */
  86566. _gl: WebGLRenderingContext;
  86567. private _renderingCanvas;
  86568. private _windowIsBackground;
  86569. private _webGLVersion;
  86570. protected _highPrecisionShadersAllowed: boolean;
  86571. /** @hidden */
  86572. readonly _shouldUseHighPrecisionShader: boolean;
  86573. /**
  86574. * Gets a boolean indicating that only power of 2 textures are supported
  86575. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  86576. */
  86577. readonly needPOTTextures: boolean;
  86578. /** @hidden */
  86579. _badOS: boolean;
  86580. /** @hidden */
  86581. _badDesktopOS: boolean;
  86582. /**
  86583. * Gets the audio engine
  86584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86585. * @ignorenaming
  86586. */
  86587. static audioEngine: IAudioEngine;
  86588. /**
  86589. * Default AudioEngine factory responsible of creating the Audio Engine.
  86590. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  86591. */
  86592. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  86593. /**
  86594. * Default offline support factory responsible of creating a tool used to store data locally.
  86595. * By default, this will create a Database object if the workload has been embedded.
  86596. */
  86597. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  86598. private _onFocus;
  86599. private _onBlur;
  86600. private _onCanvasPointerOut;
  86601. private _onCanvasBlur;
  86602. private _onCanvasFocus;
  86603. private _onFullscreenChange;
  86604. private _onPointerLockChange;
  86605. private _onVRDisplayPointerRestricted;
  86606. private _onVRDisplayPointerUnrestricted;
  86607. private _onVrDisplayConnect;
  86608. private _onVrDisplayDisconnect;
  86609. private _onVrDisplayPresentChange;
  86610. /**
  86611. * Observable signaled when VR display mode changes
  86612. */
  86613. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  86614. /**
  86615. * Observable signaled when VR request present is complete
  86616. */
  86617. onVRRequestPresentComplete: Observable<boolean>;
  86618. /**
  86619. * Observable signaled when VR request present starts
  86620. */
  86621. onVRRequestPresentStart: Observable<Engine>;
  86622. private _hardwareScalingLevel;
  86623. /** @hidden */
  86624. protected _caps: EngineCapabilities;
  86625. private _pointerLockRequested;
  86626. private _isStencilEnable;
  86627. private _colorWrite;
  86628. private _loadingScreen;
  86629. /** @hidden */
  86630. _drawCalls: PerfCounter;
  86631. private _glVersion;
  86632. private _glRenderer;
  86633. private _glVendor;
  86634. private _videoTextureSupported;
  86635. private _renderingQueueLaunched;
  86636. private _activeRenderLoops;
  86637. private _deterministicLockstep;
  86638. private _lockstepMaxSteps;
  86639. /**
  86640. * Observable signaled when a context lost event is raised
  86641. */
  86642. onContextLostObservable: Observable<Engine>;
  86643. /**
  86644. * Observable signaled when a context restored event is raised
  86645. */
  86646. onContextRestoredObservable: Observable<Engine>;
  86647. private _onContextLost;
  86648. private _onContextRestored;
  86649. private _contextWasLost;
  86650. private _doNotHandleContextLost;
  86651. /**
  86652. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  86653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  86654. */
  86655. doNotHandleContextLost: boolean;
  86656. private _performanceMonitor;
  86657. private _fps;
  86658. private _deltaTime;
  86659. /**
  86660. * Turn this value on if you want to pause FPS computation when in background
  86661. */
  86662. disablePerformanceMonitorInBackground: boolean;
  86663. /**
  86664. * Gets the performance monitor attached to this engine
  86665. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  86666. */
  86667. readonly performanceMonitor: PerformanceMonitor;
  86668. /**
  86669. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  86670. */
  86671. disableVertexArrayObjects: boolean;
  86672. /** @hidden */
  86673. protected _depthCullingState: _DepthCullingState;
  86674. /** @hidden */
  86675. protected _stencilState: _StencilState;
  86676. /** @hidden */
  86677. protected _alphaState: _AlphaState;
  86678. /** @hidden */
  86679. protected _alphaMode: number;
  86680. protected _internalTexturesCache: InternalTexture[];
  86681. /** @hidden */
  86682. protected _activeChannel: number;
  86683. private _currentTextureChannel;
  86684. /** @hidden */
  86685. protected _boundTexturesCache: {
  86686. [key: string]: Nullable<InternalTexture>;
  86687. };
  86688. /** @hidden */
  86689. protected _currentEffect: Nullable<Effect>;
  86690. /** @hidden */
  86691. protected _currentProgram: Nullable<WebGLProgram>;
  86692. private _compiledEffects;
  86693. private _vertexAttribArraysEnabled;
  86694. /** @hidden */
  86695. protected _cachedViewport: Nullable<Viewport>;
  86696. private _cachedVertexArrayObject;
  86697. /** @hidden */
  86698. protected _cachedVertexBuffers: any;
  86699. /** @hidden */
  86700. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  86701. /** @hidden */
  86702. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  86703. /** @hidden */
  86704. protected _currentRenderTarget: Nullable<InternalTexture>;
  86705. private _uintIndicesCurrentlySet;
  86706. private _currentBoundBuffer;
  86707. /** @hidden */
  86708. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  86709. private _currentBufferPointers;
  86710. private _currentInstanceLocations;
  86711. private _currentInstanceBuffers;
  86712. private _textureUnits;
  86713. private _workingCanvas;
  86714. private _workingContext;
  86715. private _rescalePostProcess;
  86716. private _dummyFramebuffer;
  86717. private _externalData;
  86718. private _bindedRenderFunction;
  86719. private _vaoRecordInProgress;
  86720. private _mustWipeVertexAttributes;
  86721. private _emptyTexture;
  86722. private _emptyCubeTexture;
  86723. private _emptyTexture3D;
  86724. /** @hidden */
  86725. _frameHandler: number;
  86726. private _nextFreeTextureSlots;
  86727. private _maxSimultaneousTextures;
  86728. private _activeRequests;
  86729. private _texturesSupported;
  86730. private _textureFormatInUse;
  86731. /**
  86732. * Gets the list of texture formats supported
  86733. */
  86734. readonly texturesSupported: Array<string>;
  86735. /**
  86736. * Gets the list of texture formats in use
  86737. */
  86738. readonly textureFormatInUse: Nullable<string>;
  86739. /**
  86740. * Gets the current viewport
  86741. */
  86742. readonly currentViewport: Nullable<Viewport>;
  86743. /**
  86744. * Gets the default empty texture
  86745. */
  86746. readonly emptyTexture: InternalTexture;
  86747. /**
  86748. * Gets the default empty 3D texture
  86749. */
  86750. readonly emptyTexture3D: InternalTexture;
  86751. /**
  86752. * Gets the default empty cube texture
  86753. */
  86754. readonly emptyCubeTexture: InternalTexture;
  86755. /**
  86756. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  86757. */
  86758. readonly premultipliedAlpha: boolean;
  86759. /**
  86760. * Creates a new engine
  86761. * @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
  86762. * @param antialias defines enable antialiasing (default: false)
  86763. * @param options defines further options to be sent to the getContext() function
  86764. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  86765. */
  86766. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  86767. private _disableTouchAction;
  86768. private _rebuildInternalTextures;
  86769. private _rebuildEffects;
  86770. /**
  86771. * Gets a boolean indicating if all created effects are ready
  86772. * @returns true if all effects are ready
  86773. */
  86774. areAllEffectsReady(): boolean;
  86775. private _rebuildBuffers;
  86776. private _initGLContext;
  86777. /**
  86778. * Gets version of the current webGL context
  86779. */
  86780. readonly webGLVersion: number;
  86781. /**
  86782. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  86783. */
  86784. readonly isStencilEnable: boolean;
  86785. private _prepareWorkingCanvas;
  86786. /**
  86787. * Reset the texture cache to empty state
  86788. */
  86789. resetTextureCache(): void;
  86790. /**
  86791. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  86792. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86793. * @returns true if engine is in deterministic lock step mode
  86794. */
  86795. isDeterministicLockStep(): boolean;
  86796. /**
  86797. * Gets the max steps when engine is running in deterministic lock step
  86798. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86799. * @returns the max steps
  86800. */
  86801. getLockstepMaxSteps(): number;
  86802. /**
  86803. * Gets an object containing information about the current webGL context
  86804. * @returns an object containing the vender, the renderer and the version of the current webGL context
  86805. */
  86806. getGlInfo(): {
  86807. vendor: string;
  86808. renderer: string;
  86809. version: string;
  86810. };
  86811. /**
  86812. * Gets current aspect ratio
  86813. * @param camera defines the camera to use to get the aspect ratio
  86814. * @param useScreen defines if screen size must be used (or the current render target if any)
  86815. * @returns a number defining the aspect ratio
  86816. */
  86817. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  86818. /**
  86819. * Gets current screen aspect ratio
  86820. * @returns a number defining the aspect ratio
  86821. */
  86822. getScreenAspectRatio(): number;
  86823. /**
  86824. * Gets the current render width
  86825. * @param useScreen defines if screen size must be used (or the current render target if any)
  86826. * @returns a number defining the current render width
  86827. */
  86828. getRenderWidth(useScreen?: boolean): number;
  86829. /**
  86830. * Gets the current render height
  86831. * @param useScreen defines if screen size must be used (or the current render target if any)
  86832. * @returns a number defining the current render height
  86833. */
  86834. getRenderHeight(useScreen?: boolean): number;
  86835. /**
  86836. * Gets the HTML canvas attached with the current webGL context
  86837. * @returns a HTML canvas
  86838. */
  86839. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  86840. /**
  86841. * Gets the client rect of the HTML canvas attached with the current webGL context
  86842. * @returns a client rectanglee
  86843. */
  86844. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  86845. /**
  86846. * Defines the hardware scaling level.
  86847. * By default the hardware scaling level is computed from the window device ratio.
  86848. * 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.
  86849. * @param level defines the level to use
  86850. */
  86851. setHardwareScalingLevel(level: number): void;
  86852. /**
  86853. * Gets the current hardware scaling level.
  86854. * By default the hardware scaling level is computed from the window device ratio.
  86855. * 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.
  86856. * @returns a number indicating the current hardware scaling level
  86857. */
  86858. getHardwareScalingLevel(): number;
  86859. /**
  86860. * Gets the list of loaded textures
  86861. * @returns an array containing all loaded textures
  86862. */
  86863. getLoadedTexturesCache(): InternalTexture[];
  86864. /**
  86865. * Gets the object containing all engine capabilities
  86866. * @returns the EngineCapabilities object
  86867. */
  86868. getCaps(): EngineCapabilities;
  86869. /**
  86870. * Gets the current depth function
  86871. * @returns a number defining the depth function
  86872. */
  86873. getDepthFunction(): Nullable<number>;
  86874. /**
  86875. * Sets the current depth function
  86876. * @param depthFunc defines the function to use
  86877. */
  86878. setDepthFunction(depthFunc: number): void;
  86879. /**
  86880. * Sets the current depth function to GREATER
  86881. */
  86882. setDepthFunctionToGreater(): void;
  86883. /**
  86884. * Sets the current depth function to GEQUAL
  86885. */
  86886. setDepthFunctionToGreaterOrEqual(): void;
  86887. /**
  86888. * Sets the current depth function to LESS
  86889. */
  86890. setDepthFunctionToLess(): void;
  86891. private _cachedStencilBuffer;
  86892. private _cachedStencilFunction;
  86893. private _cachedStencilMask;
  86894. private _cachedStencilOperationPass;
  86895. private _cachedStencilOperationFail;
  86896. private _cachedStencilOperationDepthFail;
  86897. private _cachedStencilReference;
  86898. /**
  86899. * Caches the the state of the stencil buffer
  86900. */
  86901. cacheStencilState(): void;
  86902. /**
  86903. * Restores the state of the stencil buffer
  86904. */
  86905. restoreStencilState(): void;
  86906. /**
  86907. * Sets the current depth function to LEQUAL
  86908. */
  86909. setDepthFunctionToLessOrEqual(): void;
  86910. /**
  86911. * Gets a boolean indicating if stencil buffer is enabled
  86912. * @returns the current stencil buffer state
  86913. */
  86914. getStencilBuffer(): boolean;
  86915. /**
  86916. * Enable or disable the stencil buffer
  86917. * @param enable defines if the stencil buffer must be enabled or disabled
  86918. */
  86919. setStencilBuffer(enable: boolean): void;
  86920. /**
  86921. * Gets the current stencil mask
  86922. * @returns a number defining the new stencil mask to use
  86923. */
  86924. getStencilMask(): number;
  86925. /**
  86926. * Sets the current stencil mask
  86927. * @param mask defines the new stencil mask to use
  86928. */
  86929. setStencilMask(mask: number): void;
  86930. /**
  86931. * Gets the current stencil function
  86932. * @returns a number defining the stencil function to use
  86933. */
  86934. getStencilFunction(): number;
  86935. /**
  86936. * Gets the current stencil reference value
  86937. * @returns a number defining the stencil reference value to use
  86938. */
  86939. getStencilFunctionReference(): number;
  86940. /**
  86941. * Gets the current stencil mask
  86942. * @returns a number defining the stencil mask to use
  86943. */
  86944. getStencilFunctionMask(): number;
  86945. /**
  86946. * Sets the current stencil function
  86947. * @param stencilFunc defines the new stencil function to use
  86948. */
  86949. setStencilFunction(stencilFunc: number): void;
  86950. /**
  86951. * Sets the current stencil reference
  86952. * @param reference defines the new stencil reference to use
  86953. */
  86954. setStencilFunctionReference(reference: number): void;
  86955. /**
  86956. * Sets the current stencil mask
  86957. * @param mask defines the new stencil mask to use
  86958. */
  86959. setStencilFunctionMask(mask: number): void;
  86960. /**
  86961. * Gets the current stencil operation when stencil fails
  86962. * @returns a number defining stencil operation to use when stencil fails
  86963. */
  86964. getStencilOperationFail(): number;
  86965. /**
  86966. * Gets the current stencil operation when depth fails
  86967. * @returns a number defining stencil operation to use when depth fails
  86968. */
  86969. getStencilOperationDepthFail(): number;
  86970. /**
  86971. * Gets the current stencil operation when stencil passes
  86972. * @returns a number defining stencil operation to use when stencil passes
  86973. */
  86974. getStencilOperationPass(): number;
  86975. /**
  86976. * Sets the stencil operation to use when stencil fails
  86977. * @param operation defines the stencil operation to use when stencil fails
  86978. */
  86979. setStencilOperationFail(operation: number): void;
  86980. /**
  86981. * Sets the stencil operation to use when depth fails
  86982. * @param operation defines the stencil operation to use when depth fails
  86983. */
  86984. setStencilOperationDepthFail(operation: number): void;
  86985. /**
  86986. * Sets the stencil operation to use when stencil passes
  86987. * @param operation defines the stencil operation to use when stencil passes
  86988. */
  86989. setStencilOperationPass(operation: number): void;
  86990. /**
  86991. * Sets a boolean indicating if the dithering state is enabled or disabled
  86992. * @param value defines the dithering state
  86993. */
  86994. setDitheringState(value: boolean): void;
  86995. /**
  86996. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  86997. * @param value defines the rasterizer state
  86998. */
  86999. setRasterizerState(value: boolean): void;
  87000. /**
  87001. * stop executing a render loop function and remove it from the execution array
  87002. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87003. */
  87004. stopRenderLoop(renderFunction?: () => void): void;
  87005. /** @hidden */
  87006. _renderLoop(): void;
  87007. /**
  87008. * Register and execute a render loop. The engine can have more than one render function
  87009. * @param renderFunction defines the function to continuously execute
  87010. */
  87011. runRenderLoop(renderFunction: () => void): void;
  87012. /**
  87013. * Toggle full screen mode
  87014. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87015. */
  87016. switchFullscreen(requestPointerLock: boolean): void;
  87017. /**
  87018. * Enters full screen mode
  87019. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87020. */
  87021. enterFullscreen(requestPointerLock: boolean): void;
  87022. /**
  87023. * Exits full screen mode
  87024. */
  87025. exitFullscreen(): void;
  87026. /**
  87027. * Clear the current render buffer or the current render target (if any is set up)
  87028. * @param color defines the color to use
  87029. * @param backBuffer defines if the back buffer must be cleared
  87030. * @param depth defines if the depth buffer must be cleared
  87031. * @param stencil defines if the stencil buffer must be cleared
  87032. */
  87033. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87034. /**
  87035. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87036. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87037. * @param y defines the y-coordinate of the corner of the clear rectangle
  87038. * @param width defines the width of the clear rectangle
  87039. * @param height defines the height of the clear rectangle
  87040. * @param clearColor defines the clear color
  87041. */
  87042. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87043. /**
  87044. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87045. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87046. * @param y defines the y-coordinate of the corner of the clear rectangle
  87047. * @param width defines the width of the clear rectangle
  87048. * @param height defines the height of the clear rectangle
  87049. */
  87050. enableScissor(x: number, y: number, width: number, height: number): void;
  87051. /**
  87052. * Disable previously set scissor test rectangle
  87053. */
  87054. disableScissor(): void;
  87055. private _viewportCached;
  87056. /** @hidden */
  87057. _viewport(x: number, y: number, width: number, height: number): void;
  87058. /**
  87059. * Set the WebGL's viewport
  87060. * @param viewport defines the viewport element to be used
  87061. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87062. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87063. */
  87064. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87065. /**
  87066. * Directly set the WebGL Viewport
  87067. * @param x defines the x coordinate of the viewport (in screen space)
  87068. * @param y defines the y coordinate of the viewport (in screen space)
  87069. * @param width defines the width of the viewport (in screen space)
  87070. * @param height defines the height of the viewport (in screen space)
  87071. * @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
  87072. */
  87073. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87074. /**
  87075. * Begin a new frame
  87076. */
  87077. beginFrame(): void;
  87078. /**
  87079. * Enf the current frame
  87080. */
  87081. endFrame(): void;
  87082. /**
  87083. * Resize the view according to the canvas' size
  87084. */
  87085. resize(): void;
  87086. /**
  87087. * Force a specific size of the canvas
  87088. * @param width defines the new canvas' width
  87089. * @param height defines the new canvas' height
  87090. */
  87091. setSize(width: number, height: number): void;
  87092. /**
  87093. * Gets a boolean indicating if a webVR device was detected
  87094. * @returns true if a webVR device was detected
  87095. */
  87096. isVRDevicePresent(): boolean;
  87097. /**
  87098. * Gets the current webVR device
  87099. * @returns the current webVR device (or null)
  87100. */
  87101. getVRDevice(): any;
  87102. /**
  87103. * Initializes a webVR display and starts listening to display change events
  87104. * The onVRDisplayChangedObservable will be notified upon these changes
  87105. * @returns The onVRDisplayChangedObservable
  87106. */
  87107. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87108. /**
  87109. * Initializes a webVR display and starts listening to display change events
  87110. * The onVRDisplayChangedObservable will be notified upon these changes
  87111. * @returns A promise containing a VRDisplay and if vr is supported
  87112. */
  87113. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  87114. /**
  87115. * Call this function to switch to webVR mode
  87116. * Will do nothing if webVR is not supported or if there is no webVR device
  87117. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87118. */
  87119. enableVR(): void;
  87120. /**
  87121. * Call this function to leave webVR mode
  87122. * Will do nothing if webVR is not supported or if there is no webVR device
  87123. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87124. */
  87125. disableVR(): void;
  87126. private _onVRFullScreenTriggered;
  87127. private _getVRDisplaysAsync;
  87128. /**
  87129. * Binds the frame buffer to the specified texture.
  87130. * @param texture The texture to render to or null for the default canvas
  87131. * @param faceIndex The face of the texture to render to in case of cube texture
  87132. * @param requiredWidth The width of the target to render to
  87133. * @param requiredHeight The height of the target to render to
  87134. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  87135. * @param depthStencilTexture The depth stencil texture to use to render
  87136. * @param lodLevel defines le lod level to bind to the frame buffer
  87137. */
  87138. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  87139. private bindUnboundFramebuffer;
  87140. /**
  87141. * Unbind the current render target texture from the webGL context
  87142. * @param texture defines the render target texture to unbind
  87143. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87144. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87145. */
  87146. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87147. /**
  87148. * Unbind a list of render target textures from the webGL context
  87149. * This is used only when drawBuffer extension or webGL2 are active
  87150. * @param textures defines the render target textures to unbind
  87151. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87152. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87153. */
  87154. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87155. /**
  87156. * Force the mipmap generation for the given render target texture
  87157. * @param texture defines the render target texture to use
  87158. */
  87159. generateMipMapsForCubemap(texture: InternalTexture): void;
  87160. /**
  87161. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  87162. */
  87163. flushFramebuffer(): void;
  87164. /**
  87165. * Unbind the current render target and bind the default framebuffer
  87166. */
  87167. restoreDefaultFramebuffer(): void;
  87168. /**
  87169. * Create an uniform buffer
  87170. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87171. * @param elements defines the content of the uniform buffer
  87172. * @returns the webGL uniform buffer
  87173. */
  87174. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  87175. /**
  87176. * Create a dynamic uniform buffer
  87177. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87178. * @param elements defines the content of the uniform buffer
  87179. * @returns the webGL uniform buffer
  87180. */
  87181. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  87182. /**
  87183. * Update an existing uniform buffer
  87184. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87185. * @param uniformBuffer defines the target uniform buffer
  87186. * @param elements defines the content to update
  87187. * @param offset defines the offset in the uniform buffer where update should start
  87188. * @param count defines the size of the data to update
  87189. */
  87190. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87191. private _resetVertexBufferBinding;
  87192. /**
  87193. * Creates a vertex buffer
  87194. * @param data the data for the vertex buffer
  87195. * @returns the new WebGL static buffer
  87196. */
  87197. createVertexBuffer(data: DataArray): WebGLBuffer;
  87198. /**
  87199. * Creates a dynamic vertex buffer
  87200. * @param data the data for the dynamic vertex buffer
  87201. * @returns the new WebGL dynamic buffer
  87202. */
  87203. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  87204. /**
  87205. * Update a dynamic index buffer
  87206. * @param indexBuffer defines the target index buffer
  87207. * @param indices defines the data to update
  87208. * @param offset defines the offset in the target index buffer where update should start
  87209. */
  87210. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  87211. /**
  87212. * Updates a dynamic vertex buffer.
  87213. * @param vertexBuffer the vertex buffer to update
  87214. * @param data the data used to update the vertex buffer
  87215. * @param byteOffset the byte offset of the data
  87216. * @param byteLength the byte length of the data
  87217. */
  87218. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  87219. private _resetIndexBufferBinding;
  87220. /**
  87221. * Creates a new index buffer
  87222. * @param indices defines the content of the index buffer
  87223. * @param updatable defines if the index buffer must be updatable
  87224. * @returns a new webGL buffer
  87225. */
  87226. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  87227. /**
  87228. * Bind a webGL buffer to the webGL context
  87229. * @param buffer defines the buffer to bind
  87230. */
  87231. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  87232. /**
  87233. * Bind an uniform buffer to the current webGL context
  87234. * @param buffer defines the buffer to bind
  87235. */
  87236. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  87237. /**
  87238. * Bind a buffer to the current webGL context at a given location
  87239. * @param buffer defines the buffer to bind
  87240. * @param location defines the index where to bind the buffer
  87241. */
  87242. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  87243. /**
  87244. * Bind a specific block at a given index in a specific shader program
  87245. * @param shaderProgram defines the shader program
  87246. * @param blockName defines the block name
  87247. * @param index defines the index where to bind the block
  87248. */
  87249. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  87250. private bindIndexBuffer;
  87251. private bindBuffer;
  87252. /**
  87253. * update the bound buffer with the given data
  87254. * @param data defines the data to update
  87255. */
  87256. updateArrayBuffer(data: Float32Array): void;
  87257. private _vertexAttribPointer;
  87258. private _bindIndexBufferWithCache;
  87259. private _bindVertexBuffersAttributes;
  87260. /**
  87261. * Records a vertex array object
  87262. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87263. * @param vertexBuffers defines the list of vertex buffers to store
  87264. * @param indexBuffer defines the index buffer to store
  87265. * @param effect defines the effect to store
  87266. * @returns the new vertex array object
  87267. */
  87268. recordVertexArrayObject(vertexBuffers: {
  87269. [key: string]: VertexBuffer;
  87270. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  87271. /**
  87272. * Bind a specific vertex array object
  87273. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87274. * @param vertexArrayObject defines the vertex array object to bind
  87275. * @param indexBuffer defines the index buffer to bind
  87276. */
  87277. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  87278. /**
  87279. * Bind webGl buffers directly to the webGL context
  87280. * @param vertexBuffer defines the vertex buffer to bind
  87281. * @param indexBuffer defines the index buffer to bind
  87282. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  87283. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  87284. * @param effect defines the effect associated with the vertex buffer
  87285. */
  87286. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  87287. private _unbindVertexArrayObject;
  87288. /**
  87289. * Bind a list of vertex buffers to the webGL context
  87290. * @param vertexBuffers defines the list of vertex buffers to bind
  87291. * @param indexBuffer defines the index buffer to bind
  87292. * @param effect defines the effect associated with the vertex buffers
  87293. */
  87294. bindBuffers(vertexBuffers: {
  87295. [key: string]: Nullable<VertexBuffer>;
  87296. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  87297. /**
  87298. * Unbind all instance attributes
  87299. */
  87300. unbindInstanceAttributes(): void;
  87301. /**
  87302. * Release and free the memory of a vertex array object
  87303. * @param vao defines the vertex array object to delete
  87304. */
  87305. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  87306. /** @hidden */
  87307. _releaseBuffer(buffer: WebGLBuffer): boolean;
  87308. /**
  87309. * Creates a webGL buffer to use with instanciation
  87310. * @param capacity defines the size of the buffer
  87311. * @returns the webGL buffer
  87312. */
  87313. createInstancesBuffer(capacity: number): WebGLBuffer;
  87314. /**
  87315. * Delete a webGL buffer used with instanciation
  87316. * @param buffer defines the webGL buffer to delete
  87317. */
  87318. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  87319. /**
  87320. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  87321. * @param instancesBuffer defines the webGL buffer to update and bind
  87322. * @param data defines the data to store in the buffer
  87323. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  87324. */
  87325. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  87326. /**
  87327. * Apply all cached states (depth, culling, stencil and alpha)
  87328. */
  87329. applyStates(): void;
  87330. /**
  87331. * Send a draw order
  87332. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87333. * @param indexStart defines the starting index
  87334. * @param indexCount defines the number of index to draw
  87335. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87336. */
  87337. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  87338. /**
  87339. * Draw a list of points
  87340. * @param verticesStart defines the index of first vertex to draw
  87341. * @param verticesCount defines the count of vertices to draw
  87342. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87343. */
  87344. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87345. /**
  87346. * Draw a list of unindexed primitives
  87347. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87348. * @param verticesStart defines the index of first vertex to draw
  87349. * @param verticesCount defines the count of vertices to draw
  87350. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87351. */
  87352. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87353. /**
  87354. * Draw a list of indexed primitives
  87355. * @param fillMode defines the primitive to use
  87356. * @param indexStart defines the starting index
  87357. * @param indexCount defines the number of index to draw
  87358. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87359. */
  87360. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  87361. /**
  87362. * Draw a list of unindexed primitives
  87363. * @param fillMode defines the primitive to use
  87364. * @param verticesStart defines the index of first vertex to draw
  87365. * @param verticesCount defines the count of vertices to draw
  87366. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87367. */
  87368. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87369. private _drawMode;
  87370. /** @hidden */
  87371. _releaseEffect(effect: Effect): void;
  87372. /** @hidden */
  87373. _deleteProgram(program: WebGLProgram): void;
  87374. /**
  87375. * Create a new effect (used to store vertex/fragment shaders)
  87376. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  87377. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  87378. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  87379. * @param samplers defines an array of string used to represent textures
  87380. * @param defines defines the string containing the defines to use to compile the shaders
  87381. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  87382. * @param onCompiled defines a function to call when the effect creation is successful
  87383. * @param onError defines a function to call when the effect creation has failed
  87384. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  87385. * @returns the new Effect
  87386. */
  87387. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  87388. private _compileShader;
  87389. private _compileRawShader;
  87390. /**
  87391. * Directly creates a webGL program
  87392. * @param vertexCode defines the vertex shader code to use
  87393. * @param fragmentCode defines the fragment shader code to use
  87394. * @param context defines the webGL context to use (if not set, the current one will be used)
  87395. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87396. * @returns the new webGL program
  87397. */
  87398. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87399. /**
  87400. * Creates a webGL program
  87401. * @param vertexCode defines the vertex shader code to use
  87402. * @param fragmentCode defines the fragment shader code to use
  87403. * @param defines defines the string containing the defines to use to compile the shaders
  87404. * @param context defines the webGL context to use (if not set, the current one will be used)
  87405. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87406. * @returns the new webGL program
  87407. */
  87408. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87409. private _createShaderProgram;
  87410. private _finalizeProgram;
  87411. /** @hidden */
  87412. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  87413. /** @hidden */
  87414. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  87415. /**
  87416. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  87417. * @param shaderProgram defines the webGL program to use
  87418. * @param uniformsNames defines the list of uniform names
  87419. * @returns an array of webGL uniform locations
  87420. */
  87421. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  87422. /**
  87423. * Gets the lsit of active attributes for a given webGL program
  87424. * @param shaderProgram defines the webGL program to use
  87425. * @param attributesNames defines the list of attribute names to get
  87426. * @returns an array of indices indicating the offset of each attribute
  87427. */
  87428. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  87429. /**
  87430. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  87431. * @param effect defines the effect to activate
  87432. */
  87433. enableEffect(effect: Nullable<Effect>): void;
  87434. /**
  87435. * Set the value of an uniform to an array of int32
  87436. * @param uniform defines the webGL uniform location where to store the value
  87437. * @param array defines the array of int32 to store
  87438. */
  87439. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87440. /**
  87441. * Set the value of an uniform to an array of int32 (stored as vec2)
  87442. * @param uniform defines the webGL uniform location where to store the value
  87443. * @param array defines the array of int32 to store
  87444. */
  87445. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87446. /**
  87447. * Set the value of an uniform to an array of int32 (stored as vec3)
  87448. * @param uniform defines the webGL uniform location where to store the value
  87449. * @param array defines the array of int32 to store
  87450. */
  87451. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87452. /**
  87453. * Set the value of an uniform to an array of int32 (stored as vec4)
  87454. * @param uniform defines the webGL uniform location where to store the value
  87455. * @param array defines the array of int32 to store
  87456. */
  87457. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87458. /**
  87459. * Set the value of an uniform to an array of float32
  87460. * @param uniform defines the webGL uniform location where to store the value
  87461. * @param array defines the array of float32 to store
  87462. */
  87463. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87464. /**
  87465. * Set the value of an uniform to an array of float32 (stored as vec2)
  87466. * @param uniform defines the webGL uniform location where to store the value
  87467. * @param array defines the array of float32 to store
  87468. */
  87469. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87470. /**
  87471. * Set the value of an uniform to an array of float32 (stored as vec3)
  87472. * @param uniform defines the webGL uniform location where to store the value
  87473. * @param array defines the array of float32 to store
  87474. */
  87475. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87476. /**
  87477. * Set the value of an uniform to an array of float32 (stored as vec4)
  87478. * @param uniform defines the webGL uniform location where to store the value
  87479. * @param array defines the array of float32 to store
  87480. */
  87481. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87482. /**
  87483. * Set the value of an uniform to an array of number
  87484. * @param uniform defines the webGL uniform location where to store the value
  87485. * @param array defines the array of number to store
  87486. */
  87487. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87488. /**
  87489. * Set the value of an uniform to an array of number (stored as vec2)
  87490. * @param uniform defines the webGL uniform location where to store the value
  87491. * @param array defines the array of number to store
  87492. */
  87493. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87494. /**
  87495. * Set the value of an uniform to an array of number (stored as vec3)
  87496. * @param uniform defines the webGL uniform location where to store the value
  87497. * @param array defines the array of number to store
  87498. */
  87499. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87500. /**
  87501. * Set the value of an uniform to an array of number (stored as vec4)
  87502. * @param uniform defines the webGL uniform location where to store the value
  87503. * @param array defines the array of number to store
  87504. */
  87505. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87506. /**
  87507. * Set the value of an uniform to an array of float32 (stored as matrices)
  87508. * @param uniform defines the webGL uniform location where to store the value
  87509. * @param matrices defines the array of float32 to store
  87510. */
  87511. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  87512. /**
  87513. * Set the value of an uniform to a matrix
  87514. * @param uniform defines the webGL uniform location where to store the value
  87515. * @param matrix defines the matrix to store
  87516. */
  87517. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  87518. /**
  87519. * Set the value of an uniform to a matrix (3x3)
  87520. * @param uniform defines the webGL uniform location where to store the value
  87521. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  87522. */
  87523. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87524. /**
  87525. * Set the value of an uniform to a matrix (2x2)
  87526. * @param uniform defines the webGL uniform location where to store the value
  87527. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  87528. */
  87529. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87530. /**
  87531. * Set the value of an uniform to a number (int)
  87532. * @param uniform defines the webGL uniform location where to store the value
  87533. * @param value defines the int number to store
  87534. */
  87535. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87536. /**
  87537. * Set the value of an uniform to a number (float)
  87538. * @param uniform defines the webGL uniform location where to store the value
  87539. * @param value defines the float number to store
  87540. */
  87541. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87542. /**
  87543. * Set the value of an uniform to a vec2
  87544. * @param uniform defines the webGL uniform location where to store the value
  87545. * @param x defines the 1st component of the value
  87546. * @param y defines the 2nd component of the value
  87547. */
  87548. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  87549. /**
  87550. * Set the value of an uniform to a vec3
  87551. * @param uniform defines the webGL uniform location where to store the value
  87552. * @param x defines the 1st component of the value
  87553. * @param y defines the 2nd component of the value
  87554. * @param z defines the 3rd component of the value
  87555. */
  87556. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  87557. /**
  87558. * Set the value of an uniform to a boolean
  87559. * @param uniform defines the webGL uniform location where to store the value
  87560. * @param bool defines the boolean to store
  87561. */
  87562. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  87563. /**
  87564. * Set the value of an uniform to a vec4
  87565. * @param uniform defines the webGL uniform location where to store the value
  87566. * @param x defines the 1st component of the value
  87567. * @param y defines the 2nd component of the value
  87568. * @param z defines the 3rd component of the value
  87569. * @param w defines the 4th component of the value
  87570. */
  87571. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  87572. /**
  87573. * Set the value of an uniform to a Color3
  87574. * @param uniform defines the webGL uniform location where to store the value
  87575. * @param color3 defines the color to store
  87576. */
  87577. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  87578. /**
  87579. * Set the value of an uniform to a Color3 and an alpha value
  87580. * @param uniform defines the webGL uniform location where to store the value
  87581. * @param color3 defines the color to store
  87582. * @param alpha defines the alpha component to store
  87583. */
  87584. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  87585. /**
  87586. * Sets a Color4 on a uniform variable
  87587. * @param uniform defines the uniform location
  87588. * @param color4 defines the value to be set
  87589. */
  87590. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  87591. /**
  87592. * Set various states to the webGL context
  87593. * @param culling defines backface culling state
  87594. * @param zOffset defines the value to apply to zOffset (0 by default)
  87595. * @param force defines if states must be applied even if cache is up to date
  87596. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  87597. */
  87598. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  87599. /**
  87600. * Set the z offset to apply to current rendering
  87601. * @param value defines the offset to apply
  87602. */
  87603. setZOffset(value: number): void;
  87604. /**
  87605. * Gets the current value of the zOffset
  87606. * @returns the current zOffset state
  87607. */
  87608. getZOffset(): number;
  87609. /**
  87610. * Enable or disable depth buffering
  87611. * @param enable defines the state to set
  87612. */
  87613. setDepthBuffer(enable: boolean): void;
  87614. /**
  87615. * Gets a boolean indicating if depth writing is enabled
  87616. * @returns the current depth writing state
  87617. */
  87618. getDepthWrite(): boolean;
  87619. /**
  87620. * Enable or disable depth writing
  87621. * @param enable defines the state to set
  87622. */
  87623. setDepthWrite(enable: boolean): void;
  87624. /**
  87625. * Enable or disable color writing
  87626. * @param enable defines the state to set
  87627. */
  87628. setColorWrite(enable: boolean): void;
  87629. /**
  87630. * Gets a boolean indicating if color writing is enabled
  87631. * @returns the current color writing state
  87632. */
  87633. getColorWrite(): boolean;
  87634. /**
  87635. * Sets alpha constants used by some alpha blending modes
  87636. * @param r defines the red component
  87637. * @param g defines the green component
  87638. * @param b defines the blue component
  87639. * @param a defines the alpha component
  87640. */
  87641. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  87642. /**
  87643. * Sets the current alpha mode
  87644. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  87645. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  87646. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87647. */
  87648. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  87649. /**
  87650. * Gets the current alpha mode
  87651. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87652. * @returns the current alpha mode
  87653. */
  87654. getAlphaMode(): number;
  87655. /**
  87656. * Clears the list of texture accessible through engine.
  87657. * This can help preventing texture load conflict due to name collision.
  87658. */
  87659. clearInternalTexturesCache(): void;
  87660. /**
  87661. * Force the entire cache to be cleared
  87662. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  87663. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  87664. */
  87665. wipeCaches(bruteForce?: boolean): void;
  87666. /**
  87667. * Set the compressed texture format to use, based on the formats you have, and the formats
  87668. * supported by the hardware / browser.
  87669. *
  87670. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  87671. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  87672. * to API arguments needed to compressed textures. This puts the burden on the container
  87673. * generator to house the arcane code for determining these for current & future formats.
  87674. *
  87675. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  87676. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  87677. *
  87678. * Note: The result of this call is not taken into account when a texture is base64.
  87679. *
  87680. * @param formatsAvailable defines the list of those format families you have created
  87681. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  87682. *
  87683. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  87684. * @returns The extension selected.
  87685. */
  87686. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  87687. private _getSamplingParameters;
  87688. private _partialLoadImg;
  87689. private _cascadeLoadImgs;
  87690. /** @hidden */
  87691. _createTexture(): WebGLTexture;
  87692. /**
  87693. * Usually called from Texture.ts.
  87694. * Passed information to create a WebGLTexture
  87695. * @param urlArg defines a value which contains one of the following:
  87696. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  87697. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  87698. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  87699. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  87700. * @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)
  87701. * @param scene needed for loading to the correct scene
  87702. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  87703. * @param onLoad optional callback to be called upon successful completion
  87704. * @param onError optional callback to be called upon failure
  87705. * @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
  87706. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  87707. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  87708. * @param forcedExtension defines the extension to use to pick the right loader
  87709. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  87710. * @returns a InternalTexture for assignment back into BABYLON.Texture
  87711. */
  87712. 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;
  87713. private _rescaleTexture;
  87714. /**
  87715. * Update a raw texture
  87716. * @param texture defines the texture to update
  87717. * @param data defines the data to store in the texture
  87718. * @param format defines the format of the data
  87719. * @param invertY defines if data must be stored with Y axis inverted
  87720. * @param compression defines the compression used (null by default)
  87721. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87722. */
  87723. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  87724. /**
  87725. * Creates a raw texture
  87726. * @param data defines the data to store in the texture
  87727. * @param width defines the width of the texture
  87728. * @param height defines the height of the texture
  87729. * @param format defines the format of the data
  87730. * @param generateMipMaps defines if the engine should generate the mip levels
  87731. * @param invertY defines if data must be stored with Y axis inverted
  87732. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87733. * @param compression defines the compression used (null by default)
  87734. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87735. * @returns the raw texture inside an InternalTexture
  87736. */
  87737. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  87738. private _unpackFlipYCached;
  87739. /**
  87740. * In case you are sharing the context with other applications, it might
  87741. * be interested to not cache the unpack flip y state to ensure a consistent
  87742. * value would be set.
  87743. */
  87744. enableUnpackFlipYCached: boolean;
  87745. /** @hidden */
  87746. _unpackFlipY(value: boolean): void;
  87747. /** @hidden */
  87748. _getUnpackAlignement(): number;
  87749. /**
  87750. * Creates a dynamic texture
  87751. * @param width defines the width of the texture
  87752. * @param height defines the height of the texture
  87753. * @param generateMipMaps defines if the engine should generate the mip levels
  87754. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87755. * @returns the dynamic texture inside an InternalTexture
  87756. */
  87757. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87758. /**
  87759. * Update the sampling mode of a given texture
  87760. * @param samplingMode defines the required sampling mode
  87761. * @param texture defines the texture to update
  87762. */
  87763. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  87764. /**
  87765. * Update the content of a dynamic texture
  87766. * @param texture defines the texture to update
  87767. * @param canvas defines the canvas containing the source
  87768. * @param invertY defines if data must be stored with Y axis inverted
  87769. * @param premulAlpha defines if alpha is stored as premultiplied
  87770. * @param format defines the format of the data
  87771. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87772. */
  87773. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87774. /**
  87775. * Update a video texture
  87776. * @param texture defines the texture to update
  87777. * @param video defines the video element to use
  87778. * @param invertY defines if data must be stored with Y axis inverted
  87779. */
  87780. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  87781. /**
  87782. * Updates a depth texture Comparison Mode and Function.
  87783. * If the comparison Function is equal to 0, the mode will be set to none.
  87784. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  87785. * @param texture The texture to set the comparison function for
  87786. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  87787. */
  87788. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  87789. private _setupDepthStencilTexture;
  87790. /**
  87791. * Creates a depth stencil texture.
  87792. * This is only available in WebGL 2 or with the depth texture extension available.
  87793. * @param size The size of face edge in the texture.
  87794. * @param options The options defining the texture.
  87795. * @returns The texture
  87796. */
  87797. createDepthStencilTexture(size: number | {
  87798. width: number;
  87799. height: number;
  87800. }, options: DepthTextureCreationOptions): InternalTexture;
  87801. /**
  87802. * Creates a depth stencil texture.
  87803. * This is only available in WebGL 2 or with the depth texture extension available.
  87804. * @param size The size of face edge in the texture.
  87805. * @param options The options defining the texture.
  87806. * @returns The texture
  87807. */
  87808. private _createDepthStencilTexture;
  87809. /**
  87810. * Creates a depth stencil cube texture.
  87811. * This is only available in WebGL 2.
  87812. * @param size The size of face edge in the cube texture.
  87813. * @param options The options defining the cube texture.
  87814. * @returns The cube texture
  87815. */
  87816. private _createDepthStencilCubeTexture;
  87817. /**
  87818. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  87819. * @param renderTarget The render target to set the frame buffer for
  87820. */
  87821. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  87822. /**
  87823. * Creates a new render target texture
  87824. * @param size defines the size of the texture
  87825. * @param options defines the options used to create the texture
  87826. * @returns a new render target texture stored in an InternalTexture
  87827. */
  87828. createRenderTargetTexture(size: number | {
  87829. width: number;
  87830. height: number;
  87831. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87832. /**
  87833. * Create a multi render target texture
  87834. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  87835. * @param size defines the size of the texture
  87836. * @param options defines the creation options
  87837. * @returns the cube texture as an InternalTexture
  87838. */
  87839. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  87840. private _setupFramebufferDepthAttachments;
  87841. /**
  87842. * Updates the sample count of a render target texture
  87843. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87844. * @param texture defines the texture to update
  87845. * @param samples defines the sample count to set
  87846. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87847. */
  87848. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  87849. /**
  87850. * Update the sample count for a given multiple render target texture
  87851. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87852. * @param textures defines the textures to update
  87853. * @param samples defines the sample count to set
  87854. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87855. */
  87856. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  87857. /** @hidden */
  87858. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87859. /** @hidden */
  87860. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87861. /** @hidden */
  87862. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87863. /** @hidden */
  87864. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  87865. /**
  87866. * Creates a new render target cube texture
  87867. * @param size defines the size of the texture
  87868. * @param options defines the options used to create the texture
  87869. * @returns a new render target cube texture stored in an InternalTexture
  87870. */
  87871. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87872. /**
  87873. * Creates a cube texture
  87874. * @param rootUrl defines the url where the files to load is located
  87875. * @param scene defines the current scene
  87876. * @param files defines the list of files to load (1 per face)
  87877. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87878. * @param onLoad defines an optional callback raised when the texture is loaded
  87879. * @param onError defines an optional callback raised if there is an issue to load the texture
  87880. * @param format defines the format of the data
  87881. * @param forcedExtension defines the extension to use to pick the right loader
  87882. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87883. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87884. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87885. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87886. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  87887. * @returns the cube texture as an InternalTexture
  87888. */
  87889. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  87890. /**
  87891. * @hidden
  87892. */
  87893. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87894. /**
  87895. * Update a raw cube texture
  87896. * @param texture defines the texture to udpdate
  87897. * @param data defines the data to store
  87898. * @param format defines the data format
  87899. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87900. * @param invertY defines if data must be stored with Y axis inverted
  87901. * @param compression defines the compression used (null by default)
  87902. * @param level defines which level of the texture to update
  87903. */
  87904. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  87905. /**
  87906. * Creates a new raw cube texture
  87907. * @param data defines the array of data to use to create each face
  87908. * @param size defines the size of the textures
  87909. * @param format defines the format of the data
  87910. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87911. * @param generateMipMaps defines if the engine should generate the mip levels
  87912. * @param invertY defines if data must be stored with Y axis inverted
  87913. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87914. * @param compression defines the compression used (null by default)
  87915. * @returns the cube texture as an InternalTexture
  87916. */
  87917. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  87918. /**
  87919. * Creates a new raw cube texture from a specified url
  87920. * @param url defines the url where the data is located
  87921. * @param scene defines the current scene
  87922. * @param size defines the size of the textures
  87923. * @param format defines the format of the data
  87924. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  87925. * @param noMipmap defines if the engine should avoid generating the mip levels
  87926. * @param callback defines a callback used to extract texture data from loaded data
  87927. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  87928. * @param onLoad defines a callback called when texture is loaded
  87929. * @param onError defines a callback called if there is an error
  87930. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87931. * @param invertY defines if data must be stored with Y axis inverted
  87932. * @returns the cube texture as an InternalTexture
  87933. */
  87934. 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;
  87935. /**
  87936. * Update a raw 3D texture
  87937. * @param texture defines the texture to update
  87938. * @param data defines the data to store
  87939. * @param format defines the data format
  87940. * @param invertY defines if data must be stored with Y axis inverted
  87941. * @param compression defines the used compression (can be null)
  87942. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  87943. */
  87944. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  87945. /**
  87946. * Creates a new raw 3D texture
  87947. * @param data defines the data used to create the texture
  87948. * @param width defines the width of the texture
  87949. * @param height defines the height of the texture
  87950. * @param depth defines the depth of the texture
  87951. * @param format defines the format of the texture
  87952. * @param generateMipMaps defines if the engine must generate mip levels
  87953. * @param invertY defines if data must be stored with Y axis inverted
  87954. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  87955. * @param compression defines the compressed used (can be null)
  87956. * @param textureType defines the compressed used (can be null)
  87957. * @returns a new raw 3D texture (stored in an InternalTexture)
  87958. */
  87959. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  87960. private _prepareWebGLTextureContinuation;
  87961. private _prepareWebGLTexture;
  87962. private _convertRGBtoRGBATextureData;
  87963. /** @hidden */
  87964. _releaseFramebufferObjects(texture: InternalTexture): void;
  87965. /** @hidden */
  87966. _releaseTexture(texture: InternalTexture): void;
  87967. private setProgram;
  87968. private _boundUniforms;
  87969. /**
  87970. * Binds an effect to the webGL context
  87971. * @param effect defines the effect to bind
  87972. */
  87973. bindSamplers(effect: Effect): void;
  87974. private _activateCurrentTexture;
  87975. /** @hidden */
  87976. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  87977. /** @hidden */
  87978. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  87979. /**
  87980. * Sets a texture to the webGL context from a postprocess
  87981. * @param channel defines the channel to use
  87982. * @param postProcess defines the source postprocess
  87983. */
  87984. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  87985. /**
  87986. * Binds the output of the passed in post process to the texture channel specified
  87987. * @param channel The channel the texture should be bound to
  87988. * @param postProcess The post process which's output should be bound
  87989. */
  87990. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  87991. /**
  87992. * Unbind all textures from the webGL context
  87993. */
  87994. unbindAllTextures(): void;
  87995. /**
  87996. * Sets a texture to the according uniform.
  87997. * @param channel The texture channel
  87998. * @param uniform The uniform to set
  87999. * @param texture The texture to apply
  88000. */
  88001. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88002. /**
  88003. * Sets a depth stencil texture from a render target to the according uniform.
  88004. * @param channel The texture channel
  88005. * @param uniform The uniform to set
  88006. * @param texture The render target texture containing the depth stencil texture to apply
  88007. */
  88008. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88009. private _bindSamplerUniformToChannel;
  88010. private _getTextureWrapMode;
  88011. private _setTexture;
  88012. /**
  88013. * Sets an array of texture to the webGL context
  88014. * @param channel defines the channel where the texture array must be set
  88015. * @param uniform defines the associated uniform location
  88016. * @param textures defines the array of textures to bind
  88017. */
  88018. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88019. /** @hidden */
  88020. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88021. private _setTextureParameterFloat;
  88022. private _setTextureParameterInteger;
  88023. /**
  88024. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88025. * @param x defines the x coordinate of the rectangle where pixels must be read
  88026. * @param y defines the y coordinate of the rectangle where pixels must be read
  88027. * @param width defines the width of the rectangle where pixels must be read
  88028. * @param height defines the height of the rectangle where pixels must be read
  88029. * @returns a Uint8Array containing RGBA colors
  88030. */
  88031. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88032. /**
  88033. * Add an externaly attached data from its key.
  88034. * This method call will fail and return false, if such key already exists.
  88035. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88036. * @param key the unique key that identifies the data
  88037. * @param data the data object to associate to the key for this Engine instance
  88038. * @return true if no such key were already present and the data was added successfully, false otherwise
  88039. */
  88040. addExternalData<T>(key: string, data: T): boolean;
  88041. /**
  88042. * Get an externaly attached data from its key
  88043. * @param key the unique key that identifies the data
  88044. * @return the associated data, if present (can be null), or undefined if not present
  88045. */
  88046. getExternalData<T>(key: string): T;
  88047. /**
  88048. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88049. * @param key the unique key that identifies the data
  88050. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88051. * @return the associated data, can be null if the factory returned null.
  88052. */
  88053. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88054. /**
  88055. * Remove an externaly attached data from the Engine instance
  88056. * @param key the unique key that identifies the data
  88057. * @return true if the data was successfully removed, false if it doesn't exist
  88058. */
  88059. removeExternalData(key: string): boolean;
  88060. /**
  88061. * Unbind all vertex attributes from the webGL context
  88062. */
  88063. unbindAllAttributes(): void;
  88064. /**
  88065. * 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
  88066. */
  88067. releaseEffects(): void;
  88068. /**
  88069. * Dispose and release all associated resources
  88070. */
  88071. dispose(): void;
  88072. /**
  88073. * Display the loading screen
  88074. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88075. */
  88076. displayLoadingUI(): void;
  88077. /**
  88078. * Hide the loading screen
  88079. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88080. */
  88081. hideLoadingUI(): void;
  88082. /**
  88083. * Gets the current loading screen object
  88084. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88085. */
  88086. /**
  88087. * Sets the current loading screen object
  88088. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88089. */
  88090. loadingScreen: ILoadingScreen;
  88091. /**
  88092. * Sets the current loading screen text
  88093. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88094. */
  88095. loadingUIText: string;
  88096. /**
  88097. * Sets the current loading screen background color
  88098. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88099. */
  88100. loadingUIBackgroundColor: string;
  88101. /**
  88102. * Attach a new callback raised when context lost event is fired
  88103. * @param callback defines the callback to call
  88104. */
  88105. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88106. /**
  88107. * Attach a new callback raised when context restored event is fired
  88108. * @param callback defines the callback to call
  88109. */
  88110. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88111. /**
  88112. * Gets the source code of the vertex shader associated with a specific webGL program
  88113. * @param program defines the program to use
  88114. * @returns a string containing the source code of the vertex shader associated with the program
  88115. */
  88116. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88117. /**
  88118. * Gets the source code of the fragment shader associated with a specific webGL program
  88119. * @param program defines the program to use
  88120. * @returns a string containing the source code of the fragment shader associated with the program
  88121. */
  88122. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88123. /**
  88124. * Get the current error code of the webGL context
  88125. * @returns the error code
  88126. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88127. */
  88128. getError(): number;
  88129. /**
  88130. * Gets the current framerate
  88131. * @returns a number representing the framerate
  88132. */
  88133. getFps(): number;
  88134. /**
  88135. * Gets the time spent between current and previous frame
  88136. * @returns a number representing the delta time in ms
  88137. */
  88138. getDeltaTime(): number;
  88139. private _measureFps;
  88140. /** @hidden */
  88141. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88142. private _canRenderToFloatFramebuffer;
  88143. private _canRenderToHalfFloatFramebuffer;
  88144. private _canRenderToFramebuffer;
  88145. /** @hidden */
  88146. _getWebGLTextureType(type: number): number;
  88147. private _getInternalFormat;
  88148. /** @hidden */
  88149. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88150. /** @hidden */
  88151. _getRGBAMultiSampleBufferFormat(type: number): number;
  88152. /** @hidden */
  88153. _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;
  88154. /** @hidden */
  88155. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88156. private _partialLoadFile;
  88157. private _cascadeLoadFiles;
  88158. /**
  88159. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88160. * @returns true if the engine can be created
  88161. * @ignorenaming
  88162. */
  88163. static isSupported(): boolean;
  88164. }
  88165. }
  88166. declare module BABYLON {
  88167. /**
  88168. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88169. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88170. */
  88171. export class EffectFallbacks {
  88172. private _defines;
  88173. private _currentRank;
  88174. private _maxRank;
  88175. private _mesh;
  88176. /**
  88177. * Removes the fallback from the bound mesh.
  88178. */
  88179. unBindMesh(): void;
  88180. /**
  88181. * Adds a fallback on the specified property.
  88182. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88183. * @param define The name of the define in the shader
  88184. */
  88185. addFallback(rank: number, define: string): void;
  88186. /**
  88187. * Sets the mesh to use CPU skinning when needing to fallback.
  88188. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88189. * @param mesh The mesh to use the fallbacks.
  88190. */
  88191. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88192. /**
  88193. * Checks to see if more fallbacks are still availible.
  88194. */
  88195. readonly isMoreFallbacks: boolean;
  88196. /**
  88197. * Removes the defines that shoould be removed when falling back.
  88198. * @param currentDefines defines the current define statements for the shader.
  88199. * @param effect defines the current effect we try to compile
  88200. * @returns The resulting defines with defines of the current rank removed.
  88201. */
  88202. reduce(currentDefines: string, effect: Effect): string;
  88203. }
  88204. /**
  88205. * Options to be used when creating an effect.
  88206. */
  88207. export class EffectCreationOptions {
  88208. /**
  88209. * Atrributes that will be used in the shader.
  88210. */
  88211. attributes: string[];
  88212. /**
  88213. * Uniform varible names that will be set in the shader.
  88214. */
  88215. uniformsNames: string[];
  88216. /**
  88217. * Uniform buffer varible names that will be set in the shader.
  88218. */
  88219. uniformBuffersNames: string[];
  88220. /**
  88221. * Sampler texture variable names that will be set in the shader.
  88222. */
  88223. samplers: string[];
  88224. /**
  88225. * Define statements that will be set in the shader.
  88226. */
  88227. defines: any;
  88228. /**
  88229. * Possible fallbacks for this effect to improve performance when needed.
  88230. */
  88231. fallbacks: Nullable<EffectFallbacks>;
  88232. /**
  88233. * Callback that will be called when the shader is compiled.
  88234. */
  88235. onCompiled: Nullable<(effect: Effect) => void>;
  88236. /**
  88237. * Callback that will be called if an error occurs during shader compilation.
  88238. */
  88239. onError: Nullable<(effect: Effect, errors: string) => void>;
  88240. /**
  88241. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88242. */
  88243. indexParameters: any;
  88244. /**
  88245. * Max number of lights that can be used in the shader.
  88246. */
  88247. maxSimultaneousLights: number;
  88248. /**
  88249. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88250. */
  88251. transformFeedbackVaryings: Nullable<string[]>;
  88252. }
  88253. /**
  88254. * Effect containing vertex and fragment shader that can be executed on an object.
  88255. */
  88256. export class Effect {
  88257. /**
  88258. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88259. */
  88260. static ShadersRepository: string;
  88261. /**
  88262. * Name of the effect.
  88263. */
  88264. name: any;
  88265. /**
  88266. * String container all the define statements that should be set on the shader.
  88267. */
  88268. defines: string;
  88269. /**
  88270. * Callback that will be called when the shader is compiled.
  88271. */
  88272. onCompiled: Nullable<(effect: Effect) => void>;
  88273. /**
  88274. * Callback that will be called if an error occurs during shader compilation.
  88275. */
  88276. onError: Nullable<(effect: Effect, errors: string) => void>;
  88277. /**
  88278. * Callback that will be called when effect is bound.
  88279. */
  88280. onBind: Nullable<(effect: Effect) => void>;
  88281. /**
  88282. * Unique ID of the effect.
  88283. */
  88284. uniqueId: number;
  88285. /**
  88286. * Observable that will be called when the shader is compiled.
  88287. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  88288. */
  88289. onCompileObservable: Observable<Effect>;
  88290. /**
  88291. * Observable that will be called if an error occurs during shader compilation.
  88292. */
  88293. onErrorObservable: Observable<Effect>;
  88294. /** @hidden */
  88295. _onBindObservable: Nullable<Observable<Effect>>;
  88296. /**
  88297. * Observable that will be called when effect is bound.
  88298. */
  88299. readonly onBindObservable: Observable<Effect>;
  88300. /** @hidden */
  88301. _bonesComputationForcedToCPU: boolean;
  88302. private static _uniqueIdSeed;
  88303. private _engine;
  88304. private _uniformBuffersNames;
  88305. private _uniformsNames;
  88306. private _samplers;
  88307. private _isReady;
  88308. private _compilationError;
  88309. private _attributesNames;
  88310. private _attributes;
  88311. private _uniforms;
  88312. /**
  88313. * Key for the effect.
  88314. * @hidden
  88315. */
  88316. _key: string;
  88317. private _indexParameters;
  88318. private _fallbacks;
  88319. private _vertexSourceCode;
  88320. private _fragmentSourceCode;
  88321. private _vertexSourceCodeOverride;
  88322. private _fragmentSourceCodeOverride;
  88323. private _transformFeedbackVaryings;
  88324. /**
  88325. * Compiled shader to webGL program.
  88326. * @hidden
  88327. */
  88328. _program: WebGLProgram;
  88329. private _valueCache;
  88330. private static _baseCache;
  88331. /**
  88332. * Instantiates an effect.
  88333. * An effect can be used to create/manage/execute vertex and fragment shaders.
  88334. * @param baseName Name of the effect.
  88335. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  88336. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  88337. * @param samplers List of sampler variables that will be passed to the shader.
  88338. * @param engine Engine to be used to render the effect
  88339. * @param defines Define statements to be added to the shader.
  88340. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  88341. * @param onCompiled Callback that will be called when the shader is compiled.
  88342. * @param onError Callback that will be called if an error occurs during shader compilation.
  88343. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88344. */
  88345. 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);
  88346. /**
  88347. * Unique key for this effect
  88348. */
  88349. readonly key: string;
  88350. /**
  88351. * If the effect has been compiled and prepared.
  88352. * @returns if the effect is compiled and prepared.
  88353. */
  88354. isReady(): boolean;
  88355. /**
  88356. * The engine the effect was initialized with.
  88357. * @returns the engine.
  88358. */
  88359. getEngine(): Engine;
  88360. /**
  88361. * The compiled webGL program for the effect
  88362. * @returns the webGL program.
  88363. */
  88364. getProgram(): WebGLProgram;
  88365. /**
  88366. * The set of names of attribute variables for the shader.
  88367. * @returns An array of attribute names.
  88368. */
  88369. getAttributesNames(): string[];
  88370. /**
  88371. * Returns the attribute at the given index.
  88372. * @param index The index of the attribute.
  88373. * @returns The location of the attribute.
  88374. */
  88375. getAttributeLocation(index: number): number;
  88376. /**
  88377. * Returns the attribute based on the name of the variable.
  88378. * @param name of the attribute to look up.
  88379. * @returns the attribute location.
  88380. */
  88381. getAttributeLocationByName(name: string): number;
  88382. /**
  88383. * The number of attributes.
  88384. * @returns the numnber of attributes.
  88385. */
  88386. getAttributesCount(): number;
  88387. /**
  88388. * Gets the index of a uniform variable.
  88389. * @param uniformName of the uniform to look up.
  88390. * @returns the index.
  88391. */
  88392. getUniformIndex(uniformName: string): number;
  88393. /**
  88394. * Returns the attribute based on the name of the variable.
  88395. * @param uniformName of the uniform to look up.
  88396. * @returns the location of the uniform.
  88397. */
  88398. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  88399. /**
  88400. * Returns an array of sampler variable names
  88401. * @returns The array of sampler variable neames.
  88402. */
  88403. getSamplers(): string[];
  88404. /**
  88405. * The error from the last compilation.
  88406. * @returns the error string.
  88407. */
  88408. getCompilationError(): string;
  88409. /**
  88410. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  88411. * @param func The callback to be used.
  88412. */
  88413. executeWhenCompiled(func: (effect: Effect) => void): void;
  88414. private _checkIsReady;
  88415. /** @hidden */
  88416. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  88417. /** @hidden */
  88418. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  88419. /** @hidden */
  88420. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  88421. private _processShaderConversion;
  88422. private _processIncludes;
  88423. private _processPrecision;
  88424. /**
  88425. * Recompiles the webGL program
  88426. * @param vertexSourceCode The source code for the vertex shader.
  88427. * @param fragmentSourceCode The source code for the fragment shader.
  88428. * @param onCompiled Callback called when completed.
  88429. * @param onError Callback called on error.
  88430. * @hidden
  88431. */
  88432. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  88433. /**
  88434. * Gets the uniform locations of the the specified variable names
  88435. * @param names THe names of the variables to lookup.
  88436. * @returns Array of locations in the same order as variable names.
  88437. */
  88438. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  88439. /**
  88440. * Prepares the effect
  88441. * @hidden
  88442. */
  88443. _prepareEffect(): void;
  88444. /**
  88445. * Checks if the effect is supported. (Must be called after compilation)
  88446. */
  88447. readonly isSupported: boolean;
  88448. /**
  88449. * Binds a texture to the engine to be used as output of the shader.
  88450. * @param channel Name of the output variable.
  88451. * @param texture Texture to bind.
  88452. * @hidden
  88453. */
  88454. _bindTexture(channel: string, texture: InternalTexture): void;
  88455. /**
  88456. * Sets a texture on the engine to be used in the shader.
  88457. * @param channel Name of the sampler variable.
  88458. * @param texture Texture to set.
  88459. */
  88460. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  88461. /**
  88462. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  88463. * @param channel Name of the sampler variable.
  88464. * @param texture Texture to set.
  88465. */
  88466. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  88467. /**
  88468. * Sets an array of textures on the engine to be used in the shader.
  88469. * @param channel Name of the variable.
  88470. * @param textures Textures to set.
  88471. */
  88472. setTextureArray(channel: string, textures: BaseTexture[]): void;
  88473. /**
  88474. * 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)
  88475. * @param channel Name of the sampler variable.
  88476. * @param postProcess Post process to get the input texture from.
  88477. */
  88478. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  88479. /**
  88480. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  88481. * 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)
  88482. * @param channel Name of the sampler variable.
  88483. * @param postProcess Post process to get the output texture from.
  88484. */
  88485. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  88486. /** @hidden */
  88487. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  88488. /** @hidden */
  88489. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  88490. /** @hidden */
  88491. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  88492. /** @hidden */
  88493. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  88494. /**
  88495. * Binds a buffer to a uniform.
  88496. * @param buffer Buffer to bind.
  88497. * @param name Name of the uniform variable to bind to.
  88498. */
  88499. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  88500. /**
  88501. * Binds block to a uniform.
  88502. * @param blockName Name of the block to bind.
  88503. * @param index Index to bind.
  88504. */
  88505. bindUniformBlock(blockName: string, index: number): void;
  88506. /**
  88507. * Sets an interger value on a uniform variable.
  88508. * @param uniformName Name of the variable.
  88509. * @param value Value to be set.
  88510. * @returns this effect.
  88511. */
  88512. setInt(uniformName: string, value: number): Effect;
  88513. /**
  88514. * Sets an int array on a uniform variable.
  88515. * @param uniformName Name of the variable.
  88516. * @param array array to be set.
  88517. * @returns this effect.
  88518. */
  88519. setIntArray(uniformName: string, array: Int32Array): Effect;
  88520. /**
  88521. * 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)
  88522. * @param uniformName Name of the variable.
  88523. * @param array array to be set.
  88524. * @returns this effect.
  88525. */
  88526. setIntArray2(uniformName: string, array: Int32Array): Effect;
  88527. /**
  88528. * 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)
  88529. * @param uniformName Name of the variable.
  88530. * @param array array to be set.
  88531. * @returns this effect.
  88532. */
  88533. setIntArray3(uniformName: string, array: Int32Array): Effect;
  88534. /**
  88535. * 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)
  88536. * @param uniformName Name of the variable.
  88537. * @param array array to be set.
  88538. * @returns this effect.
  88539. */
  88540. setIntArray4(uniformName: string, array: Int32Array): Effect;
  88541. /**
  88542. * Sets an float array on a uniform variable.
  88543. * @param uniformName Name of the variable.
  88544. * @param array array to be set.
  88545. * @returns this effect.
  88546. */
  88547. setFloatArray(uniformName: string, array: Float32Array): Effect;
  88548. /**
  88549. * 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)
  88550. * @param uniformName Name of the variable.
  88551. * @param array array to be set.
  88552. * @returns this effect.
  88553. */
  88554. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  88555. /**
  88556. * 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)
  88557. * @param uniformName Name of the variable.
  88558. * @param array array to be set.
  88559. * @returns this effect.
  88560. */
  88561. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  88562. /**
  88563. * 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)
  88564. * @param uniformName Name of the variable.
  88565. * @param array array to be set.
  88566. * @returns this effect.
  88567. */
  88568. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  88569. /**
  88570. * Sets an array on a uniform variable.
  88571. * @param uniformName Name of the variable.
  88572. * @param array array to be set.
  88573. * @returns this effect.
  88574. */
  88575. setArray(uniformName: string, array: number[]): Effect;
  88576. /**
  88577. * 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)
  88578. * @param uniformName Name of the variable.
  88579. * @param array array to be set.
  88580. * @returns this effect.
  88581. */
  88582. setArray2(uniformName: string, array: number[]): Effect;
  88583. /**
  88584. * 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)
  88585. * @param uniformName Name of the variable.
  88586. * @param array array to be set.
  88587. * @returns this effect.
  88588. */
  88589. setArray3(uniformName: string, array: number[]): Effect;
  88590. /**
  88591. * 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)
  88592. * @param uniformName Name of the variable.
  88593. * @param array array to be set.
  88594. * @returns this effect.
  88595. */
  88596. setArray4(uniformName: string, array: number[]): Effect;
  88597. /**
  88598. * Sets matrices on a uniform variable.
  88599. * @param uniformName Name of the variable.
  88600. * @param matrices matrices to be set.
  88601. * @returns this effect.
  88602. */
  88603. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  88604. /**
  88605. * Sets matrix on a uniform variable.
  88606. * @param uniformName Name of the variable.
  88607. * @param matrix matrix to be set.
  88608. * @returns this effect.
  88609. */
  88610. setMatrix(uniformName: string, matrix: Matrix): Effect;
  88611. /**
  88612. * 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)
  88613. * @param uniformName Name of the variable.
  88614. * @param matrix matrix to be set.
  88615. * @returns this effect.
  88616. */
  88617. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  88618. /**
  88619. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  88620. * @param uniformName Name of the variable.
  88621. * @param matrix matrix to be set.
  88622. * @returns this effect.
  88623. */
  88624. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  88625. /**
  88626. * Sets a float on a uniform variable.
  88627. * @param uniformName Name of the variable.
  88628. * @param value value to be set.
  88629. * @returns this effect.
  88630. */
  88631. setFloat(uniformName: string, value: number): Effect;
  88632. /**
  88633. * Sets a boolean on a uniform variable.
  88634. * @param uniformName Name of the variable.
  88635. * @param bool value to be set.
  88636. * @returns this effect.
  88637. */
  88638. setBool(uniformName: string, bool: boolean): Effect;
  88639. /**
  88640. * Sets a Vector2 on a uniform variable.
  88641. * @param uniformName Name of the variable.
  88642. * @param vector2 vector2 to be set.
  88643. * @returns this effect.
  88644. */
  88645. setVector2(uniformName: string, vector2: Vector2): Effect;
  88646. /**
  88647. * Sets a float2 on a uniform variable.
  88648. * @param uniformName Name of the variable.
  88649. * @param x First float in float2.
  88650. * @param y Second float in float2.
  88651. * @returns this effect.
  88652. */
  88653. setFloat2(uniformName: string, x: number, y: number): Effect;
  88654. /**
  88655. * Sets a Vector3 on a uniform variable.
  88656. * @param uniformName Name of the variable.
  88657. * @param vector3 Value to be set.
  88658. * @returns this effect.
  88659. */
  88660. setVector3(uniformName: string, vector3: Vector3): Effect;
  88661. /**
  88662. * Sets a float3 on a uniform variable.
  88663. * @param uniformName Name of the variable.
  88664. * @param x First float in float3.
  88665. * @param y Second float in float3.
  88666. * @param z Third float in float3.
  88667. * @returns this effect.
  88668. */
  88669. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  88670. /**
  88671. * Sets a Vector4 on a uniform variable.
  88672. * @param uniformName Name of the variable.
  88673. * @param vector4 Value to be set.
  88674. * @returns this effect.
  88675. */
  88676. setVector4(uniformName: string, vector4: Vector4): Effect;
  88677. /**
  88678. * Sets a float4 on a uniform variable.
  88679. * @param uniformName Name of the variable.
  88680. * @param x First float in float4.
  88681. * @param y Second float in float4.
  88682. * @param z Third float in float4.
  88683. * @param w Fourth float in float4.
  88684. * @returns this effect.
  88685. */
  88686. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  88687. /**
  88688. * Sets a Color3 on a uniform variable.
  88689. * @param uniformName Name of the variable.
  88690. * @param color3 Value to be set.
  88691. * @returns this effect.
  88692. */
  88693. setColor3(uniformName: string, color3: Color3): Effect;
  88694. /**
  88695. * Sets a Color4 on a uniform variable.
  88696. * @param uniformName Name of the variable.
  88697. * @param color3 Value to be set.
  88698. * @param alpha Alpha value to be set.
  88699. * @returns this effect.
  88700. */
  88701. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  88702. /**
  88703. * Sets a Color4 on a uniform variable
  88704. * @param uniformName defines the name of the variable
  88705. * @param color4 defines the value to be set
  88706. * @returns this effect.
  88707. */
  88708. setDirectColor4(uniformName: string, color4: Color4): Effect;
  88709. /**
  88710. * This function will add a new shader to the shader store
  88711. * @param name the name of the shader
  88712. * @param pixelShader optional pixel shader content
  88713. * @param vertexShader optional vertex shader content
  88714. */
  88715. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  88716. /**
  88717. * Store of each shader (The can be looked up using effect.key)
  88718. */
  88719. static ShadersStore: {
  88720. [key: string]: string;
  88721. };
  88722. /**
  88723. * Store of each included file for a shader (The can be looked up using effect.key)
  88724. */
  88725. static IncludesShadersStore: {
  88726. [key: string]: string;
  88727. };
  88728. /**
  88729. * Resets the cache of effects.
  88730. */
  88731. static ResetCache(): void;
  88732. }
  88733. }
  88734. declare module BABYLON {
  88735. /**
  88736. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88737. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88738. * 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;
  88739. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88740. */
  88741. export class ColorCurves {
  88742. private _dirty;
  88743. private _tempColor;
  88744. private _globalCurve;
  88745. private _highlightsCurve;
  88746. private _midtonesCurve;
  88747. private _shadowsCurve;
  88748. private _positiveCurve;
  88749. private _negativeCurve;
  88750. private _globalHue;
  88751. private _globalDensity;
  88752. private _globalSaturation;
  88753. private _globalExposure;
  88754. /**
  88755. * Gets the global Hue value.
  88756. * 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).
  88757. */
  88758. /**
  88759. * Sets the global Hue value.
  88760. * 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).
  88761. */
  88762. globalHue: number;
  88763. /**
  88764. * Gets the global Density value.
  88765. * 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.
  88766. * Values less than zero provide a filter of opposite hue.
  88767. */
  88768. /**
  88769. * Sets the global Density value.
  88770. * 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.
  88771. * Values less than zero provide a filter of opposite hue.
  88772. */
  88773. globalDensity: number;
  88774. /**
  88775. * Gets the global Saturation value.
  88776. * 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.
  88777. */
  88778. /**
  88779. * Sets the global Saturation value.
  88780. * 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.
  88781. */
  88782. globalSaturation: number;
  88783. /**
  88784. * Gets the global Exposure value.
  88785. * 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.
  88786. */
  88787. /**
  88788. * Sets the global Exposure value.
  88789. * 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.
  88790. */
  88791. globalExposure: number;
  88792. private _highlightsHue;
  88793. private _highlightsDensity;
  88794. private _highlightsSaturation;
  88795. private _highlightsExposure;
  88796. /**
  88797. * Gets the highlights Hue value.
  88798. * 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).
  88799. */
  88800. /**
  88801. * Sets the highlights Hue value.
  88802. * 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).
  88803. */
  88804. highlightsHue: number;
  88805. /**
  88806. * Gets the highlights Density value.
  88807. * 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.
  88808. * Values less than zero provide a filter of opposite hue.
  88809. */
  88810. /**
  88811. * Sets the highlights Density value.
  88812. * 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.
  88813. * Values less than zero provide a filter of opposite hue.
  88814. */
  88815. highlightsDensity: number;
  88816. /**
  88817. * Gets the highlights Saturation value.
  88818. * 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.
  88819. */
  88820. /**
  88821. * Sets the highlights Saturation value.
  88822. * 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.
  88823. */
  88824. highlightsSaturation: number;
  88825. /**
  88826. * Gets the highlights Exposure value.
  88827. * 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.
  88828. */
  88829. /**
  88830. * Sets the highlights Exposure value.
  88831. * 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.
  88832. */
  88833. highlightsExposure: number;
  88834. private _midtonesHue;
  88835. private _midtonesDensity;
  88836. private _midtonesSaturation;
  88837. private _midtonesExposure;
  88838. /**
  88839. * Gets the midtones Hue value.
  88840. * 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).
  88841. */
  88842. /**
  88843. * Sets the midtones Hue value.
  88844. * 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).
  88845. */
  88846. midtonesHue: number;
  88847. /**
  88848. * Gets the midtones Density value.
  88849. * 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.
  88850. * Values less than zero provide a filter of opposite hue.
  88851. */
  88852. /**
  88853. * Sets the midtones Density value.
  88854. * 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.
  88855. * Values less than zero provide a filter of opposite hue.
  88856. */
  88857. midtonesDensity: number;
  88858. /**
  88859. * Gets the midtones Saturation value.
  88860. * 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.
  88861. */
  88862. /**
  88863. * Sets the midtones Saturation value.
  88864. * 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.
  88865. */
  88866. midtonesSaturation: number;
  88867. /**
  88868. * Gets the midtones Exposure value.
  88869. * 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.
  88870. */
  88871. /**
  88872. * Sets the midtones Exposure value.
  88873. * 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.
  88874. */
  88875. midtonesExposure: number;
  88876. private _shadowsHue;
  88877. private _shadowsDensity;
  88878. private _shadowsSaturation;
  88879. private _shadowsExposure;
  88880. /**
  88881. * Gets the shadows Hue value.
  88882. * 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).
  88883. */
  88884. /**
  88885. * Sets the shadows Hue value.
  88886. * 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).
  88887. */
  88888. shadowsHue: number;
  88889. /**
  88890. * Gets the shadows Density value.
  88891. * 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.
  88892. * Values less than zero provide a filter of opposite hue.
  88893. */
  88894. /**
  88895. * Sets the shadows Density value.
  88896. * 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.
  88897. * Values less than zero provide a filter of opposite hue.
  88898. */
  88899. shadowsDensity: number;
  88900. /**
  88901. * Gets the shadows Saturation value.
  88902. * 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.
  88903. */
  88904. /**
  88905. * Sets the shadows Saturation value.
  88906. * 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.
  88907. */
  88908. shadowsSaturation: number;
  88909. /**
  88910. * Gets the shadows Exposure value.
  88911. * 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.
  88912. */
  88913. /**
  88914. * Sets the shadows Exposure value.
  88915. * 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.
  88916. */
  88917. shadowsExposure: number;
  88918. /**
  88919. * Returns the class name
  88920. * @returns The class name
  88921. */
  88922. getClassName(): string;
  88923. /**
  88924. * Binds the color curves to the shader.
  88925. * @param colorCurves The color curve to bind
  88926. * @param effect The effect to bind to
  88927. * @param positiveUniform The positive uniform shader parameter
  88928. * @param neutralUniform The neutral uniform shader parameter
  88929. * @param negativeUniform The negative uniform shader parameter
  88930. */
  88931. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88932. /**
  88933. * Prepare the list of uniforms associated with the ColorCurves effects.
  88934. * @param uniformsList The list of uniforms used in the effect
  88935. */
  88936. static PrepareUniforms(uniformsList: string[]): void;
  88937. /**
  88938. * Returns color grading data based on a hue, density, saturation and exposure value.
  88939. * @param filterHue The hue of the color filter.
  88940. * @param filterDensity The density of the color filter.
  88941. * @param saturation The saturation.
  88942. * @param exposure The exposure.
  88943. * @param result The result data container.
  88944. */
  88945. private getColorGradingDataToRef;
  88946. /**
  88947. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88948. * @param value The input slider value in range [-100,100].
  88949. * @returns Adjusted value.
  88950. */
  88951. private static applyColorGradingSliderNonlinear;
  88952. /**
  88953. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88954. * @param hue The hue (H) input.
  88955. * @param saturation The saturation (S) input.
  88956. * @param brightness The brightness (B) input.
  88957. * @result An RGBA color represented as Vector4.
  88958. */
  88959. private static fromHSBToRef;
  88960. /**
  88961. * Returns a value clamped between min and max
  88962. * @param value The value to clamp
  88963. * @param min The minimum of value
  88964. * @param max The maximum of value
  88965. * @returns The clamped value.
  88966. */
  88967. private static clamp;
  88968. /**
  88969. * Clones the current color curve instance.
  88970. * @return The cloned curves
  88971. */
  88972. clone(): ColorCurves;
  88973. /**
  88974. * Serializes the current color curve instance to a json representation.
  88975. * @return a JSON representation
  88976. */
  88977. serialize(): any;
  88978. /**
  88979. * Parses the color curve from a json representation.
  88980. * @param source the JSON source to parse
  88981. * @return The parsed curves
  88982. */
  88983. static Parse(source: any): ColorCurves;
  88984. }
  88985. }
  88986. declare module BABYLON {
  88987. /**
  88988. * Interface to follow in your material defines to integrate easily the
  88989. * Image proccessing functions.
  88990. * @hidden
  88991. */
  88992. export interface IImageProcessingConfigurationDefines {
  88993. IMAGEPROCESSING: boolean;
  88994. VIGNETTE: boolean;
  88995. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88996. VIGNETTEBLENDMODEOPAQUE: boolean;
  88997. TONEMAPPING: boolean;
  88998. TONEMAPPING_ACES: boolean;
  88999. CONTRAST: boolean;
  89000. EXPOSURE: boolean;
  89001. COLORCURVES: boolean;
  89002. COLORGRADING: boolean;
  89003. COLORGRADING3D: boolean;
  89004. SAMPLER3DGREENDEPTH: boolean;
  89005. SAMPLER3DBGRMAP: boolean;
  89006. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89007. }
  89008. /**
  89009. * @hidden
  89010. */
  89011. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89012. IMAGEPROCESSING: boolean;
  89013. VIGNETTE: boolean;
  89014. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89015. VIGNETTEBLENDMODEOPAQUE: boolean;
  89016. TONEMAPPING: boolean;
  89017. TONEMAPPING_ACES: boolean;
  89018. CONTRAST: boolean;
  89019. COLORCURVES: boolean;
  89020. COLORGRADING: boolean;
  89021. COLORGRADING3D: boolean;
  89022. SAMPLER3DGREENDEPTH: boolean;
  89023. SAMPLER3DBGRMAP: boolean;
  89024. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89025. EXPOSURE: boolean;
  89026. constructor();
  89027. }
  89028. /**
  89029. * This groups together the common properties used for image processing either in direct forward pass
  89030. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89031. * or not.
  89032. */
  89033. export class ImageProcessingConfiguration {
  89034. /**
  89035. * Default tone mapping applied in BabylonJS.
  89036. */
  89037. static readonly TONEMAPPING_STANDARD: number;
  89038. /**
  89039. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89040. * to other engines rendering to increase portability.
  89041. */
  89042. static readonly TONEMAPPING_ACES: number;
  89043. /**
  89044. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89045. */
  89046. colorCurves: Nullable<ColorCurves>;
  89047. private _colorCurvesEnabled;
  89048. /**
  89049. * Gets wether the color curves effect is enabled.
  89050. */
  89051. /**
  89052. * Sets wether the color curves effect is enabled.
  89053. */
  89054. colorCurvesEnabled: boolean;
  89055. private _colorGradingTexture;
  89056. /**
  89057. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89058. */
  89059. /**
  89060. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89061. */
  89062. colorGradingTexture: Nullable<BaseTexture>;
  89063. private _colorGradingEnabled;
  89064. /**
  89065. * Gets wether the color grading effect is enabled.
  89066. */
  89067. /**
  89068. * Sets wether the color grading effect is enabled.
  89069. */
  89070. colorGradingEnabled: boolean;
  89071. private _colorGradingWithGreenDepth;
  89072. /**
  89073. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89074. */
  89075. /**
  89076. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89077. */
  89078. colorGradingWithGreenDepth: boolean;
  89079. private _colorGradingBGR;
  89080. /**
  89081. * Gets wether the color grading texture contains BGR values.
  89082. */
  89083. /**
  89084. * Sets wether the color grading texture contains BGR values.
  89085. */
  89086. colorGradingBGR: boolean;
  89087. /** @hidden */
  89088. _exposure: number;
  89089. /**
  89090. * Gets the Exposure used in the effect.
  89091. */
  89092. /**
  89093. * Sets the Exposure used in the effect.
  89094. */
  89095. exposure: number;
  89096. private _toneMappingEnabled;
  89097. /**
  89098. * Gets wether the tone mapping effect is enabled.
  89099. */
  89100. /**
  89101. * Sets wether the tone mapping effect is enabled.
  89102. */
  89103. toneMappingEnabled: boolean;
  89104. private _toneMappingType;
  89105. /**
  89106. * Gets the type of tone mapping effect.
  89107. */
  89108. /**
  89109. * Sets the type of tone mapping effect used in BabylonJS.
  89110. */
  89111. toneMappingType: number;
  89112. protected _contrast: number;
  89113. /**
  89114. * Gets the contrast used in the effect.
  89115. */
  89116. /**
  89117. * Sets the contrast used in the effect.
  89118. */
  89119. contrast: number;
  89120. /**
  89121. * Vignette stretch size.
  89122. */
  89123. vignetteStretch: number;
  89124. /**
  89125. * Vignette centre X Offset.
  89126. */
  89127. vignetteCentreX: number;
  89128. /**
  89129. * Vignette centre Y Offset.
  89130. */
  89131. vignetteCentreY: number;
  89132. /**
  89133. * Vignette weight or intensity of the vignette effect.
  89134. */
  89135. vignetteWeight: number;
  89136. /**
  89137. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89138. * if vignetteEnabled is set to true.
  89139. */
  89140. vignetteColor: Color4;
  89141. /**
  89142. * Camera field of view used by the Vignette effect.
  89143. */
  89144. vignetteCameraFov: number;
  89145. private _vignetteBlendMode;
  89146. /**
  89147. * Gets the vignette blend mode allowing different kind of effect.
  89148. */
  89149. /**
  89150. * Sets the vignette blend mode allowing different kind of effect.
  89151. */
  89152. vignetteBlendMode: number;
  89153. private _vignetteEnabled;
  89154. /**
  89155. * Gets wether the vignette effect is enabled.
  89156. */
  89157. /**
  89158. * Sets wether the vignette effect is enabled.
  89159. */
  89160. vignetteEnabled: boolean;
  89161. private _applyByPostProcess;
  89162. /**
  89163. * Gets wether the image processing is applied through a post process or not.
  89164. */
  89165. /**
  89166. * Sets wether the image processing is applied through a post process or not.
  89167. */
  89168. applyByPostProcess: boolean;
  89169. private _isEnabled;
  89170. /**
  89171. * Gets wether the image processing is enabled or not.
  89172. */
  89173. /**
  89174. * Sets wether the image processing is enabled or not.
  89175. */
  89176. isEnabled: boolean;
  89177. /**
  89178. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89179. */
  89180. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89181. /**
  89182. * Method called each time the image processing information changes requires to recompile the effect.
  89183. */
  89184. protected _updateParameters(): void;
  89185. /**
  89186. * Gets the current class name.
  89187. * @return "ImageProcessingConfiguration"
  89188. */
  89189. getClassName(): string;
  89190. /**
  89191. * Prepare the list of uniforms associated with the Image Processing effects.
  89192. * @param uniforms The list of uniforms used in the effect
  89193. * @param defines the list of defines currently in use
  89194. */
  89195. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89196. /**
  89197. * Prepare the list of samplers associated with the Image Processing effects.
  89198. * @param samplersList The list of uniforms used in the effect
  89199. * @param defines the list of defines currently in use
  89200. */
  89201. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89202. /**
  89203. * Prepare the list of defines associated to the shader.
  89204. * @param defines the list of defines to complete
  89205. * @param forPostProcess Define if we are currently in post process mode or not
  89206. */
  89207. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89208. /**
  89209. * Returns true if all the image processing information are ready.
  89210. * @returns True if ready, otherwise, false
  89211. */
  89212. isReady(): boolean;
  89213. /**
  89214. * Binds the image processing to the shader.
  89215. * @param effect The effect to bind to
  89216. * @param aspectRatio Define the current aspect ratio of the effect
  89217. */
  89218. bind(effect: Effect, aspectRatio?: number): void;
  89219. /**
  89220. * Clones the current image processing instance.
  89221. * @return The cloned image processing
  89222. */
  89223. clone(): ImageProcessingConfiguration;
  89224. /**
  89225. * Serializes the current image processing instance to a json representation.
  89226. * @return a JSON representation
  89227. */
  89228. serialize(): any;
  89229. /**
  89230. * Parses the image processing from a json representation.
  89231. * @param source the JSON source to parse
  89232. * @return The parsed image processing
  89233. */
  89234. static Parse(source: any): ImageProcessingConfiguration;
  89235. private static _VIGNETTEMODE_MULTIPLY;
  89236. private static _VIGNETTEMODE_OPAQUE;
  89237. /**
  89238. * Used to apply the vignette as a mix with the pixel color.
  89239. */
  89240. static readonly VIGNETTEMODE_MULTIPLY: number;
  89241. /**
  89242. * Used to apply the vignette as a replacement of the pixel color.
  89243. */
  89244. static readonly VIGNETTEMODE_OPAQUE: number;
  89245. }
  89246. }
  89247. declare module BABYLON {
  89248. /**
  89249. * This represents all the required information to add a fresnel effect on a material:
  89250. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89251. */
  89252. export class FresnelParameters {
  89253. private _isEnabled;
  89254. /**
  89255. * Define if the fresnel effect is enable or not.
  89256. */
  89257. isEnabled: boolean;
  89258. /**
  89259. * Define the color used on edges (grazing angle)
  89260. */
  89261. leftColor: Color3;
  89262. /**
  89263. * Define the color used on center
  89264. */
  89265. rightColor: Color3;
  89266. /**
  89267. * Define bias applied to computed fresnel term
  89268. */
  89269. bias: number;
  89270. /**
  89271. * Defined the power exponent applied to fresnel term
  89272. */
  89273. power: number;
  89274. /**
  89275. * Clones the current fresnel and its valuues
  89276. * @returns a clone fresnel configuration
  89277. */
  89278. clone(): FresnelParameters;
  89279. /**
  89280. * Serializes the current fresnel parameters to a JSON representation.
  89281. * @return the JSON serialization
  89282. */
  89283. serialize(): any;
  89284. /**
  89285. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  89286. * @param parsedFresnelParameters Define the JSON representation
  89287. * @returns the parsed parameters
  89288. */
  89289. static Parse(parsedFresnelParameters: any): FresnelParameters;
  89290. }
  89291. }
  89292. declare module BABYLON {
  89293. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  89294. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89295. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89296. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89297. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89298. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89299. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89300. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89301. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89302. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89303. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89304. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89305. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89306. /**
  89307. * Decorator used to define property that can be serialized as reference to a camera
  89308. * @param sourceName defines the name of the property to decorate
  89309. */
  89310. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89311. /**
  89312. * Class used to help serialization objects
  89313. */
  89314. export class SerializationHelper {
  89315. /** hidden */
  89316. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  89317. /** hidden */
  89318. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  89319. /** hidden */
  89320. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  89321. /** hidden */
  89322. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  89323. /**
  89324. * Appends the serialized animations from the source animations
  89325. * @param source Source containing the animations
  89326. * @param destination Target to store the animations
  89327. */
  89328. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89329. /**
  89330. * Static function used to serialized a specific entity
  89331. * @param entity defines the entity to serialize
  89332. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  89333. * @returns a JSON compatible object representing the serialization of the entity
  89334. */
  89335. static Serialize<T>(entity: T, serializationObject?: any): any;
  89336. /**
  89337. * Creates a new entity from a serialization data object
  89338. * @param creationFunction defines a function used to instanciated the new entity
  89339. * @param source defines the source serialization data
  89340. * @param scene defines the hosting scene
  89341. * @param rootUrl defines the root url for resources
  89342. * @returns a new entity
  89343. */
  89344. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  89345. /**
  89346. * Clones an object
  89347. * @param creationFunction defines the function used to instanciate the new object
  89348. * @param source defines the source object
  89349. * @returns the cloned object
  89350. */
  89351. static Clone<T>(creationFunction: () => T, source: T): T;
  89352. /**
  89353. * Instanciates a new object based on a source one (some data will be shared between both object)
  89354. * @param creationFunction defines the function used to instanciate the new object
  89355. * @param source defines the source object
  89356. * @returns the new object
  89357. */
  89358. static Instanciate<T>(creationFunction: () => T, source: T): T;
  89359. }
  89360. }
  89361. declare module BABYLON {
  89362. /**
  89363. * This is the base class of all the camera used in the application.
  89364. * @see http://doc.babylonjs.com/features/cameras
  89365. */
  89366. export class Camera extends Node {
  89367. /** @hidden */
  89368. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89369. /**
  89370. * This is the default projection mode used by the cameras.
  89371. * It helps recreating a feeling of perspective and better appreciate depth.
  89372. * This is the best way to simulate real life cameras.
  89373. */
  89374. static readonly PERSPECTIVE_CAMERA: number;
  89375. /**
  89376. * This helps creating camera with an orthographic mode.
  89377. * 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.
  89378. */
  89379. static readonly ORTHOGRAPHIC_CAMERA: number;
  89380. /**
  89381. * This is the default FOV mode for perspective cameras.
  89382. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89383. */
  89384. static readonly FOVMODE_VERTICAL_FIXED: number;
  89385. /**
  89386. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89387. */
  89388. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89389. /**
  89390. * This specifies ther is no need for a camera rig.
  89391. * Basically only one eye is rendered corresponding to the camera.
  89392. */
  89393. static readonly RIG_MODE_NONE: number;
  89394. /**
  89395. * Simulates a camera Rig with one blue eye and one red eye.
  89396. * This can be use with 3d blue and red glasses.
  89397. */
  89398. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89399. /**
  89400. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89401. */
  89402. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89403. /**
  89404. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89405. */
  89406. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89407. /**
  89408. * Defines that both eyes of the camera will be rendered over under each other.
  89409. */
  89410. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89411. /**
  89412. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89413. */
  89414. static readonly RIG_MODE_VR: number;
  89415. /**
  89416. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89417. */
  89418. static readonly RIG_MODE_WEBVR: number;
  89419. /**
  89420. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89421. */
  89422. static readonly RIG_MODE_CUSTOM: number;
  89423. /**
  89424. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89425. */
  89426. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89427. /**
  89428. * Define the input manager associated with the camera.
  89429. */
  89430. inputs: CameraInputsManager<Camera>;
  89431. /** @hidden */
  89432. _position: Vector3;
  89433. /**
  89434. * Define the current local position of the camera in the scene
  89435. */
  89436. position: Vector3;
  89437. /**
  89438. * The vector the camera should consider as up.
  89439. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89440. */
  89441. upVector: Vector3;
  89442. /**
  89443. * Define the current limit on the left side for an orthographic camera
  89444. * In scene unit
  89445. */
  89446. orthoLeft: Nullable<number>;
  89447. /**
  89448. * Define the current limit on the right side for an orthographic camera
  89449. * In scene unit
  89450. */
  89451. orthoRight: Nullable<number>;
  89452. /**
  89453. * Define the current limit on the bottom side for an orthographic camera
  89454. * In scene unit
  89455. */
  89456. orthoBottom: Nullable<number>;
  89457. /**
  89458. * Define the current limit on the top side for an orthographic camera
  89459. * In scene unit
  89460. */
  89461. orthoTop: Nullable<number>;
  89462. /**
  89463. * Field Of View is set in Radians. (default is 0.8)
  89464. */
  89465. fov: number;
  89466. /**
  89467. * Define the minimum distance the camera can see from.
  89468. * This is important to note that the depth buffer are not infinite and the closer it starts
  89469. * the more your scene might encounter depth fighting issue.
  89470. */
  89471. minZ: number;
  89472. /**
  89473. * Define the maximum distance the camera can see to.
  89474. * This is important to note that the depth buffer are not infinite and the further it end
  89475. * the more your scene might encounter depth fighting issue.
  89476. */
  89477. maxZ: number;
  89478. /**
  89479. * Define the default inertia of the camera.
  89480. * This helps giving a smooth feeling to the camera movement.
  89481. */
  89482. inertia: number;
  89483. /**
  89484. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  89485. */
  89486. mode: number;
  89487. /**
  89488. * Define wether the camera is intermediate.
  89489. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89490. */
  89491. isIntermediate: boolean;
  89492. /**
  89493. * Define the viewport of the camera.
  89494. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89495. */
  89496. viewport: Viewport;
  89497. /**
  89498. * Restricts the camera to viewing objects with the same layerMask.
  89499. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89500. */
  89501. layerMask: number;
  89502. /**
  89503. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89504. */
  89505. fovMode: number;
  89506. /**
  89507. * Rig mode of the camera.
  89508. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89509. * This is normally controlled byt the camera themselves as internal use.
  89510. */
  89511. cameraRigMode: number;
  89512. /**
  89513. * Defines the distance between both "eyes" in case of a RIG
  89514. */
  89515. interaxialDistance: number;
  89516. /**
  89517. * Defines if stereoscopic rendering is done side by side or over under.
  89518. */
  89519. isStereoscopicSideBySide: boolean;
  89520. /**
  89521. * 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
  89522. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89523. * else in the scene.
  89524. */
  89525. customRenderTargets: RenderTargetTexture[];
  89526. /**
  89527. * When set, the camera will render to this render target instead of the default canvas
  89528. */
  89529. outputRenderTarget: Nullable<RenderTargetTexture>;
  89530. /**
  89531. * Observable triggered when the camera view matrix has changed.
  89532. */
  89533. onViewMatrixChangedObservable: Observable<Camera>;
  89534. /**
  89535. * Observable triggered when the camera Projection matrix has changed.
  89536. */
  89537. onProjectionMatrixChangedObservable: Observable<Camera>;
  89538. /**
  89539. * Observable triggered when the inputs have been processed.
  89540. */
  89541. onAfterCheckInputsObservable: Observable<Camera>;
  89542. /**
  89543. * Observable triggered when reset has been called and applied to the camera.
  89544. */
  89545. onRestoreStateObservable: Observable<Camera>;
  89546. /** @hidden */
  89547. _cameraRigParams: any;
  89548. /** @hidden */
  89549. _rigCameras: Camera[];
  89550. /** @hidden */
  89551. _rigPostProcess: Nullable<PostProcess>;
  89552. protected _webvrViewMatrix: Matrix;
  89553. /** @hidden */
  89554. _skipRendering: boolean;
  89555. /** @hidden */
  89556. _projectionMatrix: Matrix;
  89557. /** @hidden */
  89558. _postProcesses: Nullable<PostProcess>[];
  89559. /** @hidden */
  89560. _activeMeshes: SmartArray<AbstractMesh>;
  89561. protected _globalPosition: Vector3;
  89562. /** hidden */
  89563. _computedViewMatrix: Matrix;
  89564. private _doNotComputeProjectionMatrix;
  89565. private _transformMatrix;
  89566. private _frustumPlanes;
  89567. private _refreshFrustumPlanes;
  89568. private _storedFov;
  89569. private _stateStored;
  89570. /**
  89571. * Instantiates a new camera object.
  89572. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89573. * @see http://doc.babylonjs.com/features/cameras
  89574. * @param name Defines the name of the camera in the scene
  89575. * @param position Defines the position of the camera
  89576. * @param scene Defines the scene the camera belongs too
  89577. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89578. */
  89579. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89580. /**
  89581. * Store current camera state (fov, position, etc..)
  89582. * @returns the camera
  89583. */
  89584. storeState(): Camera;
  89585. /**
  89586. * Restores the camera state values if it has been stored. You must call storeState() first
  89587. */
  89588. protected _restoreStateValues(): boolean;
  89589. /**
  89590. * Restored camera state. You must call storeState() first.
  89591. * @returns true if restored and false otherwise
  89592. */
  89593. restoreState(): boolean;
  89594. /**
  89595. * Gets the class name of the camera.
  89596. * @returns the class name
  89597. */
  89598. getClassName(): string;
  89599. /** @hidden */
  89600. readonly _isCamera: boolean;
  89601. /**
  89602. * Gets a string representation of the camera useful for debug purpose.
  89603. * @param fullDetails Defines that a more verboe level of logging is required
  89604. * @returns the string representation
  89605. */
  89606. toString(fullDetails?: boolean): string;
  89607. /**
  89608. * Gets the current world space position of the camera.
  89609. */
  89610. readonly globalPosition: Vector3;
  89611. /**
  89612. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89613. * @returns the active meshe list
  89614. */
  89615. getActiveMeshes(): SmartArray<AbstractMesh>;
  89616. /**
  89617. * Check wether a mesh is part of the current active mesh list of the camera
  89618. * @param mesh Defines the mesh to check
  89619. * @returns true if active, false otherwise
  89620. */
  89621. isActiveMesh(mesh: Mesh): boolean;
  89622. /**
  89623. * Is this camera ready to be used/rendered
  89624. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89625. * @return true if the camera is ready
  89626. */
  89627. isReady(completeCheck?: boolean): boolean;
  89628. /** @hidden */
  89629. _initCache(): void;
  89630. /** @hidden */
  89631. _updateCache(ignoreParentClass?: boolean): void;
  89632. /** @hidden */
  89633. _isSynchronized(): boolean;
  89634. /** @hidden */
  89635. _isSynchronizedViewMatrix(): boolean;
  89636. /** @hidden */
  89637. _isSynchronizedProjectionMatrix(): boolean;
  89638. /**
  89639. * Attach the input controls to a specific dom element to get the input from.
  89640. * @param element Defines the element the controls should be listened from
  89641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89642. */
  89643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89644. /**
  89645. * Detach the current controls from the specified dom element.
  89646. * @param element Defines the element to stop listening the inputs from
  89647. */
  89648. detachControl(element: HTMLElement): void;
  89649. /**
  89650. * Update the camera state according to the different inputs gathered during the frame.
  89651. */
  89652. update(): void;
  89653. /** @hidden */
  89654. _checkInputs(): void;
  89655. /** @hidden */
  89656. readonly rigCameras: Camera[];
  89657. /**
  89658. * Gets the post process used by the rig cameras
  89659. */
  89660. readonly rigPostProcess: Nullable<PostProcess>;
  89661. /**
  89662. * Internal, gets the first post proces.
  89663. * @returns the first post process to be run on this camera.
  89664. */
  89665. _getFirstPostProcess(): Nullable<PostProcess>;
  89666. private _cascadePostProcessesToRigCams;
  89667. /**
  89668. * Attach a post process to the camera.
  89669. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89670. * @param postProcess The post process to attach to the camera
  89671. * @param insertAt The position of the post process in case several of them are in use in the scene
  89672. * @returns the position the post process has been inserted at
  89673. */
  89674. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89675. /**
  89676. * Detach a post process to the camera.
  89677. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89678. * @param postProcess The post process to detach from the camera
  89679. */
  89680. detachPostProcess(postProcess: PostProcess): void;
  89681. /**
  89682. * Gets the current world matrix of the camera
  89683. */
  89684. getWorldMatrix(): Matrix;
  89685. /** @hidden */
  89686. _getViewMatrix(): Matrix;
  89687. /**
  89688. * Gets the current view matrix of the camera.
  89689. * @param force forces the camera to recompute the matrix without looking at the cached state
  89690. * @returns the view matrix
  89691. */
  89692. getViewMatrix(force?: boolean): Matrix;
  89693. /**
  89694. * Freeze the projection matrix.
  89695. * It will prevent the cache check of the camera projection compute and can speed up perf
  89696. * if no parameter of the camera are meant to change
  89697. * @param projection Defines manually a projection if necessary
  89698. */
  89699. freezeProjectionMatrix(projection?: Matrix): void;
  89700. /**
  89701. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89702. */
  89703. unfreezeProjectionMatrix(): void;
  89704. /**
  89705. * Gets the current projection matrix of the camera.
  89706. * @param force forces the camera to recompute the matrix without looking at the cached state
  89707. * @returns the projection matrix
  89708. */
  89709. getProjectionMatrix(force?: boolean): Matrix;
  89710. /**
  89711. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89712. * @returns a Matrix
  89713. */
  89714. getTransformationMatrix(): Matrix;
  89715. private _updateFrustumPlanes;
  89716. /**
  89717. * Checks if a cullable object (mesh...) is in the camera frustum
  89718. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89719. * @param target The object to check
  89720. * @returns true if the object is in frustum otherwise false
  89721. */
  89722. isInFrustum(target: ICullable): boolean;
  89723. /**
  89724. * Checks if a cullable object (mesh...) is in the camera frustum
  89725. * Unlike isInFrustum this cheks the full bounding box
  89726. * @param target The object to check
  89727. * @returns true if the object is in frustum otherwise false
  89728. */
  89729. isCompletelyInFrustum(target: ICullable): boolean;
  89730. /**
  89731. * Gets a ray in the forward direction from the camera.
  89732. * @param length Defines the length of the ray to create
  89733. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89734. * @param origin Defines the start point of the ray which defaults to the camera position
  89735. * @returns the forward ray
  89736. */
  89737. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89738. /**
  89739. * Releases resources associated with this node.
  89740. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89741. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89742. */
  89743. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89744. /** @hidden */
  89745. _isLeftCamera: boolean;
  89746. /**
  89747. * Gets the left camera of a rig setup in case of Rigged Camera
  89748. */
  89749. readonly isLeftCamera: boolean;
  89750. /** @hidden */
  89751. _isRightCamera: boolean;
  89752. /**
  89753. * Gets the right camera of a rig setup in case of Rigged Camera
  89754. */
  89755. readonly isRightCamera: boolean;
  89756. /**
  89757. * Gets the left camera of a rig setup in case of Rigged Camera
  89758. */
  89759. readonly leftCamera: Nullable<FreeCamera>;
  89760. /**
  89761. * Gets the right camera of a rig setup in case of Rigged Camera
  89762. */
  89763. readonly rightCamera: Nullable<FreeCamera>;
  89764. /**
  89765. * Gets the left camera target of a rig setup in case of Rigged Camera
  89766. * @returns the target position
  89767. */
  89768. getLeftTarget(): Nullable<Vector3>;
  89769. /**
  89770. * Gets the right camera target of a rig setup in case of Rigged Camera
  89771. * @returns the target position
  89772. */
  89773. getRightTarget(): Nullable<Vector3>;
  89774. /**
  89775. * @hidden
  89776. */
  89777. setCameraRigMode(mode: number, rigParams: any): void;
  89778. /** @hidden */
  89779. static _setStereoscopicRigMode(camera: Camera): void;
  89780. /** @hidden */
  89781. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89782. /** @hidden */
  89783. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89784. /** @hidden */
  89785. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89786. /** @hidden */
  89787. _getVRProjectionMatrix(): Matrix;
  89788. protected _updateCameraRotationMatrix(): void;
  89789. protected _updateWebVRCameraRotationMatrix(): void;
  89790. /**
  89791. * This function MUST be overwritten by the different WebVR cameras available.
  89792. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89793. * @hidden
  89794. */
  89795. _getWebVRProjectionMatrix(): Matrix;
  89796. /**
  89797. * This function MUST be overwritten by the different WebVR cameras available.
  89798. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89799. * @hidden
  89800. */
  89801. _getWebVRViewMatrix(): Matrix;
  89802. /** @hidden */
  89803. setCameraRigParameter(name: string, value: any): void;
  89804. /**
  89805. * needs to be overridden by children so sub has required properties to be copied
  89806. * @hidden
  89807. */
  89808. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89809. /**
  89810. * May need to be overridden by children
  89811. * @hidden
  89812. */
  89813. _updateRigCameras(): void;
  89814. /** @hidden */
  89815. _setupInputs(): void;
  89816. /**
  89817. * Serialiaze the camera setup to a json represention
  89818. * @returns the JSON representation
  89819. */
  89820. serialize(): any;
  89821. /**
  89822. * Clones the current camera.
  89823. * @param name The cloned camera name
  89824. * @returns the cloned camera
  89825. */
  89826. clone(name: string): Camera;
  89827. /**
  89828. * Gets the direction of the camera relative to a given local axis.
  89829. * @param localAxis Defines the reference axis to provide a relative direction.
  89830. * @return the direction
  89831. */
  89832. getDirection(localAxis: Vector3): Vector3;
  89833. /**
  89834. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89835. * @param localAxis Defines the reference axis to provide a relative direction.
  89836. * @param result Defines the vector to store the result in
  89837. */
  89838. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89839. /**
  89840. * Gets a camera constructor for a given camera type
  89841. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89842. * @param name The name of the camera the result will be able to instantiate
  89843. * @param scene The scene the result will construct the camera in
  89844. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89845. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89846. * @returns a factory method to construc the camera
  89847. */
  89848. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89849. /**
  89850. * Compute the world matrix of the camera.
  89851. * @returns the camera workd matrix
  89852. */
  89853. computeWorldMatrix(): Matrix;
  89854. /**
  89855. * Parse a JSON and creates the camera from the parsed information
  89856. * @param parsedCamera The JSON to parse
  89857. * @param scene The scene to instantiate the camera in
  89858. * @returns the newly constructed camera
  89859. */
  89860. static Parse(parsedCamera: any, scene: Scene): Camera;
  89861. }
  89862. }
  89863. declare module BABYLON {
  89864. /**
  89865. * Interface for any object that can request an animation frame
  89866. */
  89867. export interface ICustomAnimationFrameRequester {
  89868. /**
  89869. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  89870. */
  89871. renderFunction?: Function;
  89872. /**
  89873. * Called to request the next frame to render to
  89874. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  89875. */
  89876. requestAnimationFrame: Function;
  89877. /**
  89878. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  89879. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  89880. */
  89881. requestID?: number;
  89882. }
  89883. /**
  89884. * Interface containing an array of animations
  89885. */
  89886. export interface IAnimatable {
  89887. /**
  89888. * Array of animations
  89889. */
  89890. animations: Array<Animation>;
  89891. }
  89892. /** Interface used by value gradients (color, factor, ...) */
  89893. export interface IValueGradient {
  89894. /**
  89895. * Gets or sets the gradient value (between 0 and 1)
  89896. */
  89897. gradient: number;
  89898. }
  89899. /** Class used to store color4 gradient */
  89900. export class ColorGradient implements IValueGradient {
  89901. /**
  89902. * Gets or sets the gradient value (between 0 and 1)
  89903. */
  89904. gradient: number;
  89905. /**
  89906. * Gets or sets first associated color
  89907. */
  89908. color1: Color4;
  89909. /**
  89910. * Gets or sets second associated color
  89911. */
  89912. color2?: Color4;
  89913. /**
  89914. * Will get a color picked randomly between color1 and color2.
  89915. * If color2 is undefined then color1 will be used
  89916. * @param result defines the target Color4 to store the result in
  89917. */
  89918. getColorToRef(result: Color4): void;
  89919. }
  89920. /** Class used to store color 3 gradient */
  89921. export class Color3Gradient implements IValueGradient {
  89922. /**
  89923. * Gets or sets the gradient value (between 0 and 1)
  89924. */
  89925. gradient: number;
  89926. /**
  89927. * Gets or sets the associated color
  89928. */
  89929. color: Color3;
  89930. }
  89931. /** Class used to store factor gradient */
  89932. export class FactorGradient implements IValueGradient {
  89933. /**
  89934. * Gets or sets the gradient value (between 0 and 1)
  89935. */
  89936. gradient: number;
  89937. /**
  89938. * Gets or sets first associated factor
  89939. */
  89940. factor1: number;
  89941. /**
  89942. * Gets or sets second associated factor
  89943. */
  89944. factor2?: number;
  89945. /**
  89946. * Will get a number picked randomly between factor1 and factor2.
  89947. * If factor2 is undefined then factor1 will be used
  89948. * @returns the picked number
  89949. */
  89950. getFactor(): number;
  89951. }
  89952. /**
  89953. * @ignore
  89954. * Application error to support additional information when loading a file
  89955. */
  89956. export class LoadFileError extends Error {
  89957. /** defines the optional web request */
  89958. request?: WebRequest | undefined;
  89959. private static _setPrototypeOf;
  89960. /**
  89961. * Creates a new LoadFileError
  89962. * @param message defines the message of the error
  89963. * @param request defines the optional web request
  89964. */
  89965. constructor(message: string,
  89966. /** defines the optional web request */
  89967. request?: WebRequest | undefined);
  89968. }
  89969. /**
  89970. * Class used to define a retry strategy when error happens while loading assets
  89971. */
  89972. export class RetryStrategy {
  89973. /**
  89974. * Function used to defines an exponential back off strategy
  89975. * @param maxRetries defines the maximum number of retries (3 by default)
  89976. * @param baseInterval defines the interval between retries
  89977. * @returns the strategy function to use
  89978. */
  89979. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  89980. }
  89981. /**
  89982. * File request interface
  89983. */
  89984. export interface IFileRequest {
  89985. /**
  89986. * Raised when the request is complete (success or error).
  89987. */
  89988. onCompleteObservable: Observable<IFileRequest>;
  89989. /**
  89990. * Aborts the request for a file.
  89991. */
  89992. abort: () => void;
  89993. }
  89994. /**
  89995. * Class containing a set of static utilities functions
  89996. */
  89997. export class Tools {
  89998. /**
  89999. * Gets or sets the base URL to use to load assets
  90000. */
  90001. static BaseUrl: string;
  90002. /**
  90003. * Enable/Disable Custom HTTP Request Headers globally.
  90004. * default = false
  90005. * @see CustomRequestHeaders
  90006. */
  90007. static UseCustomRequestHeaders: boolean;
  90008. /**
  90009. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90010. * i.e. when loading files, where the server/service expects an Authorization header
  90011. */
  90012. static CustomRequestHeaders: {
  90013. [key: string]: string;
  90014. };
  90015. /**
  90016. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90017. */
  90018. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90019. /**
  90020. * Default behaviour for cors in the application.
  90021. * It can be a string if the expected behavior is identical in the entire app.
  90022. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90023. */
  90024. static CorsBehavior: string | ((url: string | string[]) => string);
  90025. /**
  90026. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90027. * @ignorenaming
  90028. */
  90029. static UseFallbackTexture: boolean;
  90030. /**
  90031. * Use this object to register external classes like custom textures or material
  90032. * to allow the laoders to instantiate them
  90033. */
  90034. static RegisteredExternalClasses: {
  90035. [key: string]: Object;
  90036. };
  90037. /**
  90038. * Texture content used if a texture cannot loaded
  90039. * @ignorenaming
  90040. */
  90041. static fallbackTexture: string;
  90042. /**
  90043. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90044. * @param u defines the coordinate on X axis
  90045. * @param v defines the coordinate on Y axis
  90046. * @param width defines the width of the source data
  90047. * @param height defines the height of the source data
  90048. * @param pixels defines the source byte array
  90049. * @param color defines the output color
  90050. */
  90051. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90052. /**
  90053. * Interpolates between a and b via alpha
  90054. * @param a The lower value (returned when alpha = 0)
  90055. * @param b The upper value (returned when alpha = 1)
  90056. * @param alpha The interpolation-factor
  90057. * @return The mixed value
  90058. */
  90059. static Mix(a: number, b: number, alpha: number): number;
  90060. /**
  90061. * Tries to instantiate a new object from a given class name
  90062. * @param className defines the class name to instantiate
  90063. * @returns the new object or null if the system was not able to do the instantiation
  90064. */
  90065. static Instantiate(className: string): any;
  90066. /**
  90067. * Provides a slice function that will work even on IE
  90068. * @param data defines the array to slice
  90069. * @param start defines the start of the data (optional)
  90070. * @param end defines the end of the data (optional)
  90071. * @returns the new sliced array
  90072. */
  90073. static Slice<T>(data: T, start?: number, end?: number): T;
  90074. /**
  90075. * Polyfill for setImmediate
  90076. * @param action defines the action to execute after the current execution block
  90077. */
  90078. static SetImmediate(action: () => void): void;
  90079. /**
  90080. * Function indicating if a number is an exponent of 2
  90081. * @param value defines the value to test
  90082. * @returns true if the value is an exponent of 2
  90083. */
  90084. static IsExponentOfTwo(value: number): boolean;
  90085. private static _tmpFloatArray;
  90086. /**
  90087. * Returns the nearest 32-bit single precision float representation of a Number
  90088. * @param value A Number. If the parameter is of a different type, it will get converted
  90089. * to a number or to NaN if it cannot be converted
  90090. * @returns number
  90091. */
  90092. static FloatRound(value: number): number;
  90093. /**
  90094. * Find the next highest power of two.
  90095. * @param x Number to start search from.
  90096. * @return Next highest power of two.
  90097. */
  90098. static CeilingPOT(x: number): number;
  90099. /**
  90100. * Find the next lowest power of two.
  90101. * @param x Number to start search from.
  90102. * @return Next lowest power of two.
  90103. */
  90104. static FloorPOT(x: number): number;
  90105. /**
  90106. * Find the nearest power of two.
  90107. * @param x Number to start search from.
  90108. * @return Next nearest power of two.
  90109. */
  90110. static NearestPOT(x: number): number;
  90111. /**
  90112. * Get the closest exponent of two
  90113. * @param value defines the value to approximate
  90114. * @param max defines the maximum value to return
  90115. * @param mode defines how to define the closest value
  90116. * @returns closest exponent of two of the given value
  90117. */
  90118. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90119. /**
  90120. * Extracts the filename from a path
  90121. * @param path defines the path to use
  90122. * @returns the filename
  90123. */
  90124. static GetFilename(path: string): string;
  90125. /**
  90126. * Extracts the "folder" part of a path (everything before the filename).
  90127. * @param uri The URI to extract the info from
  90128. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90129. * @returns The "folder" part of the path
  90130. */
  90131. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90132. /**
  90133. * Extracts text content from a DOM element hierarchy
  90134. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90135. */
  90136. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90137. /**
  90138. * Convert an angle in radians to degrees
  90139. * @param angle defines the angle to convert
  90140. * @returns the angle in degrees
  90141. */
  90142. static ToDegrees(angle: number): number;
  90143. /**
  90144. * Convert an angle in degrees to radians
  90145. * @param angle defines the angle to convert
  90146. * @returns the angle in radians
  90147. */
  90148. static ToRadians(angle: number): number;
  90149. /**
  90150. * Encode a buffer to a base64 string
  90151. * @param buffer defines the buffer to encode
  90152. * @returns the encoded string
  90153. */
  90154. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90155. /**
  90156. * Extracts minimum and maximum values from a list of indexed positions
  90157. * @param positions defines the positions to use
  90158. * @param indices defines the indices to the positions
  90159. * @param indexStart defines the start index
  90160. * @param indexCount defines the end index
  90161. * @param bias defines bias value to add to the result
  90162. * @return minimum and maximum values
  90163. */
  90164. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90165. minimum: Vector3;
  90166. maximum: Vector3;
  90167. };
  90168. /**
  90169. * Extracts minimum and maximum values from a list of positions
  90170. * @param positions defines the positions to use
  90171. * @param start defines the start index in the positions array
  90172. * @param count defines the number of positions to handle
  90173. * @param bias defines bias value to add to the result
  90174. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90175. * @return minimum and maximum values
  90176. */
  90177. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90178. minimum: Vector3;
  90179. maximum: Vector3;
  90180. };
  90181. /**
  90182. * Returns an array if obj is not an array
  90183. * @param obj defines the object to evaluate as an array
  90184. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90185. * @returns either obj directly if obj is an array or a new array containing obj
  90186. */
  90187. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90188. /**
  90189. * Gets the pointer prefix to use
  90190. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90191. */
  90192. static GetPointerPrefix(): string;
  90193. /**
  90194. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90195. * @param func - the function to be called
  90196. * @param requester - the object that will request the next frame. Falls back to window.
  90197. * @returns frame number
  90198. */
  90199. static QueueNewFrame(func: () => void, requester?: any): number;
  90200. /**
  90201. * Ask the browser to promote the current element to fullscreen rendering mode
  90202. * @param element defines the DOM element to promote
  90203. */
  90204. static RequestFullscreen(element: HTMLElement): void;
  90205. /**
  90206. * Asks the browser to exit fullscreen mode
  90207. */
  90208. static ExitFullscreen(): void;
  90209. /**
  90210. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90211. * @param url define the url we are trying
  90212. * @param element define the dom element where to configure the cors policy
  90213. */
  90214. static SetCorsBehavior(url: string | string[], element: {
  90215. crossOrigin: string | null;
  90216. }): void;
  90217. /**
  90218. * Removes unwanted characters from an url
  90219. * @param url defines the url to clean
  90220. * @returns the cleaned url
  90221. */
  90222. static CleanUrl(url: string): string;
  90223. /**
  90224. * Gets or sets a function used to pre-process url before using them to load assets
  90225. */
  90226. static PreprocessUrl: (url: string) => string;
  90227. /**
  90228. * Loads an image as an HTMLImageElement.
  90229. * @param input url string, ArrayBuffer, or Blob to load
  90230. * @param onLoad callback called when the image successfully loads
  90231. * @param onError callback called when the image fails to load
  90232. * @param offlineProvider offline provider for caching
  90233. * @returns the HTMLImageElement of the loaded image
  90234. */
  90235. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90236. /**
  90237. * Loads a file
  90238. * @param url url string, ArrayBuffer, or Blob to load
  90239. * @param onSuccess callback called when the file successfully loads
  90240. * @param onProgress callback called while file is loading (if the server supports this mode)
  90241. * @param offlineProvider defines the offline provider for caching
  90242. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90243. * @param onError callback called when the file fails to load
  90244. * @returns a file request object
  90245. */
  90246. 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;
  90247. /**
  90248. * Load a script (identified by an url). When the url returns, the
  90249. * content of this file is added into a new script element, attached to the DOM (body element)
  90250. * @param scriptUrl defines the url of the script to laod
  90251. * @param onSuccess defines the callback called when the script is loaded
  90252. * @param onError defines the callback to call if an error occurs
  90253. * @param scriptId defines the id of the script element
  90254. */
  90255. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90256. /**
  90257. * Load an asynchronous script (identified by an url). When the url returns, the
  90258. * content of this file is added into a new script element, attached to the DOM (body element)
  90259. * @param scriptUrl defines the url of the script to laod
  90260. * @param scriptId defines the id of the script element
  90261. * @returns a promise request object
  90262. */
  90263. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90264. /**
  90265. * Loads a file from a blob
  90266. * @param fileToLoad defines the blob to use
  90267. * @param callback defines the callback to call when data is loaded
  90268. * @param progressCallback defines the callback to call during loading process
  90269. * @returns a file request object
  90270. */
  90271. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  90272. /**
  90273. * Loads a file
  90274. * @param fileToLoad defines the file to load
  90275. * @param callback defines the callback to call when data is loaded
  90276. * @param progressCallBack defines the callback to call during loading process
  90277. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  90278. * @returns a file request object
  90279. */
  90280. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  90281. /**
  90282. * Creates a data url from a given string content
  90283. * @param content defines the content to convert
  90284. * @returns the new data url link
  90285. */
  90286. static FileAsURL(content: string): string;
  90287. /**
  90288. * Format the given number to a specific decimal format
  90289. * @param value defines the number to format
  90290. * @param decimals defines the number of decimals to use
  90291. * @returns the formatted string
  90292. */
  90293. static Format(value: number, decimals?: number): string;
  90294. /**
  90295. * Checks if a given vector is inside a specific range
  90296. * @param v defines the vector to test
  90297. * @param min defines the minimum range
  90298. * @param max defines the maximum range
  90299. */
  90300. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  90301. /**
  90302. * Tries to copy an object by duplicating every property
  90303. * @param source defines the source object
  90304. * @param destination defines the target object
  90305. * @param doNotCopyList defines a list of properties to avoid
  90306. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  90307. */
  90308. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  90309. /**
  90310. * Gets a boolean indicating if the given object has no own property
  90311. * @param obj defines the object to test
  90312. * @returns true if object has no own property
  90313. */
  90314. static IsEmpty(obj: any): boolean;
  90315. /**
  90316. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  90317. * @param str Source string
  90318. * @param suffix Suffix to search for in the source string
  90319. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  90320. */
  90321. static EndsWith(str: string, suffix: string): boolean;
  90322. /**
  90323. * Function used to register events at window level
  90324. * @param events defines the events to register
  90325. */
  90326. static RegisterTopRootEvents(events: {
  90327. name: string;
  90328. handler: Nullable<(e: FocusEvent) => any>;
  90329. }[]): void;
  90330. /**
  90331. * Function used to unregister events from window level
  90332. * @param events defines the events to unregister
  90333. */
  90334. static UnregisterTopRootEvents(events: {
  90335. name: string;
  90336. handler: Nullable<(e: FocusEvent) => any>;
  90337. }[]): void;
  90338. /**
  90339. * @ignore
  90340. */
  90341. static _ScreenshotCanvas: HTMLCanvasElement;
  90342. /**
  90343. * Dumps the current bound framebuffer
  90344. * @param width defines the rendering width
  90345. * @param height defines the rendering height
  90346. * @param engine defines the hosting engine
  90347. * @param successCallback defines the callback triggered once the data are available
  90348. * @param mimeType defines the mime type of the result
  90349. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  90350. */
  90351. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90352. /**
  90353. * Converts the canvas data to blob.
  90354. * This acts as a polyfill for browsers not supporting the to blob function.
  90355. * @param canvas Defines the canvas to extract the data from
  90356. * @param successCallback Defines the callback triggered once the data are available
  90357. * @param mimeType Defines the mime type of the result
  90358. */
  90359. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  90360. /**
  90361. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  90362. * @param successCallback defines the callback triggered once the data are available
  90363. * @param mimeType defines the mime type of the result
  90364. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  90365. */
  90366. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90367. /**
  90368. * Downloads a blob in the browser
  90369. * @param blob defines the blob to download
  90370. * @param fileName defines the name of the downloaded file
  90371. */
  90372. static Download(blob: Blob, fileName: string): void;
  90373. /**
  90374. * Captures a screenshot of the current rendering
  90375. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90376. * @param engine defines the rendering engine
  90377. * @param camera defines the source camera
  90378. * @param size This parameter can be set to a single number or to an object with the
  90379. * following (optional) properties: precision, width, height. If a single number is passed,
  90380. * it will be used for both width and height. If an object is passed, the screenshot size
  90381. * will be derived from the parameters. The precision property is a multiplier allowing
  90382. * rendering at a higher or lower resolution
  90383. * @param successCallback defines the callback receives a single parameter which contains the
  90384. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90385. * src parameter of an <img> to display it
  90386. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  90387. * Check your browser for supported MIME types
  90388. */
  90389. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  90390. /**
  90391. * Generates an image screenshot from the specified camera.
  90392. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90393. * @param engine The engine to use for rendering
  90394. * @param camera The camera to use for rendering
  90395. * @param size This parameter can be set to a single number or to an object with the
  90396. * following (optional) properties: precision, width, height. If a single number is passed,
  90397. * it will be used for both width and height. If an object is passed, the screenshot size
  90398. * will be derived from the parameters. The precision property is a multiplier allowing
  90399. * rendering at a higher or lower resolution
  90400. * @param successCallback The callback receives a single parameter which contains the
  90401. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90402. * src parameter of an <img> to display it
  90403. * @param mimeType The MIME type of the screenshot image (default: image/png).
  90404. * Check your browser for supported MIME types
  90405. * @param samples Texture samples (default: 1)
  90406. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  90407. * @param fileName A name for for the downloaded file.
  90408. */
  90409. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  90410. /**
  90411. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90412. * Be aware Math.random() could cause collisions, but:
  90413. * "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"
  90414. * @returns a pseudo random id
  90415. */
  90416. static RandomId(): string;
  90417. /**
  90418. * Test if the given uri is a base64 string
  90419. * @param uri The uri to test
  90420. * @return True if the uri is a base64 string or false otherwise
  90421. */
  90422. static IsBase64(uri: string): boolean;
  90423. /**
  90424. * Decode the given base64 uri.
  90425. * @param uri The uri to decode
  90426. * @return The decoded base64 data.
  90427. */
  90428. static DecodeBase64(uri: string): ArrayBuffer;
  90429. /**
  90430. * Gets the absolute url.
  90431. * @param url the input url
  90432. * @return the absolute url
  90433. */
  90434. static GetAbsoluteUrl(url: string): string;
  90435. /**
  90436. * No log
  90437. */
  90438. static readonly NoneLogLevel: number;
  90439. /**
  90440. * Only message logs
  90441. */
  90442. static readonly MessageLogLevel: number;
  90443. /**
  90444. * Only warning logs
  90445. */
  90446. static readonly WarningLogLevel: number;
  90447. /**
  90448. * Only error logs
  90449. */
  90450. static readonly ErrorLogLevel: number;
  90451. /**
  90452. * All logs
  90453. */
  90454. static readonly AllLogLevel: number;
  90455. /**
  90456. * Gets a value indicating the number of loading errors
  90457. * @ignorenaming
  90458. */
  90459. static readonly errorsCount: number;
  90460. /**
  90461. * Callback called when a new log is added
  90462. */
  90463. static OnNewCacheEntry: (entry: string) => void;
  90464. /**
  90465. * Log a message to the console
  90466. * @param message defines the message to log
  90467. */
  90468. static Log(message: string): void;
  90469. /**
  90470. * Write a warning message to the console
  90471. * @param message defines the message to log
  90472. */
  90473. static Warn(message: string): void;
  90474. /**
  90475. * Write an error message to the console
  90476. * @param message defines the message to log
  90477. */
  90478. static Error(message: string): void;
  90479. /**
  90480. * Gets current log cache (list of logs)
  90481. */
  90482. static readonly LogCache: string;
  90483. /**
  90484. * Clears the log cache
  90485. */
  90486. static ClearLogCache(): void;
  90487. /**
  90488. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  90489. */
  90490. static LogLevels: number;
  90491. /**
  90492. * Checks if the loaded document was accessed via `file:`-Protocol.
  90493. * @returns boolean
  90494. */
  90495. static IsFileURL(): boolean;
  90496. /**
  90497. * Checks if the window object exists
  90498. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  90499. */
  90500. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  90501. /**
  90502. * No performance log
  90503. */
  90504. static readonly PerformanceNoneLogLevel: number;
  90505. /**
  90506. * Use user marks to log performance
  90507. */
  90508. static readonly PerformanceUserMarkLogLevel: number;
  90509. /**
  90510. * Log performance to the console
  90511. */
  90512. static readonly PerformanceConsoleLogLevel: number;
  90513. private static _performance;
  90514. /**
  90515. * Sets the current performance log level
  90516. */
  90517. static PerformanceLogLevel: number;
  90518. private static _StartPerformanceCounterDisabled;
  90519. private static _EndPerformanceCounterDisabled;
  90520. private static _StartUserMark;
  90521. private static _EndUserMark;
  90522. private static _StartPerformanceConsole;
  90523. private static _EndPerformanceConsole;
  90524. /**
  90525. * Starts a performance counter
  90526. */
  90527. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90528. /**
  90529. * Ends a specific performance coutner
  90530. */
  90531. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90532. /**
  90533. * Gets either window.performance.now() if supported or Date.now() else
  90534. */
  90535. static readonly Now: number;
  90536. /**
  90537. * This method will return the name of the class used to create the instance of the given object.
  90538. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  90539. * @param object the object to get the class name from
  90540. * @param isType defines if the object is actually a type
  90541. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  90542. */
  90543. static GetClassName(object: any, isType?: boolean): string;
  90544. /**
  90545. * Gets the first element of an array satisfying a given predicate
  90546. * @param array defines the array to browse
  90547. * @param predicate defines the predicate to use
  90548. * @returns null if not found or the element
  90549. */
  90550. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  90551. /**
  90552. * This method will return the name of the full name of the class, including its owning module (if any).
  90553. * 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).
  90554. * @param object the object to get the class name from
  90555. * @param isType defines if the object is actually a type
  90556. * @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.
  90557. * @ignorenaming
  90558. */
  90559. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  90560. /**
  90561. * Returns a promise that resolves after the given amount of time.
  90562. * @param delay Number of milliseconds to delay
  90563. * @returns Promise that resolves after the given amount of time
  90564. */
  90565. static DelayAsync(delay: number): Promise<void>;
  90566. /**
  90567. * Gets the current gradient from an array of IValueGradient
  90568. * @param ratio defines the current ratio to get
  90569. * @param gradients defines the array of IValueGradient
  90570. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90571. */
  90572. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90573. }
  90574. /**
  90575. * This class is used to track a performance counter which is number based.
  90576. * The user has access to many properties which give statistics of different nature.
  90577. *
  90578. * The implementer can track two kinds of Performance Counter: time and count.
  90579. * 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.
  90580. * 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.
  90581. */
  90582. export class PerfCounter {
  90583. /**
  90584. * Gets or sets a global boolean to turn on and off all the counters
  90585. */
  90586. static Enabled: boolean;
  90587. /**
  90588. * Returns the smallest value ever
  90589. */
  90590. readonly min: number;
  90591. /**
  90592. * Returns the biggest value ever
  90593. */
  90594. readonly max: number;
  90595. /**
  90596. * Returns the average value since the performance counter is running
  90597. */
  90598. readonly average: number;
  90599. /**
  90600. * Returns the average value of the last second the counter was monitored
  90601. */
  90602. readonly lastSecAverage: number;
  90603. /**
  90604. * Returns the current value
  90605. */
  90606. readonly current: number;
  90607. /**
  90608. * Gets the accumulated total
  90609. */
  90610. readonly total: number;
  90611. /**
  90612. * Gets the total value count
  90613. */
  90614. readonly count: number;
  90615. /**
  90616. * Creates a new counter
  90617. */
  90618. constructor();
  90619. /**
  90620. * Call this method to start monitoring a new frame.
  90621. * 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.
  90622. */
  90623. fetchNewFrame(): void;
  90624. /**
  90625. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  90626. * @param newCount the count value to add to the monitored count
  90627. * @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.
  90628. */
  90629. addCount(newCount: number, fetchResult: boolean): void;
  90630. /**
  90631. * Start monitoring this performance counter
  90632. */
  90633. beginMonitoring(): void;
  90634. /**
  90635. * Compute the time lapsed since the previous beginMonitoring() call.
  90636. * @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
  90637. */
  90638. endMonitoring(newFrame?: boolean): void;
  90639. private _fetchResult;
  90640. private _startMonitoringTime;
  90641. private _min;
  90642. private _max;
  90643. private _average;
  90644. private _current;
  90645. private _totalValueCount;
  90646. private _totalAccumulated;
  90647. private _lastSecAverage;
  90648. private _lastSecAccumulated;
  90649. private _lastSecTime;
  90650. private _lastSecValueCount;
  90651. }
  90652. /**
  90653. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  90654. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  90655. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  90656. * @param name The name of the class, case should be preserved
  90657. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  90658. */
  90659. export function className(name: string, module?: string): (target: Object) => void;
  90660. /**
  90661. * An implementation of a loop for asynchronous functions.
  90662. */
  90663. export class AsyncLoop {
  90664. /**
  90665. * Defines the number of iterations for the loop
  90666. */
  90667. iterations: number;
  90668. /**
  90669. * Defines the current index of the loop.
  90670. */
  90671. index: number;
  90672. private _done;
  90673. private _fn;
  90674. private _successCallback;
  90675. /**
  90676. * Constructor.
  90677. * @param iterations the number of iterations.
  90678. * @param func the function to run each iteration
  90679. * @param successCallback the callback that will be called upon succesful execution
  90680. * @param offset starting offset.
  90681. */
  90682. constructor(
  90683. /**
  90684. * Defines the number of iterations for the loop
  90685. */
  90686. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  90687. /**
  90688. * Execute the next iteration. Must be called after the last iteration was finished.
  90689. */
  90690. executeNext(): void;
  90691. /**
  90692. * Break the loop and run the success callback.
  90693. */
  90694. breakLoop(): void;
  90695. /**
  90696. * Create and run an async loop.
  90697. * @param iterations the number of iterations.
  90698. * @param fn the function to run each iteration
  90699. * @param successCallback the callback that will be called upon succesful execution
  90700. * @param offset starting offset.
  90701. * @returns the created async loop object
  90702. */
  90703. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  90704. /**
  90705. * A for-loop that will run a given number of iterations synchronous and the rest async.
  90706. * @param iterations total number of iterations
  90707. * @param syncedIterations number of synchronous iterations in each async iteration.
  90708. * @param fn the function to call each iteration.
  90709. * @param callback a success call back that will be called when iterating stops.
  90710. * @param breakFunction a break condition (optional)
  90711. * @param timeout timeout settings for the setTimeout function. default - 0.
  90712. * @returns the created async loop object
  90713. */
  90714. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  90715. }
  90716. }
  90717. declare module BABYLON {
  90718. /** @hidden */
  90719. export interface ICollisionCoordinator {
  90720. createCollider(): Collider;
  90721. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90722. init(scene: Scene): void;
  90723. }
  90724. /** @hidden */
  90725. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  90726. private _scene;
  90727. private _scaledPosition;
  90728. private _scaledVelocity;
  90729. private _finalPosition;
  90730. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90731. createCollider(): Collider;
  90732. init(scene: Scene): void;
  90733. private _collideWithWorld;
  90734. }
  90735. }
  90736. declare module BABYLON {
  90737. /**
  90738. * This class defines the direct association between an animation and a target
  90739. */
  90740. export class TargetedAnimation {
  90741. /**
  90742. * Animation to perform
  90743. */
  90744. animation: Animation;
  90745. /**
  90746. * Target to animate
  90747. */
  90748. target: any;
  90749. }
  90750. /**
  90751. * Use this class to create coordinated animations on multiple targets
  90752. */
  90753. export class AnimationGroup implements IDisposable {
  90754. /** The name of the animation group */
  90755. name: string;
  90756. private _scene;
  90757. private _targetedAnimations;
  90758. private _animatables;
  90759. private _from;
  90760. private _to;
  90761. private _isStarted;
  90762. private _isPaused;
  90763. private _speedRatio;
  90764. /**
  90765. * Gets or sets the unique id of the node
  90766. */
  90767. uniqueId: number;
  90768. /**
  90769. * This observable will notify when one animation have ended
  90770. */
  90771. onAnimationEndObservable: Observable<TargetedAnimation>;
  90772. /**
  90773. * Observer raised when one animation loops
  90774. */
  90775. onAnimationLoopObservable: Observable<TargetedAnimation>;
  90776. /**
  90777. * This observable will notify when all animations have ended.
  90778. */
  90779. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  90780. /**
  90781. * This observable will notify when all animations have paused.
  90782. */
  90783. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  90784. /**
  90785. * This observable will notify when all animations are playing.
  90786. */
  90787. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  90788. /**
  90789. * Gets the first frame
  90790. */
  90791. readonly from: number;
  90792. /**
  90793. * Gets the last frame
  90794. */
  90795. readonly to: number;
  90796. /**
  90797. * Define if the animations are started
  90798. */
  90799. readonly isStarted: boolean;
  90800. /**
  90801. * Gets a value indicating that the current group is playing
  90802. */
  90803. readonly isPlaying: boolean;
  90804. /**
  90805. * Gets or sets the speed ratio to use for all animations
  90806. */
  90807. /**
  90808. * Gets or sets the speed ratio to use for all animations
  90809. */
  90810. speedRatio: number;
  90811. /**
  90812. * Gets the targeted animations for this animation group
  90813. */
  90814. readonly targetedAnimations: Array<TargetedAnimation>;
  90815. /**
  90816. * returning the list of animatables controlled by this animation group.
  90817. */
  90818. readonly animatables: Array<Animatable>;
  90819. /**
  90820. * Instantiates a new Animation Group.
  90821. * This helps managing several animations at once.
  90822. * @see http://doc.babylonjs.com/how_to/group
  90823. * @param name Defines the name of the group
  90824. * @param scene Defines the scene the group belongs to
  90825. */
  90826. constructor(
  90827. /** The name of the animation group */
  90828. name: string, scene?: Nullable<Scene>);
  90829. /**
  90830. * Add an animation (with its target) in the group
  90831. * @param animation defines the animation we want to add
  90832. * @param target defines the target of the animation
  90833. * @returns the TargetedAnimation object
  90834. */
  90835. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  90836. /**
  90837. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  90838. * It can add constant keys at begin or end
  90839. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  90840. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  90841. * @returns the animation group
  90842. */
  90843. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  90844. /**
  90845. * Start all animations on given targets
  90846. * @param loop defines if animations must loop
  90847. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  90848. * @param from defines the from key (optional)
  90849. * @param to defines the to key (optional)
  90850. * @returns the current animation group
  90851. */
  90852. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  90853. /**
  90854. * Pause all animations
  90855. * @returns the animation group
  90856. */
  90857. pause(): AnimationGroup;
  90858. /**
  90859. * Play all animations to initial state
  90860. * This function will start() the animations if they were not started or will restart() them if they were paused
  90861. * @param loop defines if animations must loop
  90862. * @returns the animation group
  90863. */
  90864. play(loop?: boolean): AnimationGroup;
  90865. /**
  90866. * Reset all animations to initial state
  90867. * @returns the animation group
  90868. */
  90869. reset(): AnimationGroup;
  90870. /**
  90871. * Restart animations from key 0
  90872. * @returns the animation group
  90873. */
  90874. restart(): AnimationGroup;
  90875. /**
  90876. * Stop all animations
  90877. * @returns the animation group
  90878. */
  90879. stop(): AnimationGroup;
  90880. /**
  90881. * Set animation weight for all animatables
  90882. * @param weight defines the weight to use
  90883. * @return the animationGroup
  90884. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90885. */
  90886. setWeightForAllAnimatables(weight: number): AnimationGroup;
  90887. /**
  90888. * Synchronize and normalize all animatables with a source animatable
  90889. * @param root defines the root animatable to synchronize with
  90890. * @return the animationGroup
  90891. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  90892. */
  90893. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  90894. /**
  90895. * Goes to a specific frame in this animation group
  90896. * @param frame the frame number to go to
  90897. * @return the animationGroup
  90898. */
  90899. goToFrame(frame: number): AnimationGroup;
  90900. /**
  90901. * Dispose all associated resources
  90902. */
  90903. dispose(): void;
  90904. private _checkAnimationGroupEnded;
  90905. /**
  90906. * Clone the current animation group and returns a copy
  90907. * @param newName defines the name of the new group
  90908. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  90909. * @returns the new aniamtion group
  90910. */
  90911. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  90912. /**
  90913. * Returns a new AnimationGroup object parsed from the source provided.
  90914. * @param parsedAnimationGroup defines the source
  90915. * @param scene defines the scene that will receive the animationGroup
  90916. * @returns a new AnimationGroup
  90917. */
  90918. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  90919. /**
  90920. * Returns the string "AnimationGroup"
  90921. * @returns "AnimationGroup"
  90922. */
  90923. getClassName(): string;
  90924. /**
  90925. * Creates a detailled string about the object
  90926. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  90927. * @returns a string representing the object
  90928. */
  90929. toString(fullDetails?: boolean): string;
  90930. }
  90931. }
  90932. declare module BABYLON {
  90933. /**
  90934. * Define an interface for all classes that will hold resources
  90935. */
  90936. export interface IDisposable {
  90937. /**
  90938. * Releases all held resources
  90939. */
  90940. dispose(): void;
  90941. }
  90942. /** Interface defining initialization parameters for Scene class */
  90943. export interface SceneOptions {
  90944. /**
  90945. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  90946. * It will improve performance when the number of geometries becomes important.
  90947. */
  90948. useGeometryUniqueIdsMap?: boolean;
  90949. /**
  90950. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  90951. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  90952. */
  90953. useMaterialMeshMap?: boolean;
  90954. /**
  90955. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  90956. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  90957. */
  90958. useClonedMeshhMap?: boolean;
  90959. }
  90960. /**
  90961. * Represents a scene to be rendered by the engine.
  90962. * @see http://doc.babylonjs.com/features/scene
  90963. */
  90964. export class Scene extends AbstractScene implements IAnimatable {
  90965. private static _uniqueIdCounter;
  90966. /** The fog is deactivated */
  90967. static readonly FOGMODE_NONE: number;
  90968. /** The fog density is following an exponential function */
  90969. static readonly FOGMODE_EXP: number;
  90970. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  90971. static readonly FOGMODE_EXP2: number;
  90972. /** The fog density is following a linear function. */
  90973. static readonly FOGMODE_LINEAR: number;
  90974. /**
  90975. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  90976. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90977. */
  90978. static MinDeltaTime: number;
  90979. /**
  90980. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  90981. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90982. */
  90983. static MaxDeltaTime: number;
  90984. /**
  90985. * Factory used to create the default material.
  90986. * @param name The name of the material to create
  90987. * @param scene The scene to create the material for
  90988. * @returns The default material
  90989. */
  90990. static DefaultMaterialFactory(scene: Scene): Material;
  90991. /**
  90992. * Factory used to create the a collision coordinator.
  90993. * @returns The collision coordinator
  90994. */
  90995. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  90996. /** @hidden */
  90997. readonly _isScene: boolean;
  90998. /**
  90999. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91000. */
  91001. autoClear: boolean;
  91002. /**
  91003. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91004. */
  91005. autoClearDepthAndStencil: boolean;
  91006. /**
  91007. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91008. */
  91009. clearColor: Color4;
  91010. /**
  91011. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91012. */
  91013. ambientColor: Color3;
  91014. /**
  91015. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91016. * It should only be one of the following (if not the default embedded one):
  91017. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91018. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91019. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91020. * The material properties need to be setup according to the type of texture in use.
  91021. */
  91022. environmentBRDFTexture: BaseTexture;
  91023. /** @hidden */
  91024. protected _environmentTexture: Nullable<BaseTexture>;
  91025. /**
  91026. * Texture used in all pbr material as the reflection texture.
  91027. * As in the majority of the scene they are the same (exception for multi room and so on),
  91028. * this is easier to reference from here than from all the materials.
  91029. */
  91030. /**
  91031. * Texture used in all pbr material as the reflection texture.
  91032. * As in the majority of the scene they are the same (exception for multi room and so on),
  91033. * this is easier to set here than in all the materials.
  91034. */
  91035. environmentTexture: Nullable<BaseTexture>;
  91036. /** @hidden */
  91037. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91038. /**
  91039. * Default image processing configuration used either in the rendering
  91040. * Forward main pass or through the imageProcessingPostProcess if present.
  91041. * As in the majority of the scene they are the same (exception for multi camera),
  91042. * this is easier to reference from here than from all the materials and post process.
  91043. *
  91044. * No setter as we it is a shared configuration, you can set the values instead.
  91045. */
  91046. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91047. private _forceWireframe;
  91048. /**
  91049. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91050. */
  91051. forceWireframe: boolean;
  91052. private _forcePointsCloud;
  91053. /**
  91054. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91055. */
  91056. forcePointsCloud: boolean;
  91057. /**
  91058. * Gets or sets the active clipplane 1
  91059. */
  91060. clipPlane: Nullable<Plane>;
  91061. /**
  91062. * Gets or sets the active clipplane 2
  91063. */
  91064. clipPlane2: Nullable<Plane>;
  91065. /**
  91066. * Gets or sets the active clipplane 3
  91067. */
  91068. clipPlane3: Nullable<Plane>;
  91069. /**
  91070. * Gets or sets the active clipplane 4
  91071. */
  91072. clipPlane4: Nullable<Plane>;
  91073. /**
  91074. * Gets or sets a boolean indicating if animations are enabled
  91075. */
  91076. animationsEnabled: boolean;
  91077. private _animationPropertiesOverride;
  91078. /**
  91079. * Gets or sets the animation properties override
  91080. */
  91081. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91082. /**
  91083. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91084. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91085. */
  91086. useConstantAnimationDeltaTime: boolean;
  91087. /**
  91088. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91089. * Please note that it requires to run a ray cast through the scene on every frame
  91090. */
  91091. constantlyUpdateMeshUnderPointer: boolean;
  91092. /**
  91093. * Defines the HTML cursor to use when hovering over interactive elements
  91094. */
  91095. hoverCursor: string;
  91096. /**
  91097. * Defines the HTML default cursor to use (empty by default)
  91098. */
  91099. defaultCursor: string;
  91100. /**
  91101. * This is used to call preventDefault() on pointer down
  91102. * in order to block unwanted artifacts like system double clicks
  91103. */
  91104. preventDefaultOnPointerDown: boolean;
  91105. /**
  91106. * This is used to call preventDefault() on pointer up
  91107. * in order to block unwanted artifacts like system double clicks
  91108. */
  91109. preventDefaultOnPointerUp: boolean;
  91110. /**
  91111. * Gets or sets user defined metadata
  91112. */
  91113. metadata: any;
  91114. /**
  91115. * For internal use only. Please do not use.
  91116. */
  91117. reservedDataStore: any;
  91118. /**
  91119. * Gets the name of the plugin used to load this scene (null by default)
  91120. */
  91121. loadingPluginName: string;
  91122. /**
  91123. * Use this array to add regular expressions used to disable offline support for specific urls
  91124. */
  91125. disableOfflineSupportExceptionRules: RegExp[];
  91126. /**
  91127. * An event triggered when the scene is disposed.
  91128. */
  91129. onDisposeObservable: Observable<Scene>;
  91130. private _onDisposeObserver;
  91131. /** Sets a function to be executed when this scene is disposed. */
  91132. onDispose: () => void;
  91133. /**
  91134. * An event triggered before rendering the scene (right after animations and physics)
  91135. */
  91136. onBeforeRenderObservable: Observable<Scene>;
  91137. private _onBeforeRenderObserver;
  91138. /** Sets a function to be executed before rendering this scene */
  91139. beforeRender: Nullable<() => void>;
  91140. /**
  91141. * An event triggered after rendering the scene
  91142. */
  91143. onAfterRenderObservable: Observable<Scene>;
  91144. private _onAfterRenderObserver;
  91145. /** Sets a function to be executed after rendering this scene */
  91146. afterRender: Nullable<() => void>;
  91147. /**
  91148. * An event triggered before animating the scene
  91149. */
  91150. onBeforeAnimationsObservable: Observable<Scene>;
  91151. /**
  91152. * An event triggered after animations processing
  91153. */
  91154. onAfterAnimationsObservable: Observable<Scene>;
  91155. /**
  91156. * An event triggered before draw calls are ready to be sent
  91157. */
  91158. onBeforeDrawPhaseObservable: Observable<Scene>;
  91159. /**
  91160. * An event triggered after draw calls have been sent
  91161. */
  91162. onAfterDrawPhaseObservable: Observable<Scene>;
  91163. /**
  91164. * An event triggered when the scene is ready
  91165. */
  91166. onReadyObservable: Observable<Scene>;
  91167. /**
  91168. * An event triggered before rendering a camera
  91169. */
  91170. onBeforeCameraRenderObservable: Observable<Camera>;
  91171. private _onBeforeCameraRenderObserver;
  91172. /** Sets a function to be executed before rendering a camera*/
  91173. beforeCameraRender: () => void;
  91174. /**
  91175. * An event triggered after rendering a camera
  91176. */
  91177. onAfterCameraRenderObservable: Observable<Camera>;
  91178. private _onAfterCameraRenderObserver;
  91179. /** Sets a function to be executed after rendering a camera*/
  91180. afterCameraRender: () => void;
  91181. /**
  91182. * An event triggered when active meshes evaluation is about to start
  91183. */
  91184. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  91185. /**
  91186. * An event triggered when active meshes evaluation is done
  91187. */
  91188. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  91189. /**
  91190. * An event triggered when particles rendering is about to start
  91191. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91192. */
  91193. onBeforeParticlesRenderingObservable: Observable<Scene>;
  91194. /**
  91195. * An event triggered when particles rendering is done
  91196. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91197. */
  91198. onAfterParticlesRenderingObservable: Observable<Scene>;
  91199. /**
  91200. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  91201. */
  91202. onDataLoadedObservable: Observable<Scene>;
  91203. /**
  91204. * An event triggered when a camera is created
  91205. */
  91206. onNewCameraAddedObservable: Observable<Camera>;
  91207. /**
  91208. * An event triggered when a camera is removed
  91209. */
  91210. onCameraRemovedObservable: Observable<Camera>;
  91211. /**
  91212. * An event triggered when a light is created
  91213. */
  91214. onNewLightAddedObservable: Observable<Light>;
  91215. /**
  91216. * An event triggered when a light is removed
  91217. */
  91218. onLightRemovedObservable: Observable<Light>;
  91219. /**
  91220. * An event triggered when a geometry is created
  91221. */
  91222. onNewGeometryAddedObservable: Observable<Geometry>;
  91223. /**
  91224. * An event triggered when a geometry is removed
  91225. */
  91226. onGeometryRemovedObservable: Observable<Geometry>;
  91227. /**
  91228. * An event triggered when a transform node is created
  91229. */
  91230. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  91231. /**
  91232. * An event triggered when a transform node is removed
  91233. */
  91234. onTransformNodeRemovedObservable: Observable<TransformNode>;
  91235. /**
  91236. * An event triggered when a mesh is created
  91237. */
  91238. onNewMeshAddedObservable: Observable<AbstractMesh>;
  91239. /**
  91240. * An event triggered when a mesh is removed
  91241. */
  91242. onMeshRemovedObservable: Observable<AbstractMesh>;
  91243. /**
  91244. * An event triggered when a skeleton is created
  91245. */
  91246. onNewSkeletonAddedObservable: Observable<Skeleton>;
  91247. /**
  91248. * An event triggered when a skeleton is removed
  91249. */
  91250. onSkeletonRemovedObservable: Observable<Skeleton>;
  91251. /**
  91252. * An event triggered when a material is created
  91253. */
  91254. onNewMaterialAddedObservable: Observable<Material>;
  91255. /**
  91256. * An event triggered when a material is removed
  91257. */
  91258. onMaterialRemovedObservable: Observable<Material>;
  91259. /**
  91260. * An event triggered when a texture is created
  91261. */
  91262. onNewTextureAddedObservable: Observable<BaseTexture>;
  91263. /**
  91264. * An event triggered when a texture is removed
  91265. */
  91266. onTextureRemovedObservable: Observable<BaseTexture>;
  91267. /**
  91268. * An event triggered when render targets are about to be rendered
  91269. * Can happen multiple times per frame.
  91270. */
  91271. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  91272. /**
  91273. * An event triggered when render targets were rendered.
  91274. * Can happen multiple times per frame.
  91275. */
  91276. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  91277. /**
  91278. * An event triggered before calculating deterministic simulation step
  91279. */
  91280. onBeforeStepObservable: Observable<Scene>;
  91281. /**
  91282. * An event triggered after calculating deterministic simulation step
  91283. */
  91284. onAfterStepObservable: Observable<Scene>;
  91285. /**
  91286. * An event triggered when the activeCamera property is updated
  91287. */
  91288. onActiveCameraChanged: Observable<Scene>;
  91289. /**
  91290. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  91291. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91292. * 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)
  91293. */
  91294. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91295. /**
  91296. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  91297. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91298. * 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)
  91299. */
  91300. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91301. /**
  91302. * This Observable will when a mesh has been imported into the scene.
  91303. */
  91304. onMeshImportedObservable: Observable<AbstractMesh>;
  91305. /**
  91306. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  91307. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  91308. */
  91309. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  91310. /** @hidden */
  91311. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  91312. /**
  91313. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  91314. */
  91315. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  91316. /**
  91317. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  91318. */
  91319. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  91320. /**
  91321. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  91322. */
  91323. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  91324. private _onPointerMove;
  91325. private _onPointerDown;
  91326. private _onPointerUp;
  91327. /** Callback called when a pointer move is detected */
  91328. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91329. /** Callback called when a pointer down is detected */
  91330. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91331. /** Callback called when a pointer up is detected */
  91332. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  91333. /** Callback called when a pointer pick is detected */
  91334. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  91335. /**
  91336. * 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).
  91337. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  91338. */
  91339. onPrePointerObservable: Observable<PointerInfoPre>;
  91340. /**
  91341. * Observable event triggered each time an input event is received from the rendering canvas
  91342. */
  91343. onPointerObservable: Observable<PointerInfo>;
  91344. /**
  91345. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  91346. */
  91347. readonly unTranslatedPointer: Vector2;
  91348. /** The distance in pixel that you have to move to prevent some events */
  91349. static DragMovementThreshold: number;
  91350. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91351. static LongPressDelay: number;
  91352. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91353. static DoubleClickDelay: number;
  91354. /** If you need to check double click without raising a single click at first click, enable this flag */
  91355. static ExclusiveDoubleClickMode: boolean;
  91356. private _initClickEvent;
  91357. private _initActionManager;
  91358. private _delayedSimpleClick;
  91359. private _delayedSimpleClickTimeout;
  91360. private _previousDelayedSimpleClickTimeout;
  91361. private _meshPickProceed;
  91362. private _previousButtonPressed;
  91363. private _currentPickResult;
  91364. private _previousPickResult;
  91365. private _totalPointersPressed;
  91366. private _doubleClickOccured;
  91367. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91368. cameraToUseForPointers: Nullable<Camera>;
  91369. private _pointerX;
  91370. private _pointerY;
  91371. private _unTranslatedPointerX;
  91372. private _unTranslatedPointerY;
  91373. private _startingPointerPosition;
  91374. private _previousStartingPointerPosition;
  91375. private _startingPointerTime;
  91376. private _previousStartingPointerTime;
  91377. private _pointerCaptures;
  91378. private _timeAccumulator;
  91379. private _currentStepId;
  91380. private _currentInternalStep;
  91381. /** @hidden */
  91382. _mirroredCameraPosition: Nullable<Vector3>;
  91383. /**
  91384. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  91385. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  91386. */
  91387. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  91388. /**
  91389. * Observable event triggered each time an keyboard event is received from the hosting window
  91390. */
  91391. onKeyboardObservable: Observable<KeyboardInfo>;
  91392. private _onKeyDown;
  91393. private _onKeyUp;
  91394. private _onCanvasFocusObserver;
  91395. private _onCanvasBlurObserver;
  91396. private _useRightHandedSystem;
  91397. /**
  91398. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  91399. */
  91400. useRightHandedSystem: boolean;
  91401. /**
  91402. * Sets the step Id used by deterministic lock step
  91403. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91404. * @param newStepId defines the step Id
  91405. */
  91406. setStepId(newStepId: number): void;
  91407. /**
  91408. * Gets the step Id used by deterministic lock step
  91409. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91410. * @returns the step Id
  91411. */
  91412. getStepId(): number;
  91413. /**
  91414. * Gets the internal step used by deterministic lock step
  91415. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91416. * @returns the internal step
  91417. */
  91418. getInternalStep(): number;
  91419. private _fogEnabled;
  91420. /**
  91421. * Gets or sets a boolean indicating if fog is enabled on this scene
  91422. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91423. * (Default is true)
  91424. */
  91425. fogEnabled: boolean;
  91426. private _fogMode;
  91427. /**
  91428. * Gets or sets the fog mode to use
  91429. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91430. * | mode | value |
  91431. * | --- | --- |
  91432. * | FOGMODE_NONE | 0 |
  91433. * | FOGMODE_EXP | 1 |
  91434. * | FOGMODE_EXP2 | 2 |
  91435. * | FOGMODE_LINEAR | 3 |
  91436. */
  91437. fogMode: number;
  91438. /**
  91439. * Gets or sets the fog color to use
  91440. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91441. * (Default is Color3(0.2, 0.2, 0.3))
  91442. */
  91443. fogColor: Color3;
  91444. /**
  91445. * Gets or sets the fog density to use
  91446. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91447. * (Default is 0.1)
  91448. */
  91449. fogDensity: number;
  91450. /**
  91451. * Gets or sets the fog start distance to use
  91452. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91453. * (Default is 0)
  91454. */
  91455. fogStart: number;
  91456. /**
  91457. * Gets or sets the fog end distance to use
  91458. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91459. * (Default is 1000)
  91460. */
  91461. fogEnd: number;
  91462. private _shadowsEnabled;
  91463. /**
  91464. * Gets or sets a boolean indicating if shadows are enabled on this scene
  91465. */
  91466. shadowsEnabled: boolean;
  91467. private _lightsEnabled;
  91468. /**
  91469. * Gets or sets a boolean indicating if lights are enabled on this scene
  91470. */
  91471. lightsEnabled: boolean;
  91472. /** All of the active cameras added to this scene. */
  91473. activeCameras: Camera[];
  91474. /** @hidden */
  91475. _activeCamera: Nullable<Camera>;
  91476. /** Gets or sets the current active camera */
  91477. activeCamera: Nullable<Camera>;
  91478. private _defaultMaterial;
  91479. /** The default material used on meshes when no material is affected */
  91480. /** The default material used on meshes when no material is affected */
  91481. defaultMaterial: Material;
  91482. private _texturesEnabled;
  91483. /**
  91484. * Gets or sets a boolean indicating if textures are enabled on this scene
  91485. */
  91486. texturesEnabled: boolean;
  91487. /**
  91488. * Gets or sets a boolean indicating if particles are enabled on this scene
  91489. */
  91490. particlesEnabled: boolean;
  91491. /**
  91492. * Gets or sets a boolean indicating if sprites are enabled on this scene
  91493. */
  91494. spritesEnabled: boolean;
  91495. private _skeletonsEnabled;
  91496. /**
  91497. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  91498. */
  91499. skeletonsEnabled: boolean;
  91500. /**
  91501. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  91502. */
  91503. lensFlaresEnabled: boolean;
  91504. /**
  91505. * Gets or sets a boolean indicating if collisions are enabled on this scene
  91506. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91507. */
  91508. collisionsEnabled: boolean;
  91509. private _collisionCoordinator;
  91510. /** @hidden */
  91511. readonly collisionCoordinator: ICollisionCoordinator;
  91512. /**
  91513. * Defines the gravity applied to this scene (used only for collisions)
  91514. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91515. */
  91516. gravity: Vector3;
  91517. /**
  91518. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  91519. */
  91520. postProcessesEnabled: boolean;
  91521. /**
  91522. * The list of postprocesses added to the scene
  91523. */
  91524. postProcesses: PostProcess[];
  91525. /**
  91526. * Gets the current postprocess manager
  91527. */
  91528. postProcessManager: PostProcessManager;
  91529. /**
  91530. * Gets or sets a boolean indicating if render targets are enabled on this scene
  91531. */
  91532. renderTargetsEnabled: boolean;
  91533. /**
  91534. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  91535. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  91536. */
  91537. dumpNextRenderTargets: boolean;
  91538. /**
  91539. * The list of user defined render targets added to the scene
  91540. */
  91541. customRenderTargets: RenderTargetTexture[];
  91542. /**
  91543. * Defines if texture loading must be delayed
  91544. * If true, textures will only be loaded when they need to be rendered
  91545. */
  91546. useDelayedTextureLoading: boolean;
  91547. /**
  91548. * Gets the list of meshes imported to the scene through SceneLoader
  91549. */
  91550. importedMeshesFiles: String[];
  91551. /**
  91552. * Gets or sets a boolean indicating if probes are enabled on this scene
  91553. */
  91554. probesEnabled: boolean;
  91555. /**
  91556. * Gets or sets the current offline provider to use to store scene data
  91557. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  91558. */
  91559. offlineProvider: IOfflineProvider;
  91560. /**
  91561. * Gets or sets the action manager associated with the scene
  91562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91563. */
  91564. actionManager: AbstractActionManager;
  91565. private _meshesForIntersections;
  91566. /**
  91567. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  91568. */
  91569. proceduralTexturesEnabled: boolean;
  91570. private _engine;
  91571. private _totalVertices;
  91572. /** @hidden */
  91573. _activeIndices: PerfCounter;
  91574. /** @hidden */
  91575. _activeParticles: PerfCounter;
  91576. /** @hidden */
  91577. _activeBones: PerfCounter;
  91578. private _animationRatio;
  91579. /** @hidden */
  91580. _animationTimeLast: number;
  91581. /** @hidden */
  91582. _animationTime: number;
  91583. /**
  91584. * Gets or sets a general scale for animation speed
  91585. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  91586. */
  91587. animationTimeScale: number;
  91588. /** @hidden */
  91589. _cachedMaterial: Nullable<Material>;
  91590. /** @hidden */
  91591. _cachedEffect: Nullable<Effect>;
  91592. /** @hidden */
  91593. _cachedVisibility: Nullable<number>;
  91594. private _renderId;
  91595. private _frameId;
  91596. private _executeWhenReadyTimeoutId;
  91597. private _intermediateRendering;
  91598. private _viewUpdateFlag;
  91599. private _projectionUpdateFlag;
  91600. /** @hidden */
  91601. _toBeDisposed: Nullable<IDisposable>[];
  91602. private _activeRequests;
  91603. /** @hidden */
  91604. _pendingData: any[];
  91605. private _isDisposed;
  91606. /**
  91607. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  91608. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  91609. */
  91610. dispatchAllSubMeshesOfActiveMeshes: boolean;
  91611. private _activeMeshes;
  91612. private _processedMaterials;
  91613. private _renderTargets;
  91614. /** @hidden */
  91615. _activeParticleSystems: SmartArray<IParticleSystem>;
  91616. private _activeSkeletons;
  91617. private _softwareSkinnedMeshes;
  91618. private _renderingManager;
  91619. /** @hidden */
  91620. _activeAnimatables: Animatable[];
  91621. private _transformMatrix;
  91622. private _sceneUbo;
  91623. /** @hidden */
  91624. _viewMatrix: Matrix;
  91625. private _projectionMatrix;
  91626. private _wheelEventName;
  91627. /** @hidden */
  91628. _forcedViewPosition: Nullable<Vector3>;
  91629. /** @hidden */
  91630. _frustumPlanes: Plane[];
  91631. /**
  91632. * Gets the list of frustum planes (built from the active camera)
  91633. */
  91634. readonly frustumPlanes: Plane[];
  91635. /**
  91636. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  91637. * This is useful if there are more lights that the maximum simulteanous authorized
  91638. */
  91639. requireLightSorting: boolean;
  91640. /** @hidden */
  91641. readonly useMaterialMeshMap: boolean;
  91642. /** @hidden */
  91643. readonly useClonedMeshhMap: boolean;
  91644. private _pointerOverMesh;
  91645. private _pickedDownMesh;
  91646. private _pickedUpMesh;
  91647. private _externalData;
  91648. private _uid;
  91649. /**
  91650. * @hidden
  91651. * Backing store of defined scene components.
  91652. */
  91653. _components: ISceneComponent[];
  91654. /**
  91655. * @hidden
  91656. * Backing store of defined scene components.
  91657. */
  91658. _serializableComponents: ISceneSerializableComponent[];
  91659. /**
  91660. * List of components to register on the next registration step.
  91661. */
  91662. private _transientComponents;
  91663. /**
  91664. * Registers the transient components if needed.
  91665. */
  91666. private _registerTransientComponents;
  91667. /**
  91668. * @hidden
  91669. * Add a component to the scene.
  91670. * Note that the ccomponent could be registered on th next frame if this is called after
  91671. * the register component stage.
  91672. * @param component Defines the component to add to the scene
  91673. */
  91674. _addComponent(component: ISceneComponent): void;
  91675. /**
  91676. * @hidden
  91677. * Gets a component from the scene.
  91678. * @param name defines the name of the component to retrieve
  91679. * @returns the component or null if not present
  91680. */
  91681. _getComponent(name: string): Nullable<ISceneComponent>;
  91682. /**
  91683. * @hidden
  91684. * Defines the actions happening before camera updates.
  91685. */
  91686. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  91687. /**
  91688. * @hidden
  91689. * Defines the actions happening before clear the canvas.
  91690. */
  91691. _beforeClearStage: Stage<SimpleStageAction>;
  91692. /**
  91693. * @hidden
  91694. * Defines the actions when collecting render targets for the frame.
  91695. */
  91696. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91697. /**
  91698. * @hidden
  91699. * Defines the actions happening for one camera in the frame.
  91700. */
  91701. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91702. /**
  91703. * @hidden
  91704. * Defines the actions happening during the per mesh ready checks.
  91705. */
  91706. _isReadyForMeshStage: Stage<MeshStageAction>;
  91707. /**
  91708. * @hidden
  91709. * Defines the actions happening before evaluate active mesh checks.
  91710. */
  91711. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  91712. /**
  91713. * @hidden
  91714. * Defines the actions happening during the evaluate sub mesh checks.
  91715. */
  91716. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  91717. /**
  91718. * @hidden
  91719. * Defines the actions happening during the active mesh stage.
  91720. */
  91721. _activeMeshStage: Stage<ActiveMeshStageAction>;
  91722. /**
  91723. * @hidden
  91724. * Defines the actions happening during the per camera render target step.
  91725. */
  91726. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  91727. /**
  91728. * @hidden
  91729. * Defines the actions happening just before the active camera is drawing.
  91730. */
  91731. _beforeCameraDrawStage: Stage<CameraStageAction>;
  91732. /**
  91733. * @hidden
  91734. * Defines the actions happening just before a render target is drawing.
  91735. */
  91736. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91737. /**
  91738. * @hidden
  91739. * Defines the actions happening just before a rendering group is drawing.
  91740. */
  91741. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91742. /**
  91743. * @hidden
  91744. * Defines the actions happening just before a mesh is drawing.
  91745. */
  91746. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91747. /**
  91748. * @hidden
  91749. * Defines the actions happening just after a mesh has been drawn.
  91750. */
  91751. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91752. /**
  91753. * @hidden
  91754. * Defines the actions happening just after a rendering group has been drawn.
  91755. */
  91756. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91757. /**
  91758. * @hidden
  91759. * Defines the actions happening just after the active camera has been drawn.
  91760. */
  91761. _afterCameraDrawStage: Stage<CameraStageAction>;
  91762. /**
  91763. * @hidden
  91764. * Defines the actions happening just after a render target has been drawn.
  91765. */
  91766. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91767. /**
  91768. * @hidden
  91769. * Defines the actions happening just after rendering all cameras and computing intersections.
  91770. */
  91771. _afterRenderStage: Stage<SimpleStageAction>;
  91772. /**
  91773. * @hidden
  91774. * Defines the actions happening when a pointer move event happens.
  91775. */
  91776. _pointerMoveStage: Stage<PointerMoveStageAction>;
  91777. /**
  91778. * @hidden
  91779. * Defines the actions happening when a pointer down event happens.
  91780. */
  91781. _pointerDownStage: Stage<PointerUpDownStageAction>;
  91782. /**
  91783. * @hidden
  91784. * Defines the actions happening when a pointer up event happens.
  91785. */
  91786. _pointerUpStage: Stage<PointerUpDownStageAction>;
  91787. /**
  91788. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  91789. */
  91790. private geometriesByUniqueId;
  91791. /**
  91792. * Creates a new Scene
  91793. * @param engine defines the engine to use to render this scene
  91794. * @param options defines the scene options
  91795. */
  91796. constructor(engine: Engine, options?: SceneOptions);
  91797. /**
  91798. * Gets a string idenfifying the name of the class
  91799. * @returns "Scene" string
  91800. */
  91801. getClassName(): string;
  91802. private _defaultMeshCandidates;
  91803. /**
  91804. * @hidden
  91805. */
  91806. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  91807. private _defaultSubMeshCandidates;
  91808. /**
  91809. * @hidden
  91810. */
  91811. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  91812. /**
  91813. * Sets the default candidate providers for the scene.
  91814. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  91815. * and getCollidingSubMeshCandidates to their default function
  91816. */
  91817. setDefaultCandidateProviders(): void;
  91818. /**
  91819. * Gets the mesh that is currently under the pointer
  91820. */
  91821. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91822. /**
  91823. * Gets or sets the current on-screen X position of the pointer
  91824. */
  91825. pointerX: number;
  91826. /**
  91827. * Gets or sets the current on-screen Y position of the pointer
  91828. */
  91829. pointerY: number;
  91830. /**
  91831. * Gets the cached material (ie. the latest rendered one)
  91832. * @returns the cached material
  91833. */
  91834. getCachedMaterial(): Nullable<Material>;
  91835. /**
  91836. * Gets the cached effect (ie. the latest rendered one)
  91837. * @returns the cached effect
  91838. */
  91839. getCachedEffect(): Nullable<Effect>;
  91840. /**
  91841. * Gets the cached visibility state (ie. the latest rendered one)
  91842. * @returns the cached visibility state
  91843. */
  91844. getCachedVisibility(): Nullable<number>;
  91845. /**
  91846. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  91847. * @param material defines the current material
  91848. * @param effect defines the current effect
  91849. * @param visibility defines the current visibility state
  91850. * @returns true if one parameter is not cached
  91851. */
  91852. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  91853. /**
  91854. * Gets the engine associated with the scene
  91855. * @returns an Engine
  91856. */
  91857. getEngine(): Engine;
  91858. /**
  91859. * Gets the total number of vertices rendered per frame
  91860. * @returns the total number of vertices rendered per frame
  91861. */
  91862. getTotalVertices(): number;
  91863. /**
  91864. * Gets the performance counter for total vertices
  91865. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91866. */
  91867. readonly totalVerticesPerfCounter: PerfCounter;
  91868. /**
  91869. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  91870. * @returns the total number of active indices rendered per frame
  91871. */
  91872. getActiveIndices(): number;
  91873. /**
  91874. * Gets the performance counter for active indices
  91875. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91876. */
  91877. readonly totalActiveIndicesPerfCounter: PerfCounter;
  91878. /**
  91879. * Gets the total number of active particles rendered per frame
  91880. * @returns the total number of active particles rendered per frame
  91881. */
  91882. getActiveParticles(): number;
  91883. /**
  91884. * Gets the performance counter for active particles
  91885. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91886. */
  91887. readonly activeParticlesPerfCounter: PerfCounter;
  91888. /**
  91889. * Gets the total number of active bones rendered per frame
  91890. * @returns the total number of active bones rendered per frame
  91891. */
  91892. getActiveBones(): number;
  91893. /**
  91894. * Gets the performance counter for active bones
  91895. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91896. */
  91897. readonly activeBonesPerfCounter: PerfCounter;
  91898. /**
  91899. * Gets the array of active meshes
  91900. * @returns an array of AbstractMesh
  91901. */
  91902. getActiveMeshes(): SmartArray<AbstractMesh>;
  91903. /**
  91904. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  91905. * @returns a number
  91906. */
  91907. getAnimationRatio(): number;
  91908. /**
  91909. * Gets an unique Id for the current render phase
  91910. * @returns a number
  91911. */
  91912. getRenderId(): number;
  91913. /**
  91914. * Gets an unique Id for the current frame
  91915. * @returns a number
  91916. */
  91917. getFrameId(): number;
  91918. /** Call this function if you want to manually increment the render Id*/
  91919. incrementRenderId(): void;
  91920. private _updatePointerPosition;
  91921. private _createUbo;
  91922. private _setRayOnPointerInfo;
  91923. /**
  91924. * Use this method to simulate a pointer move on a mesh
  91925. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91926. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91927. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91928. * @returns the current scene
  91929. */
  91930. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91931. private _processPointerMove;
  91932. private _checkPrePointerObservable;
  91933. /**
  91934. * Use this method to simulate a pointer down on a mesh
  91935. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91936. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91937. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91938. * @returns the current scene
  91939. */
  91940. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  91941. private _processPointerDown;
  91942. /**
  91943. * Use this method to simulate a pointer up on a mesh
  91944. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  91945. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  91946. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  91947. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  91948. * @returns the current scene
  91949. */
  91950. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  91951. private _processPointerUp;
  91952. /**
  91953. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  91954. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  91955. * @returns true if the pointer was captured
  91956. */
  91957. isPointerCaptured(pointerId?: number): boolean;
  91958. /** @hidden */
  91959. _isPointerSwiping(): boolean;
  91960. /**
  91961. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  91962. * @param attachUp defines if you want to attach events to pointerup
  91963. * @param attachDown defines if you want to attach events to pointerdown
  91964. * @param attachMove defines if you want to attach events to pointermove
  91965. */
  91966. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  91967. /** Detaches all event handlers*/
  91968. detachControl(): void;
  91969. /**
  91970. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  91971. * Delay loaded resources are not taking in account
  91972. * @return true if all required resources are ready
  91973. */
  91974. isReady(): boolean;
  91975. /** Resets all cached information relative to material (including effect and visibility) */
  91976. resetCachedMaterial(): void;
  91977. /**
  91978. * Registers a function to be called before every frame render
  91979. * @param func defines the function to register
  91980. */
  91981. registerBeforeRender(func: () => void): void;
  91982. /**
  91983. * Unregisters a function called before every frame render
  91984. * @param func defines the function to unregister
  91985. */
  91986. unregisterBeforeRender(func: () => void): void;
  91987. /**
  91988. * Registers a function to be called after every frame render
  91989. * @param func defines the function to register
  91990. */
  91991. registerAfterRender(func: () => void): void;
  91992. /**
  91993. * Unregisters a function called after every frame render
  91994. * @param func defines the function to unregister
  91995. */
  91996. unregisterAfterRender(func: () => void): void;
  91997. private _executeOnceBeforeRender;
  91998. /**
  91999. * The provided function will run before render once and will be disposed afterwards.
  92000. * A timeout delay can be provided so that the function will be executed in N ms.
  92001. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92002. * @param func The function to be executed.
  92003. * @param timeout optional delay in ms
  92004. */
  92005. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92006. /** @hidden */
  92007. _addPendingData(data: any): void;
  92008. /** @hidden */
  92009. _removePendingData(data: any): void;
  92010. /**
  92011. * Returns the number of items waiting to be loaded
  92012. * @returns the number of items waiting to be loaded
  92013. */
  92014. getWaitingItemsCount(): number;
  92015. /**
  92016. * Returns a boolean indicating if the scene is still loading data
  92017. */
  92018. readonly isLoading: boolean;
  92019. /**
  92020. * Registers a function to be executed when the scene is ready
  92021. * @param {Function} func - the function to be executed
  92022. */
  92023. executeWhenReady(func: () => void): void;
  92024. /**
  92025. * Returns a promise that resolves when the scene is ready
  92026. * @returns A promise that resolves when the scene is ready
  92027. */
  92028. whenReadyAsync(): Promise<void>;
  92029. /** @hidden */
  92030. _checkIsReady(): void;
  92031. /**
  92032. * Gets all animatable attached to the scene
  92033. */
  92034. readonly animatables: Animatable[];
  92035. /**
  92036. * Resets the last animation time frame.
  92037. * Useful to override when animations start running when loading a scene for the first time.
  92038. */
  92039. resetLastAnimationTimeFrame(): void;
  92040. /**
  92041. * Gets the current view matrix
  92042. * @returns a Matrix
  92043. */
  92044. getViewMatrix(): Matrix;
  92045. /**
  92046. * Gets the current projection matrix
  92047. * @returns a Matrix
  92048. */
  92049. getProjectionMatrix(): Matrix;
  92050. /**
  92051. * Gets the current transform matrix
  92052. * @returns a Matrix made of View * Projection
  92053. */
  92054. getTransformMatrix(): Matrix;
  92055. /**
  92056. * Sets the current transform matrix
  92057. * @param viewL defines the View matrix to use
  92058. * @param projectionL defines the Projection matrix to use
  92059. * @param viewR defines the right View matrix to use (if provided)
  92060. * @param projectionR defines the right Projection matrix to use (if provided)
  92061. */
  92062. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92063. /**
  92064. * Gets the uniform buffer used to store scene data
  92065. * @returns a UniformBuffer
  92066. */
  92067. getSceneUniformBuffer(): UniformBuffer;
  92068. /**
  92069. * Gets an unique (relatively to the current scene) Id
  92070. * @returns an unique number for the scene
  92071. */
  92072. getUniqueId(): number;
  92073. /**
  92074. * Add a mesh to the list of scene's meshes
  92075. * @param newMesh defines the mesh to add
  92076. * @param recursive if all child meshes should also be added to the scene
  92077. */
  92078. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92079. /**
  92080. * Remove a mesh for the list of scene's meshes
  92081. * @param toRemove defines the mesh to remove
  92082. * @param recursive if all child meshes should also be removed from the scene
  92083. * @returns the index where the mesh was in the mesh list
  92084. */
  92085. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92086. /**
  92087. * Add a transform node to the list of scene's transform nodes
  92088. * @param newTransformNode defines the transform node to add
  92089. */
  92090. addTransformNode(newTransformNode: TransformNode): void;
  92091. /**
  92092. * Remove a transform node for the list of scene's transform nodes
  92093. * @param toRemove defines the transform node to remove
  92094. * @returns the index where the transform node was in the transform node list
  92095. */
  92096. removeTransformNode(toRemove: TransformNode): number;
  92097. /**
  92098. * Remove a skeleton for the list of scene's skeletons
  92099. * @param toRemove defines the skeleton to remove
  92100. * @returns the index where the skeleton was in the skeleton list
  92101. */
  92102. removeSkeleton(toRemove: Skeleton): number;
  92103. /**
  92104. * Remove a morph target for the list of scene's morph targets
  92105. * @param toRemove defines the morph target to remove
  92106. * @returns the index where the morph target was in the morph target list
  92107. */
  92108. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92109. /**
  92110. * Remove a light for the list of scene's lights
  92111. * @param toRemove defines the light to remove
  92112. * @returns the index where the light was in the light list
  92113. */
  92114. removeLight(toRemove: Light): number;
  92115. /**
  92116. * Remove a camera for the list of scene's cameras
  92117. * @param toRemove defines the camera to remove
  92118. * @returns the index where the camera was in the camera list
  92119. */
  92120. removeCamera(toRemove: Camera): number;
  92121. /**
  92122. * Remove a particle system for the list of scene's particle systems
  92123. * @param toRemove defines the particle system to remove
  92124. * @returns the index where the particle system was in the particle system list
  92125. */
  92126. removeParticleSystem(toRemove: IParticleSystem): number;
  92127. /**
  92128. * Remove a animation for the list of scene's animations
  92129. * @param toRemove defines the animation to remove
  92130. * @returns the index where the animation was in the animation list
  92131. */
  92132. removeAnimation(toRemove: Animation): number;
  92133. /**
  92134. * Removes the given animation group from this scene.
  92135. * @param toRemove The animation group to remove
  92136. * @returns The index of the removed animation group
  92137. */
  92138. removeAnimationGroup(toRemove: AnimationGroup): number;
  92139. /**
  92140. * Removes the given multi-material from this scene.
  92141. * @param toRemove The multi-material to remove
  92142. * @returns The index of the removed multi-material
  92143. */
  92144. removeMultiMaterial(toRemove: MultiMaterial): number;
  92145. /**
  92146. * Removes the given material from this scene.
  92147. * @param toRemove The material to remove
  92148. * @returns The index of the removed material
  92149. */
  92150. removeMaterial(toRemove: Material): number;
  92151. /**
  92152. * Removes the given action manager from this scene.
  92153. * @param toRemove The action manager to remove
  92154. * @returns The index of the removed action manager
  92155. */
  92156. removeActionManager(toRemove: AbstractActionManager): number;
  92157. /**
  92158. * Removes the given texture from this scene.
  92159. * @param toRemove The texture to remove
  92160. * @returns The index of the removed texture
  92161. */
  92162. removeTexture(toRemove: BaseTexture): number;
  92163. /**
  92164. * Adds the given light to this scene
  92165. * @param newLight The light to add
  92166. */
  92167. addLight(newLight: Light): void;
  92168. /**
  92169. * Sorts the list list based on light priorities
  92170. */
  92171. sortLightsByPriority(): void;
  92172. /**
  92173. * Adds the given camera to this scene
  92174. * @param newCamera The camera to add
  92175. */
  92176. addCamera(newCamera: Camera): void;
  92177. /**
  92178. * Adds the given skeleton to this scene
  92179. * @param newSkeleton The skeleton to add
  92180. */
  92181. addSkeleton(newSkeleton: Skeleton): void;
  92182. /**
  92183. * Adds the given particle system to this scene
  92184. * @param newParticleSystem The particle system to add
  92185. */
  92186. addParticleSystem(newParticleSystem: IParticleSystem): void;
  92187. /**
  92188. * Adds the given animation to this scene
  92189. * @param newAnimation The animation to add
  92190. */
  92191. addAnimation(newAnimation: Animation): void;
  92192. /**
  92193. * Adds the given animation group to this scene.
  92194. * @param newAnimationGroup The animation group to add
  92195. */
  92196. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  92197. /**
  92198. * Adds the given multi-material to this scene
  92199. * @param newMultiMaterial The multi-material to add
  92200. */
  92201. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  92202. /**
  92203. * Adds the given material to this scene
  92204. * @param newMaterial The material to add
  92205. */
  92206. addMaterial(newMaterial: Material): void;
  92207. /**
  92208. * Adds the given morph target to this scene
  92209. * @param newMorphTargetManager The morph target to add
  92210. */
  92211. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  92212. /**
  92213. * Adds the given geometry to this scene
  92214. * @param newGeometry The geometry to add
  92215. */
  92216. addGeometry(newGeometry: Geometry): void;
  92217. /**
  92218. * Adds the given action manager to this scene
  92219. * @param newActionManager The action manager to add
  92220. */
  92221. addActionManager(newActionManager: AbstractActionManager): void;
  92222. /**
  92223. * Adds the given texture to this scene.
  92224. * @param newTexture The texture to add
  92225. */
  92226. addTexture(newTexture: BaseTexture): void;
  92227. /**
  92228. * Switch active camera
  92229. * @param newCamera defines the new active camera
  92230. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  92231. */
  92232. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  92233. /**
  92234. * sets the active camera of the scene using its ID
  92235. * @param id defines the camera's ID
  92236. * @return the new active camera or null if none found.
  92237. */
  92238. setActiveCameraByID(id: string): Nullable<Camera>;
  92239. /**
  92240. * sets the active camera of the scene using its name
  92241. * @param name defines the camera's name
  92242. * @returns the new active camera or null if none found.
  92243. */
  92244. setActiveCameraByName(name: string): Nullable<Camera>;
  92245. /**
  92246. * get an animation group using its name
  92247. * @param name defines the material's name
  92248. * @return the animation group or null if none found.
  92249. */
  92250. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  92251. /**
  92252. * Get a material using its unique id
  92253. * @param uniqueId defines the material's unique id
  92254. * @return the material or null if none found.
  92255. */
  92256. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  92257. /**
  92258. * get a material using its id
  92259. * @param id defines the material's ID
  92260. * @return the material or null if none found.
  92261. */
  92262. getMaterialByID(id: string): Nullable<Material>;
  92263. /**
  92264. * Gets a material using its name
  92265. * @param name defines the material's name
  92266. * @return the material or null if none found.
  92267. */
  92268. getMaterialByName(name: string): Nullable<Material>;
  92269. /**
  92270. * Gets a camera using its id
  92271. * @param id defines the id to look for
  92272. * @returns the camera or null if not found
  92273. */
  92274. getCameraByID(id: string): Nullable<Camera>;
  92275. /**
  92276. * Gets a camera using its unique id
  92277. * @param uniqueId defines the unique id to look for
  92278. * @returns the camera or null if not found
  92279. */
  92280. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  92281. /**
  92282. * Gets a camera using its name
  92283. * @param name defines the camera's name
  92284. * @return the camera or null if none found.
  92285. */
  92286. getCameraByName(name: string): Nullable<Camera>;
  92287. /**
  92288. * Gets a bone using its id
  92289. * @param id defines the bone's id
  92290. * @return the bone or null if not found
  92291. */
  92292. getBoneByID(id: string): Nullable<Bone>;
  92293. /**
  92294. * Gets a bone using its id
  92295. * @param name defines the bone's name
  92296. * @return the bone or null if not found
  92297. */
  92298. getBoneByName(name: string): Nullable<Bone>;
  92299. /**
  92300. * Gets a light node using its name
  92301. * @param name defines the the light's name
  92302. * @return the light or null if none found.
  92303. */
  92304. getLightByName(name: string): Nullable<Light>;
  92305. /**
  92306. * Gets a light node using its id
  92307. * @param id defines the light's id
  92308. * @return the light or null if none found.
  92309. */
  92310. getLightByID(id: string): Nullable<Light>;
  92311. /**
  92312. * Gets a light node using its scene-generated unique ID
  92313. * @param uniqueId defines the light's unique id
  92314. * @return the light or null if none found.
  92315. */
  92316. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  92317. /**
  92318. * Gets a particle system by id
  92319. * @param id defines the particle system id
  92320. * @return the corresponding system or null if none found
  92321. */
  92322. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  92323. /**
  92324. * Gets a geometry using its ID
  92325. * @param id defines the geometry's id
  92326. * @return the geometry or null if none found.
  92327. */
  92328. getGeometryByID(id: string): Nullable<Geometry>;
  92329. private _getGeometryByUniqueID;
  92330. /**
  92331. * Add a new geometry to this scene
  92332. * @param geometry defines the geometry to be added to the scene.
  92333. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  92334. * @return a boolean defining if the geometry was added or not
  92335. */
  92336. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  92337. /**
  92338. * Removes an existing geometry
  92339. * @param geometry defines the geometry to be removed from the scene
  92340. * @return a boolean defining if the geometry was removed or not
  92341. */
  92342. removeGeometry(geometry: Geometry): boolean;
  92343. /**
  92344. * Gets the list of geometries attached to the scene
  92345. * @returns an array of Geometry
  92346. */
  92347. getGeometries(): Geometry[];
  92348. /**
  92349. * Gets the first added mesh found of a given ID
  92350. * @param id defines the id to search for
  92351. * @return the mesh found or null if not found at all
  92352. */
  92353. getMeshByID(id: string): Nullable<AbstractMesh>;
  92354. /**
  92355. * Gets a list of meshes using their id
  92356. * @param id defines the id to search for
  92357. * @returns a list of meshes
  92358. */
  92359. getMeshesByID(id: string): Array<AbstractMesh>;
  92360. /**
  92361. * Gets the first added transform node found of a given ID
  92362. * @param id defines the id to search for
  92363. * @return the found transform node or null if not found at all.
  92364. */
  92365. getTransformNodeByID(id: string): Nullable<TransformNode>;
  92366. /**
  92367. * Gets a transform node with its auto-generated unique id
  92368. * @param uniqueId efines the unique id to search for
  92369. * @return the found transform node or null if not found at all.
  92370. */
  92371. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  92372. /**
  92373. * Gets a list of transform nodes using their id
  92374. * @param id defines the id to search for
  92375. * @returns a list of transform nodes
  92376. */
  92377. getTransformNodesByID(id: string): Array<TransformNode>;
  92378. /**
  92379. * Gets a mesh with its auto-generated unique id
  92380. * @param uniqueId defines the unique id to search for
  92381. * @return the found mesh or null if not found at all.
  92382. */
  92383. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  92384. /**
  92385. * Gets a the last added mesh using a given id
  92386. * @param id defines the id to search for
  92387. * @return the found mesh or null if not found at all.
  92388. */
  92389. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  92390. /**
  92391. * Gets a the last added node (Mesh, Camera, Light) using a given id
  92392. * @param id defines the id to search for
  92393. * @return the found node or null if not found at all
  92394. */
  92395. getLastEntryByID(id: string): Nullable<Node>;
  92396. /**
  92397. * Gets a node (Mesh, Camera, Light) using a given id
  92398. * @param id defines the id to search for
  92399. * @return the found node or null if not found at all
  92400. */
  92401. getNodeByID(id: string): Nullable<Node>;
  92402. /**
  92403. * Gets a node (Mesh, Camera, Light) using a given name
  92404. * @param name defines the name to search for
  92405. * @return the found node or null if not found at all.
  92406. */
  92407. getNodeByName(name: string): Nullable<Node>;
  92408. /**
  92409. * Gets a mesh using a given name
  92410. * @param name defines the name to search for
  92411. * @return the found mesh or null if not found at all.
  92412. */
  92413. getMeshByName(name: string): Nullable<AbstractMesh>;
  92414. /**
  92415. * Gets a transform node using a given name
  92416. * @param name defines the name to search for
  92417. * @return the found transform node or null if not found at all.
  92418. */
  92419. getTransformNodeByName(name: string): Nullable<TransformNode>;
  92420. /**
  92421. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  92422. * @param id defines the id to search for
  92423. * @return the found skeleton or null if not found at all.
  92424. */
  92425. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  92426. /**
  92427. * Gets a skeleton using a given auto generated unique id
  92428. * @param uniqueId defines the unique id to search for
  92429. * @return the found skeleton or null if not found at all.
  92430. */
  92431. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  92432. /**
  92433. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  92434. * @param id defines the id to search for
  92435. * @return the found skeleton or null if not found at all.
  92436. */
  92437. getSkeletonById(id: string): Nullable<Skeleton>;
  92438. /**
  92439. * Gets a skeleton using a given name
  92440. * @param name defines the name to search for
  92441. * @return the found skeleton or null if not found at all.
  92442. */
  92443. getSkeletonByName(name: string): Nullable<Skeleton>;
  92444. /**
  92445. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  92446. * @param id defines the id to search for
  92447. * @return the found morph target manager or null if not found at all.
  92448. */
  92449. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  92450. /**
  92451. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  92452. * @param id defines the id to search for
  92453. * @return the found morph target or null if not found at all.
  92454. */
  92455. getMorphTargetById(id: string): Nullable<MorphTarget>;
  92456. /**
  92457. * Gets a boolean indicating if the given mesh is active
  92458. * @param mesh defines the mesh to look for
  92459. * @returns true if the mesh is in the active list
  92460. */
  92461. isActiveMesh(mesh: AbstractMesh): boolean;
  92462. /**
  92463. * Return a unique id as a string which can serve as an identifier for the scene
  92464. */
  92465. readonly uid: string;
  92466. /**
  92467. * Add an externaly attached data from its key.
  92468. * This method call will fail and return false, if such key already exists.
  92469. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92470. * @param key the unique key that identifies the data
  92471. * @param data the data object to associate to the key for this Engine instance
  92472. * @return true if no such key were already present and the data was added successfully, false otherwise
  92473. */
  92474. addExternalData<T>(key: string, data: T): boolean;
  92475. /**
  92476. * Get an externaly attached data from its key
  92477. * @param key the unique key that identifies the data
  92478. * @return the associated data, if present (can be null), or undefined if not present
  92479. */
  92480. getExternalData<T>(key: string): Nullable<T>;
  92481. /**
  92482. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92483. * @param key the unique key that identifies the data
  92484. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92485. * @return the associated data, can be null if the factory returned null.
  92486. */
  92487. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92488. /**
  92489. * Remove an externaly attached data from the Engine instance
  92490. * @param key the unique key that identifies the data
  92491. * @return true if the data was successfully removed, false if it doesn't exist
  92492. */
  92493. removeExternalData(key: string): boolean;
  92494. private _evaluateSubMesh;
  92495. /**
  92496. * Clear the processed materials smart array preventing retention point in material dispose.
  92497. */
  92498. freeProcessedMaterials(): void;
  92499. private _preventFreeActiveMeshesAndRenderingGroups;
  92500. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  92501. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  92502. * when disposing several meshes in a row or a hierarchy of meshes.
  92503. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  92504. */
  92505. blockfreeActiveMeshesAndRenderingGroups: boolean;
  92506. /**
  92507. * Clear the active meshes smart array preventing retention point in mesh dispose.
  92508. */
  92509. freeActiveMeshes(): void;
  92510. /**
  92511. * Clear the info related to rendering groups preventing retention points during dispose.
  92512. */
  92513. freeRenderingGroups(): void;
  92514. /** @hidden */
  92515. _isInIntermediateRendering(): boolean;
  92516. /**
  92517. * Lambda returning the list of potentially active meshes.
  92518. */
  92519. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  92520. /**
  92521. * Lambda returning the list of potentially active sub meshes.
  92522. */
  92523. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  92524. /**
  92525. * Lambda returning the list of potentially intersecting sub meshes.
  92526. */
  92527. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  92528. /**
  92529. * Lambda returning the list of potentially colliding sub meshes.
  92530. */
  92531. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  92532. private _activeMeshesFrozen;
  92533. /**
  92534. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  92535. * @returns the current scene
  92536. */
  92537. freezeActiveMeshes(): Scene;
  92538. /**
  92539. * Use this function to restart evaluating active meshes on every frame
  92540. * @returns the current scene
  92541. */
  92542. unfreezeActiveMeshes(): Scene;
  92543. private _evaluateActiveMeshes;
  92544. private _activeMesh;
  92545. /**
  92546. * Update the transform matrix to update from the current active camera
  92547. * @param force defines a boolean used to force the update even if cache is up to date
  92548. */
  92549. updateTransformMatrix(force?: boolean): void;
  92550. private _bindFrameBuffer;
  92551. /** @hidden */
  92552. _allowPostProcessClearColor: boolean;
  92553. /** @hidden */
  92554. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  92555. private _processSubCameras;
  92556. private _checkIntersections;
  92557. /** @hidden */
  92558. _advancePhysicsEngineStep(step: number): void;
  92559. /**
  92560. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  92561. */
  92562. getDeterministicFrameTime: () => number;
  92563. /** @hidden */
  92564. _animate(): void;
  92565. /**
  92566. * Render the scene
  92567. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  92568. */
  92569. render(updateCameras?: boolean): void;
  92570. /**
  92571. * Freeze all materials
  92572. * A frozen material will not be updatable but should be faster to render
  92573. */
  92574. freezeMaterials(): void;
  92575. /**
  92576. * Unfreeze all materials
  92577. * A frozen material will not be updatable but should be faster to render
  92578. */
  92579. unfreezeMaterials(): void;
  92580. /**
  92581. * Releases all held ressources
  92582. */
  92583. dispose(): void;
  92584. /**
  92585. * Gets if the scene is already disposed
  92586. */
  92587. readonly isDisposed: boolean;
  92588. /**
  92589. * Call this function to reduce memory footprint of the scene.
  92590. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  92591. */
  92592. clearCachedVertexData(): void;
  92593. /**
  92594. * This function will remove the local cached buffer data from texture.
  92595. * It will save memory but will prevent the texture from being rebuilt
  92596. */
  92597. cleanCachedTextureBuffer(): void;
  92598. /**
  92599. * Get the world extend vectors with an optional filter
  92600. *
  92601. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  92602. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  92603. */
  92604. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  92605. min: Vector3;
  92606. max: Vector3;
  92607. };
  92608. /**
  92609. * Creates a ray that can be used to pick in the scene
  92610. * @param x defines the x coordinate of the origin (on-screen)
  92611. * @param y defines the y coordinate of the origin (on-screen)
  92612. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92613. * @param camera defines the camera to use for the picking
  92614. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92615. * @returns a Ray
  92616. */
  92617. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  92618. /**
  92619. * Creates a ray that can be used to pick in the scene
  92620. * @param x defines the x coordinate of the origin (on-screen)
  92621. * @param y defines the y coordinate of the origin (on-screen)
  92622. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92623. * @param result defines the ray where to store the picking ray
  92624. * @param camera defines the camera to use for the picking
  92625. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92626. * @returns the current scene
  92627. */
  92628. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  92629. /**
  92630. * Creates a ray that can be used to pick in the scene
  92631. * @param x defines the x coordinate of the origin (on-screen)
  92632. * @param y defines the y coordinate of the origin (on-screen)
  92633. * @param camera defines the camera to use for the picking
  92634. * @returns a Ray
  92635. */
  92636. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  92637. /**
  92638. * Creates a ray that can be used to pick in the scene
  92639. * @param x defines the x coordinate of the origin (on-screen)
  92640. * @param y defines the y coordinate of the origin (on-screen)
  92641. * @param result defines the ray where to store the picking ray
  92642. * @param camera defines the camera to use for the picking
  92643. * @returns the current scene
  92644. */
  92645. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  92646. /** Launch a ray to try to pick a mesh in the scene
  92647. * @param x position on screen
  92648. * @param y position on screen
  92649. * @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
  92650. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  92651. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92652. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92653. * @returns a PickingInfo
  92654. */
  92655. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  92656. /** Use the given ray to pick a mesh in the scene
  92657. * @param ray The ray to use to pick meshes
  92658. * @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
  92659. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  92660. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92661. * @returns a PickingInfo
  92662. */
  92663. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  92664. /**
  92665. * Launch a ray to try to pick a mesh in the scene
  92666. * @param x X position on screen
  92667. * @param y Y position on screen
  92668. * @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
  92669. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92670. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92671. * @returns an array of PickingInfo
  92672. */
  92673. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92674. /**
  92675. * Launch a ray to try to pick a mesh in the scene
  92676. * @param ray Ray to use
  92677. * @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
  92678. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92679. * @returns an array of PickingInfo
  92680. */
  92681. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92682. /**
  92683. * Force the value of meshUnderPointer
  92684. * @param mesh defines the mesh to use
  92685. */
  92686. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  92687. /**
  92688. * Gets the mesh under the pointer
  92689. * @returns a Mesh or null if no mesh is under the pointer
  92690. */
  92691. getPointerOverMesh(): Nullable<AbstractMesh>;
  92692. /** @hidden */
  92693. _rebuildGeometries(): void;
  92694. /** @hidden */
  92695. _rebuildTextures(): void;
  92696. private _getByTags;
  92697. /**
  92698. * Get a list of meshes by tags
  92699. * @param tagsQuery defines the tags query to use
  92700. * @param forEach defines a predicate used to filter results
  92701. * @returns an array of Mesh
  92702. */
  92703. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  92704. /**
  92705. * Get a list of cameras by tags
  92706. * @param tagsQuery defines the tags query to use
  92707. * @param forEach defines a predicate used to filter results
  92708. * @returns an array of Camera
  92709. */
  92710. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  92711. /**
  92712. * Get a list of lights by tags
  92713. * @param tagsQuery defines the tags query to use
  92714. * @param forEach defines a predicate used to filter results
  92715. * @returns an array of Light
  92716. */
  92717. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  92718. /**
  92719. * Get a list of materials by tags
  92720. * @param tagsQuery defines the tags query to use
  92721. * @param forEach defines a predicate used to filter results
  92722. * @returns an array of Material
  92723. */
  92724. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  92725. /**
  92726. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92727. * This allowed control for front to back rendering or reversly depending of the special needs.
  92728. *
  92729. * @param renderingGroupId The rendering group id corresponding to its index
  92730. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92731. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92732. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92733. */
  92734. 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;
  92735. /**
  92736. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92737. *
  92738. * @param renderingGroupId The rendering group id corresponding to its index
  92739. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92740. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92741. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92742. */
  92743. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92744. /**
  92745. * Gets the current auto clear configuration for one rendering group of the rendering
  92746. * manager.
  92747. * @param index the rendering group index to get the information for
  92748. * @returns The auto clear setup for the requested rendering group
  92749. */
  92750. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92751. private _blockMaterialDirtyMechanism;
  92752. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  92753. blockMaterialDirtyMechanism: boolean;
  92754. /**
  92755. * Will flag all materials as dirty to trigger new shader compilation
  92756. * @param flag defines the flag used to specify which material part must be marked as dirty
  92757. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  92758. */
  92759. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  92760. /** @hidden */
  92761. _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;
  92762. /** @hidden */
  92763. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92764. }
  92765. }
  92766. declare module BABYLON {
  92767. /**
  92768. * Set of assets to keep when moving a scene into an asset container.
  92769. */
  92770. export class KeepAssets extends AbstractScene {
  92771. }
  92772. /**
  92773. * Container with a set of assets that can be added or removed from a scene.
  92774. */
  92775. export class AssetContainer extends AbstractScene {
  92776. /**
  92777. * The scene the AssetContainer belongs to.
  92778. */
  92779. scene: Scene;
  92780. /**
  92781. * Instantiates an AssetContainer.
  92782. * @param scene The scene the AssetContainer belongs to.
  92783. */
  92784. constructor(scene: Scene);
  92785. /**
  92786. * Adds all the assets from the container to the scene.
  92787. */
  92788. addAllToScene(): void;
  92789. /**
  92790. * Removes all the assets in the container from the scene
  92791. */
  92792. removeAllFromScene(): void;
  92793. /**
  92794. * Disposes all the assets in the container
  92795. */
  92796. dispose(): void;
  92797. private _moveAssets;
  92798. /**
  92799. * Removes all the assets contained in the scene and adds them to the container.
  92800. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  92801. */
  92802. moveAllFromScene(keepAssets?: KeepAssets): void;
  92803. /**
  92804. * 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.
  92805. * @returns the root mesh
  92806. */
  92807. createRootMesh(): Mesh;
  92808. }
  92809. }
  92810. declare module BABYLON {
  92811. /**
  92812. * Defines how the parser contract is defined.
  92813. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  92814. */
  92815. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  92816. /**
  92817. * Defines how the individual parser contract is defined.
  92818. * These parser can parse an individual asset
  92819. */
  92820. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  92821. /**
  92822. * Base class of the scene acting as a container for the different elements composing a scene.
  92823. * This class is dynamically extended by the different components of the scene increasing
  92824. * flexibility and reducing coupling
  92825. */
  92826. export abstract class AbstractScene {
  92827. /**
  92828. * Stores the list of available parsers in the application.
  92829. */
  92830. private static _BabylonFileParsers;
  92831. /**
  92832. * Stores the list of available individual parsers in the application.
  92833. */
  92834. private static _IndividualBabylonFileParsers;
  92835. /**
  92836. * Adds a parser in the list of available ones
  92837. * @param name Defines the name of the parser
  92838. * @param parser Defines the parser to add
  92839. */
  92840. static AddParser(name: string, parser: BabylonFileParser): void;
  92841. /**
  92842. * Gets a general parser from the list of avaialble ones
  92843. * @param name Defines the name of the parser
  92844. * @returns the requested parser or null
  92845. */
  92846. static GetParser(name: string): Nullable<BabylonFileParser>;
  92847. /**
  92848. * Adds n individual parser in the list of available ones
  92849. * @param name Defines the name of the parser
  92850. * @param parser Defines the parser to add
  92851. */
  92852. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  92853. /**
  92854. * Gets an individual parser from the list of avaialble ones
  92855. * @param name Defines the name of the parser
  92856. * @returns the requested parser or null
  92857. */
  92858. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  92859. /**
  92860. * Parser json data and populate both a scene and its associated container object
  92861. * @param jsonData Defines the data to parse
  92862. * @param scene Defines the scene to parse the data for
  92863. * @param container Defines the container attached to the parsing sequence
  92864. * @param rootUrl Defines the root url of the data
  92865. */
  92866. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  92867. /**
  92868. * Gets the list of root nodes (ie. nodes with no parent)
  92869. */
  92870. rootNodes: Node[];
  92871. /** All of the cameras added to this scene
  92872. * @see http://doc.babylonjs.com/babylon101/cameras
  92873. */
  92874. cameras: Camera[];
  92875. /**
  92876. * All of the lights added to this scene
  92877. * @see http://doc.babylonjs.com/babylon101/lights
  92878. */
  92879. lights: Light[];
  92880. /**
  92881. * All of the (abstract) meshes added to this scene
  92882. */
  92883. meshes: AbstractMesh[];
  92884. /**
  92885. * The list of skeletons added to the scene
  92886. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92887. */
  92888. skeletons: Skeleton[];
  92889. /**
  92890. * All of the particle systems added to this scene
  92891. * @see http://doc.babylonjs.com/babylon101/particles
  92892. */
  92893. particleSystems: IParticleSystem[];
  92894. /**
  92895. * Gets a list of Animations associated with the scene
  92896. */
  92897. animations: Animation[];
  92898. /**
  92899. * All of the animation groups added to this scene
  92900. * @see http://doc.babylonjs.com/how_to/group
  92901. */
  92902. animationGroups: AnimationGroup[];
  92903. /**
  92904. * All of the multi-materials added to this scene
  92905. * @see http://doc.babylonjs.com/how_to/multi_materials
  92906. */
  92907. multiMaterials: MultiMaterial[];
  92908. /**
  92909. * All of the materials added to this scene
  92910. * In the context of a Scene, it is not supposed to be modified manually.
  92911. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  92912. * Note also that the order of the Material wihin the array is not significant and might change.
  92913. * @see http://doc.babylonjs.com/babylon101/materials
  92914. */
  92915. materials: Material[];
  92916. /**
  92917. * The list of morph target managers added to the scene
  92918. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  92919. */
  92920. morphTargetManagers: MorphTargetManager[];
  92921. /**
  92922. * The list of geometries used in the scene.
  92923. */
  92924. geometries: Geometry[];
  92925. /**
  92926. * All of the tranform nodes added to this scene
  92927. * In the context of a Scene, it is not supposed to be modified manually.
  92928. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  92929. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  92930. * @see http://doc.babylonjs.com/how_to/transformnode
  92931. */
  92932. transformNodes: TransformNode[];
  92933. /**
  92934. * ActionManagers available on the scene.
  92935. */
  92936. actionManagers: AbstractActionManager[];
  92937. /**
  92938. * Textures to keep.
  92939. */
  92940. textures: BaseTexture[];
  92941. /**
  92942. * Environment texture for the scene
  92943. */
  92944. environmentTexture: Nullable<BaseTexture>;
  92945. }
  92946. }
  92947. declare module BABYLON {
  92948. /**
  92949. * Defines a sound that can be played in the application.
  92950. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  92951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92952. */
  92953. export class Sound {
  92954. /**
  92955. * The name of the sound in the scene.
  92956. */
  92957. name: string;
  92958. /**
  92959. * Does the sound autoplay once loaded.
  92960. */
  92961. autoplay: boolean;
  92962. /**
  92963. * Does the sound loop after it finishes playing once.
  92964. */
  92965. loop: boolean;
  92966. /**
  92967. * Does the sound use a custom attenuation curve to simulate the falloff
  92968. * happening when the source gets further away from the camera.
  92969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  92970. */
  92971. useCustomAttenuation: boolean;
  92972. /**
  92973. * The sound track id this sound belongs to.
  92974. */
  92975. soundTrackId: number;
  92976. /**
  92977. * Is this sound currently played.
  92978. */
  92979. isPlaying: boolean;
  92980. /**
  92981. * Is this sound currently paused.
  92982. */
  92983. isPaused: boolean;
  92984. /**
  92985. * Does this sound enables spatial sound.
  92986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92987. */
  92988. spatialSound: boolean;
  92989. /**
  92990. * Define the reference distance the sound should be heard perfectly.
  92991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92992. */
  92993. refDistance: number;
  92994. /**
  92995. * Define the roll off factor of spatial sounds.
  92996. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92997. */
  92998. rolloffFactor: number;
  92999. /**
  93000. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93002. */
  93003. maxDistance: number;
  93004. /**
  93005. * Define the distance attenuation model the sound will follow.
  93006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93007. */
  93008. distanceModel: string;
  93009. /**
  93010. * @hidden
  93011. * Back Compat
  93012. **/
  93013. onended: () => any;
  93014. /**
  93015. * Observable event when the current playing sound finishes.
  93016. */
  93017. onEndedObservable: Observable<Sound>;
  93018. private _panningModel;
  93019. private _playbackRate;
  93020. private _streaming;
  93021. private _startTime;
  93022. private _startOffset;
  93023. private _position;
  93024. /** @hidden */
  93025. _positionInEmitterSpace: boolean;
  93026. private _localDirection;
  93027. private _volume;
  93028. private _isReadyToPlay;
  93029. private _isDirectional;
  93030. private _readyToPlayCallback;
  93031. private _audioBuffer;
  93032. private _soundSource;
  93033. private _streamingSource;
  93034. private _soundPanner;
  93035. private _soundGain;
  93036. private _inputAudioNode;
  93037. private _outputAudioNode;
  93038. private _coneInnerAngle;
  93039. private _coneOuterAngle;
  93040. private _coneOuterGain;
  93041. private _scene;
  93042. private _connectedTransformNode;
  93043. private _customAttenuationFunction;
  93044. private _registerFunc;
  93045. private _isOutputConnected;
  93046. private _htmlAudioElement;
  93047. private _urlType;
  93048. /** @hidden */
  93049. static _SceneComponentInitialization: (scene: Scene) => void;
  93050. /**
  93051. * Create a sound and attach it to a scene
  93052. * @param name Name of your sound
  93053. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93054. * @param scene defines the scene the sound belongs to
  93055. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93056. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93057. */
  93058. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93059. /**
  93060. * Release the sound and its associated resources
  93061. */
  93062. dispose(): void;
  93063. /**
  93064. * Gets if the sounds is ready to be played or not.
  93065. * @returns true if ready, otherwise false
  93066. */
  93067. isReady(): boolean;
  93068. private _soundLoaded;
  93069. /**
  93070. * Sets the data of the sound from an audiobuffer
  93071. * @param audioBuffer The audioBuffer containing the data
  93072. */
  93073. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93074. /**
  93075. * Updates the current sounds options such as maxdistance, loop...
  93076. * @param options A JSON object containing values named as the object properties
  93077. */
  93078. updateOptions(options: any): void;
  93079. private _createSpatialParameters;
  93080. private _updateSpatialParameters;
  93081. /**
  93082. * Switch the panning model to HRTF:
  93083. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93084. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93085. */
  93086. switchPanningModelToHRTF(): void;
  93087. /**
  93088. * Switch the panning model to Equal Power:
  93089. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93091. */
  93092. switchPanningModelToEqualPower(): void;
  93093. private _switchPanningModel;
  93094. /**
  93095. * Connect this sound to a sound track audio node like gain...
  93096. * @param soundTrackAudioNode the sound track audio node to connect to
  93097. */
  93098. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93099. /**
  93100. * Transform this sound into a directional source
  93101. * @param coneInnerAngle Size of the inner cone in degree
  93102. * @param coneOuterAngle Size of the outer cone in degree
  93103. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93104. */
  93105. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93106. /**
  93107. * Gets or sets the inner angle for the directional cone.
  93108. */
  93109. /**
  93110. * Gets or sets the inner angle for the directional cone.
  93111. */
  93112. directionalConeInnerAngle: number;
  93113. /**
  93114. * Gets or sets the outer angle for the directional cone.
  93115. */
  93116. /**
  93117. * Gets or sets the outer angle for the directional cone.
  93118. */
  93119. directionalConeOuterAngle: number;
  93120. /**
  93121. * Sets the position of the emitter if spatial sound is enabled
  93122. * @param newPosition Defines the new posisiton
  93123. */
  93124. setPosition(newPosition: Vector3): void;
  93125. /**
  93126. * Sets the local direction of the emitter if spatial sound is enabled
  93127. * @param newLocalDirection Defines the new local direction
  93128. */
  93129. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93130. private _updateDirection;
  93131. /** @hidden */
  93132. updateDistanceFromListener(): void;
  93133. /**
  93134. * Sets a new custom attenuation function for the sound.
  93135. * @param callback Defines the function used for the attenuation
  93136. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93137. */
  93138. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93139. /**
  93140. * Play the sound
  93141. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93142. * @param offset (optional) Start the sound setting it at a specific time
  93143. */
  93144. play(time?: number, offset?: number): void;
  93145. private _onended;
  93146. /**
  93147. * Stop the sound
  93148. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93149. */
  93150. stop(time?: number): void;
  93151. /**
  93152. * Put the sound in pause
  93153. */
  93154. pause(): void;
  93155. /**
  93156. * Sets a dedicated volume for this sounds
  93157. * @param newVolume Define the new volume of the sound
  93158. * @param time Define in how long the sound should be at this value
  93159. */
  93160. setVolume(newVolume: number, time?: number): void;
  93161. /**
  93162. * Set the sound play back rate
  93163. * @param newPlaybackRate Define the playback rate the sound should be played at
  93164. */
  93165. setPlaybackRate(newPlaybackRate: number): void;
  93166. /**
  93167. * Gets the volume of the sound.
  93168. * @returns the volume of the sound
  93169. */
  93170. getVolume(): number;
  93171. /**
  93172. * Attach the sound to a dedicated mesh
  93173. * @param transformNode The transform node to connect the sound with
  93174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93175. */
  93176. attachToMesh(transformNode: TransformNode): void;
  93177. /**
  93178. * Detach the sound from the previously attached mesh
  93179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93180. */
  93181. detachFromMesh(): void;
  93182. private _onRegisterAfterWorldMatrixUpdate;
  93183. /**
  93184. * Clone the current sound in the scene.
  93185. * @returns the new sound clone
  93186. */
  93187. clone(): Nullable<Sound>;
  93188. /**
  93189. * Gets the current underlying audio buffer containing the data
  93190. * @returns the audio buffer
  93191. */
  93192. getAudioBuffer(): Nullable<AudioBuffer>;
  93193. /**
  93194. * Serializes the Sound in a JSON representation
  93195. * @returns the JSON representation of the sound
  93196. */
  93197. serialize(): any;
  93198. /**
  93199. * Parse a JSON representation of a sound to innstantiate in a given scene
  93200. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  93201. * @param scene Define the scene the new parsed sound should be created in
  93202. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  93203. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  93204. * @returns the newly parsed sound
  93205. */
  93206. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  93207. }
  93208. }
  93209. declare module BABYLON {
  93210. /**
  93211. * This defines an action helpful to play a defined sound on a triggered action.
  93212. */
  93213. export class PlaySoundAction extends Action {
  93214. private _sound;
  93215. /**
  93216. * Instantiate the action
  93217. * @param triggerOptions defines the trigger options
  93218. * @param sound defines the sound to play
  93219. * @param condition defines the trigger related conditions
  93220. */
  93221. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93222. /** @hidden */
  93223. _prepare(): void;
  93224. /**
  93225. * Execute the action and play the sound.
  93226. */
  93227. execute(): void;
  93228. /**
  93229. * Serializes the actions and its related information.
  93230. * @param parent defines the object to serialize in
  93231. * @returns the serialized object
  93232. */
  93233. serialize(parent: any): any;
  93234. }
  93235. /**
  93236. * This defines an action helpful to stop a defined sound on a triggered action.
  93237. */
  93238. export class StopSoundAction extends Action {
  93239. private _sound;
  93240. /**
  93241. * Instantiate the action
  93242. * @param triggerOptions defines the trigger options
  93243. * @param sound defines the sound to stop
  93244. * @param condition defines the trigger related conditions
  93245. */
  93246. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93247. /** @hidden */
  93248. _prepare(): void;
  93249. /**
  93250. * Execute the action and stop the sound.
  93251. */
  93252. execute(): void;
  93253. /**
  93254. * Serializes the actions and its related information.
  93255. * @param parent defines the object to serialize in
  93256. * @returns the serialized object
  93257. */
  93258. serialize(parent: any): any;
  93259. }
  93260. }
  93261. declare module BABYLON {
  93262. /**
  93263. * This defines an action responsible to change the value of a property
  93264. * by interpolating between its current value and the newly set one once triggered.
  93265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93266. */
  93267. export class InterpolateValueAction extends Action {
  93268. /**
  93269. * Defines the path of the property where the value should be interpolated
  93270. */
  93271. propertyPath: string;
  93272. /**
  93273. * Defines the target value at the end of the interpolation.
  93274. */
  93275. value: any;
  93276. /**
  93277. * Defines the time it will take for the property to interpolate to the value.
  93278. */
  93279. duration: number;
  93280. /**
  93281. * Defines if the other scene animations should be stopped when the action has been triggered
  93282. */
  93283. stopOtherAnimations?: boolean;
  93284. /**
  93285. * Defines a callback raised once the interpolation animation has been done.
  93286. */
  93287. onInterpolationDone?: () => void;
  93288. /**
  93289. * Observable triggered once the interpolation animation has been done.
  93290. */
  93291. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  93292. private _target;
  93293. private _effectiveTarget;
  93294. private _property;
  93295. /**
  93296. * Instantiate the action
  93297. * @param triggerOptions defines the trigger options
  93298. * @param target defines the object containing the value to interpolate
  93299. * @param propertyPath defines the path to the property in the target object
  93300. * @param value defines the target value at the end of the interpolation
  93301. * @param duration deines the time it will take for the property to interpolate to the value.
  93302. * @param condition defines the trigger related conditions
  93303. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  93304. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  93305. */
  93306. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  93307. /** @hidden */
  93308. _prepare(): void;
  93309. /**
  93310. * Execute the action starts the value interpolation.
  93311. */
  93312. execute(): void;
  93313. /**
  93314. * Serializes the actions and its related information.
  93315. * @param parent defines the object to serialize in
  93316. * @returns the serialized object
  93317. */
  93318. serialize(parent: any): any;
  93319. }
  93320. }
  93321. declare module BABYLON {
  93322. /**
  93323. * Options allowed during the creation of a sound track.
  93324. */
  93325. export interface ISoundTrackOptions {
  93326. /**
  93327. * The volume the sound track should take during creation
  93328. */
  93329. volume?: number;
  93330. /**
  93331. * Define if the sound track is the main sound track of the scene
  93332. */
  93333. mainTrack?: boolean;
  93334. }
  93335. /**
  93336. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  93337. * It will be also used in a future release to apply effects on a specific track.
  93338. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93339. */
  93340. export class SoundTrack {
  93341. /**
  93342. * The unique identifier of the sound track in the scene.
  93343. */
  93344. id: number;
  93345. /**
  93346. * The list of sounds included in the sound track.
  93347. */
  93348. soundCollection: Array<Sound>;
  93349. private _outputAudioNode;
  93350. private _scene;
  93351. private _isMainTrack;
  93352. private _connectedAnalyser;
  93353. private _options;
  93354. private _isInitialized;
  93355. /**
  93356. * Creates a new sound track.
  93357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93358. * @param scene Define the scene the sound track belongs to
  93359. * @param options
  93360. */
  93361. constructor(scene: Scene, options?: ISoundTrackOptions);
  93362. private _initializeSoundTrackAudioGraph;
  93363. /**
  93364. * Release the sound track and its associated resources
  93365. */
  93366. dispose(): void;
  93367. /**
  93368. * Adds a sound to this sound track
  93369. * @param sound define the cound to add
  93370. * @ignoreNaming
  93371. */
  93372. AddSound(sound: Sound): void;
  93373. /**
  93374. * Removes a sound to this sound track
  93375. * @param sound define the cound to remove
  93376. * @ignoreNaming
  93377. */
  93378. RemoveSound(sound: Sound): void;
  93379. /**
  93380. * Set a global volume for the full sound track.
  93381. * @param newVolume Define the new volume of the sound track
  93382. */
  93383. setVolume(newVolume: number): void;
  93384. /**
  93385. * Switch the panning model to HRTF:
  93386. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93388. */
  93389. switchPanningModelToHRTF(): void;
  93390. /**
  93391. * Switch the panning model to Equal Power:
  93392. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93394. */
  93395. switchPanningModelToEqualPower(): void;
  93396. /**
  93397. * Connect the sound track to an audio analyser allowing some amazing
  93398. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93400. * @param analyser The analyser to connect to the engine
  93401. */
  93402. connectToAnalyser(analyser: Analyser): void;
  93403. }
  93404. }
  93405. declare module BABYLON {
  93406. interface AbstractScene {
  93407. /**
  93408. * The list of sounds used in the scene.
  93409. */
  93410. sounds: Nullable<Array<Sound>>;
  93411. }
  93412. interface Scene {
  93413. /**
  93414. * @hidden
  93415. * Backing field
  93416. */
  93417. _mainSoundTrack: SoundTrack;
  93418. /**
  93419. * The main sound track played by the scene.
  93420. * It cotains your primary collection of sounds.
  93421. */
  93422. mainSoundTrack: SoundTrack;
  93423. /**
  93424. * The list of sound tracks added to the scene
  93425. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93426. */
  93427. soundTracks: Nullable<Array<SoundTrack>>;
  93428. /**
  93429. * Gets a sound using a given name
  93430. * @param name defines the name to search for
  93431. * @return the found sound or null if not found at all.
  93432. */
  93433. getSoundByName(name: string): Nullable<Sound>;
  93434. /**
  93435. * Gets or sets if audio support is enabled
  93436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93437. */
  93438. audioEnabled: boolean;
  93439. /**
  93440. * Gets or sets if audio will be output to headphones
  93441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93442. */
  93443. headphone: boolean;
  93444. }
  93445. /**
  93446. * Defines the sound scene component responsible to manage any sounds
  93447. * in a given scene.
  93448. */
  93449. export class AudioSceneComponent implements ISceneSerializableComponent {
  93450. /**
  93451. * The component name helpfull to identify the component in the list of scene components.
  93452. */
  93453. readonly name: string;
  93454. /**
  93455. * The scene the component belongs to.
  93456. */
  93457. scene: Scene;
  93458. private _audioEnabled;
  93459. /**
  93460. * Gets whether audio is enabled or not.
  93461. * Please use related enable/disable method to switch state.
  93462. */
  93463. readonly audioEnabled: boolean;
  93464. private _headphone;
  93465. /**
  93466. * Gets whether audio is outputing to headphone or not.
  93467. * Please use the according Switch methods to change output.
  93468. */
  93469. readonly headphone: boolean;
  93470. /**
  93471. * Creates a new instance of the component for the given scene
  93472. * @param scene Defines the scene to register the component in
  93473. */
  93474. constructor(scene: Scene);
  93475. /**
  93476. * Registers the component in a given scene
  93477. */
  93478. register(): void;
  93479. /**
  93480. * Rebuilds the elements related to this component in case of
  93481. * context lost for instance.
  93482. */
  93483. rebuild(): void;
  93484. /**
  93485. * Serializes the component data to the specified json object
  93486. * @param serializationObject The object to serialize to
  93487. */
  93488. serialize(serializationObject: any): void;
  93489. /**
  93490. * Adds all the element from the container to the scene
  93491. * @param container the container holding the elements
  93492. */
  93493. addFromContainer(container: AbstractScene): void;
  93494. /**
  93495. * Removes all the elements in the container from the scene
  93496. * @param container contains the elements to remove
  93497. * @param dispose if the removed element should be disposed (default: false)
  93498. */
  93499. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  93500. /**
  93501. * Disposes the component and the associated ressources.
  93502. */
  93503. dispose(): void;
  93504. /**
  93505. * Disables audio in the associated scene.
  93506. */
  93507. disableAudio(): void;
  93508. /**
  93509. * Enables audio in the associated scene.
  93510. */
  93511. enableAudio(): void;
  93512. /**
  93513. * Switch audio to headphone output.
  93514. */
  93515. switchAudioModeForHeadphones(): void;
  93516. /**
  93517. * Switch audio to normal speakers.
  93518. */
  93519. switchAudioModeForNormalSpeakers(): void;
  93520. private _afterRender;
  93521. }
  93522. }
  93523. declare module BABYLON {
  93524. /**
  93525. * Wraps one or more Sound objects and selects one with random weight for playback.
  93526. */
  93527. export class WeightedSound {
  93528. /** When true a Sound will be selected and played when the current playing Sound completes. */
  93529. loop: boolean;
  93530. private _coneInnerAngle;
  93531. private _coneOuterAngle;
  93532. private _volume;
  93533. /** A Sound is currently playing. */
  93534. isPlaying: boolean;
  93535. /** A Sound is currently paused. */
  93536. isPaused: boolean;
  93537. private _sounds;
  93538. private _weights;
  93539. private _currentIndex?;
  93540. /**
  93541. * Creates a new WeightedSound from the list of sounds given.
  93542. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  93543. * @param sounds Array of Sounds that will be selected from.
  93544. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  93545. */
  93546. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  93547. /**
  93548. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  93549. */
  93550. /**
  93551. * The size of cone in degress for a directional sound in which there will be no attenuation.
  93552. */
  93553. directionalConeInnerAngle: number;
  93554. /**
  93555. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93556. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93557. */
  93558. /**
  93559. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93560. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93561. */
  93562. directionalConeOuterAngle: number;
  93563. /**
  93564. * Playback volume.
  93565. */
  93566. /**
  93567. * Playback volume.
  93568. */
  93569. volume: number;
  93570. private _onended;
  93571. /**
  93572. * Suspend playback
  93573. */
  93574. pause(): void;
  93575. /**
  93576. * Stop playback
  93577. */
  93578. stop(): void;
  93579. /**
  93580. * Start playback.
  93581. * @param startOffset Position the clip head at a specific time in seconds.
  93582. */
  93583. play(startOffset?: number): void;
  93584. }
  93585. }
  93586. declare module BABYLON {
  93587. /**
  93588. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  93589. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93590. */
  93591. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  93592. /**
  93593. * Gets the name of the behavior.
  93594. */
  93595. readonly name: string;
  93596. /**
  93597. * The easing function used by animations
  93598. */
  93599. static EasingFunction: BackEase;
  93600. /**
  93601. * The easing mode used by animations
  93602. */
  93603. static EasingMode: number;
  93604. /**
  93605. * The duration of the animation, in milliseconds
  93606. */
  93607. transitionDuration: number;
  93608. /**
  93609. * Length of the distance animated by the transition when lower radius is reached
  93610. */
  93611. lowerRadiusTransitionRange: number;
  93612. /**
  93613. * Length of the distance animated by the transition when upper radius is reached
  93614. */
  93615. upperRadiusTransitionRange: number;
  93616. private _autoTransitionRange;
  93617. /**
  93618. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93619. */
  93620. /**
  93621. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93622. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  93623. */
  93624. autoTransitionRange: boolean;
  93625. private _attachedCamera;
  93626. private _onAfterCheckInputsObserver;
  93627. private _onMeshTargetChangedObserver;
  93628. /**
  93629. * Initializes the behavior.
  93630. */
  93631. init(): void;
  93632. /**
  93633. * Attaches the behavior to its arc rotate camera.
  93634. * @param camera Defines the camera to attach the behavior to
  93635. */
  93636. attach(camera: ArcRotateCamera): void;
  93637. /**
  93638. * Detaches the behavior from its current arc rotate camera.
  93639. */
  93640. detach(): void;
  93641. private _radiusIsAnimating;
  93642. private _radiusBounceTransition;
  93643. private _animatables;
  93644. private _cachedWheelPrecision;
  93645. /**
  93646. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  93647. * @param radiusLimit The limit to check against.
  93648. * @return Bool to indicate if at limit.
  93649. */
  93650. private _isRadiusAtLimit;
  93651. /**
  93652. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  93653. * @param radiusDelta The delta by which to animate to. Can be negative.
  93654. */
  93655. private _applyBoundRadiusAnimation;
  93656. /**
  93657. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  93658. */
  93659. protected _clearAnimationLocks(): void;
  93660. /**
  93661. * Stops and removes all animations that have been applied to the camera
  93662. */
  93663. stopAllAnimations(): void;
  93664. }
  93665. }
  93666. declare module BABYLON {
  93667. /**
  93668. * 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.
  93669. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93670. */
  93671. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  93672. /**
  93673. * Gets the name of the behavior.
  93674. */
  93675. readonly name: string;
  93676. private _mode;
  93677. private _radiusScale;
  93678. private _positionScale;
  93679. private _defaultElevation;
  93680. private _elevationReturnTime;
  93681. private _elevationReturnWaitTime;
  93682. private _zoomStopsAnimation;
  93683. private _framingTime;
  93684. /**
  93685. * The easing function used by animations
  93686. */
  93687. static EasingFunction: ExponentialEase;
  93688. /**
  93689. * The easing mode used by animations
  93690. */
  93691. static EasingMode: number;
  93692. /**
  93693. * Sets the current mode used by the behavior
  93694. */
  93695. /**
  93696. * Gets current mode used by the behavior.
  93697. */
  93698. mode: number;
  93699. /**
  93700. * Sets the scale applied to the radius (1 by default)
  93701. */
  93702. /**
  93703. * Gets the scale applied to the radius
  93704. */
  93705. radiusScale: number;
  93706. /**
  93707. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93708. */
  93709. /**
  93710. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93711. */
  93712. positionScale: number;
  93713. /**
  93714. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93715. * behaviour is triggered, in radians.
  93716. */
  93717. /**
  93718. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93719. * behaviour is triggered, in radians.
  93720. */
  93721. defaultElevation: number;
  93722. /**
  93723. * Sets the time (in milliseconds) taken to return to the default beta position.
  93724. * Negative value indicates camera should not return to default.
  93725. */
  93726. /**
  93727. * Gets the time (in milliseconds) taken to return to the default beta position.
  93728. * Negative value indicates camera should not return to default.
  93729. */
  93730. elevationReturnTime: number;
  93731. /**
  93732. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93733. */
  93734. /**
  93735. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93736. */
  93737. elevationReturnWaitTime: number;
  93738. /**
  93739. * Sets the flag that indicates if user zooming should stop animation.
  93740. */
  93741. /**
  93742. * Gets the flag that indicates if user zooming should stop animation.
  93743. */
  93744. zoomStopsAnimation: boolean;
  93745. /**
  93746. * Sets the transition time when framing the mesh, in milliseconds
  93747. */
  93748. /**
  93749. * Gets the transition time when framing the mesh, in milliseconds
  93750. */
  93751. framingTime: number;
  93752. /**
  93753. * Define if the behavior should automatically change the configured
  93754. * camera limits and sensibilities.
  93755. */
  93756. autoCorrectCameraLimitsAndSensibility: boolean;
  93757. private _onPrePointerObservableObserver;
  93758. private _onAfterCheckInputsObserver;
  93759. private _onMeshTargetChangedObserver;
  93760. private _attachedCamera;
  93761. private _isPointerDown;
  93762. private _lastInteractionTime;
  93763. /**
  93764. * Initializes the behavior.
  93765. */
  93766. init(): void;
  93767. /**
  93768. * Attaches the behavior to its arc rotate camera.
  93769. * @param camera Defines the camera to attach the behavior to
  93770. */
  93771. attach(camera: ArcRotateCamera): void;
  93772. /**
  93773. * Detaches the behavior from its current arc rotate camera.
  93774. */
  93775. detach(): void;
  93776. private _animatables;
  93777. private _betaIsAnimating;
  93778. private _betaTransition;
  93779. private _radiusTransition;
  93780. private _vectorTransition;
  93781. /**
  93782. * Targets the given mesh and updates zoom level accordingly.
  93783. * @param mesh The mesh to target.
  93784. * @param radius Optional. If a cached radius position already exists, overrides default.
  93785. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93786. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93787. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93788. */
  93789. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93790. /**
  93791. * Targets the given mesh with its children and updates zoom level accordingly.
  93792. * @param mesh The mesh to target.
  93793. * @param radius Optional. If a cached radius position already exists, overrides default.
  93794. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93795. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93796. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93797. */
  93798. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93799. /**
  93800. * Targets the given meshes with their children and updates zoom level accordingly.
  93801. * @param meshes The mesh to target.
  93802. * @param radius Optional. If a cached radius position already exists, overrides default.
  93803. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93804. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93805. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93806. */
  93807. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93808. /**
  93809. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  93810. * @param minimumWorld Determines the smaller position of the bounding box extend
  93811. * @param maximumWorld Determines the bigger position of the bounding box extend
  93812. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93813. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93814. */
  93815. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93816. /**
  93817. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  93818. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  93819. * frustum width.
  93820. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  93821. * to fully enclose the mesh in the viewing frustum.
  93822. */
  93823. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  93824. /**
  93825. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  93826. * is automatically returned to its default position (expected to be above ground plane).
  93827. */
  93828. private _maintainCameraAboveGround;
  93829. /**
  93830. * Returns the frustum slope based on the canvas ratio and camera FOV
  93831. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  93832. */
  93833. private _getFrustumSlope;
  93834. /**
  93835. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  93836. */
  93837. private _clearAnimationLocks;
  93838. /**
  93839. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93840. */
  93841. private _applyUserInteraction;
  93842. /**
  93843. * Stops and removes all animations that have been applied to the camera
  93844. */
  93845. stopAllAnimations(): void;
  93846. /**
  93847. * Gets a value indicating if the user is moving the camera
  93848. */
  93849. readonly isUserIsMoving: boolean;
  93850. /**
  93851. * The camera can move all the way towards the mesh.
  93852. */
  93853. static IgnoreBoundsSizeMode: number;
  93854. /**
  93855. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  93856. */
  93857. static FitFrustumSidesMode: number;
  93858. }
  93859. }
  93860. declare module BABYLON {
  93861. /**
  93862. * Base class for Camera Pointer Inputs.
  93863. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  93864. * for example usage.
  93865. */
  93866. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  93867. /**
  93868. * Defines the camera the input is attached to.
  93869. */
  93870. abstract camera: Camera;
  93871. /**
  93872. * Whether keyboard modifier keys are pressed at time of last mouse event.
  93873. */
  93874. protected _altKey: boolean;
  93875. protected _ctrlKey: boolean;
  93876. protected _metaKey: boolean;
  93877. protected _shiftKey: boolean;
  93878. /**
  93879. * Which mouse buttons were pressed at time of last mouse event.
  93880. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  93881. */
  93882. protected _buttonsPressed: number;
  93883. /**
  93884. * Defines the buttons associated with the input to handle camera move.
  93885. */
  93886. buttons: number[];
  93887. /**
  93888. * Attach the input controls to a specific dom element to get the input from.
  93889. * @param element Defines the element the controls should be listened from
  93890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93891. */
  93892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93893. /**
  93894. * Detach the current controls from the specified dom element.
  93895. * @param element Defines the element to stop listening the inputs from
  93896. */
  93897. detachControl(element: Nullable<HTMLElement>): void;
  93898. /**
  93899. * Gets the class name of the current input.
  93900. * @returns the class name
  93901. */
  93902. getClassName(): string;
  93903. /**
  93904. * Get the friendly name associated with the input class.
  93905. * @returns the input friendly name
  93906. */
  93907. getSimpleName(): string;
  93908. /**
  93909. * Called on pointer POINTERDOUBLETAP event.
  93910. * Override this method to provide functionality on POINTERDOUBLETAP event.
  93911. */
  93912. protected onDoubleTap(type: string): void;
  93913. /**
  93914. * Called on pointer POINTERMOVE event if only a single touch is active.
  93915. * Override this method to provide functionality.
  93916. */
  93917. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93918. /**
  93919. * Called on pointer POINTERMOVE event if multiple touches are active.
  93920. * Override this method to provide functionality.
  93921. */
  93922. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93923. /**
  93924. * Called on JS contextmenu event.
  93925. * Override this method to provide functionality.
  93926. */
  93927. protected onContextMenu(evt: PointerEvent): void;
  93928. /**
  93929. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  93930. * press.
  93931. * Override this method to provide functionality.
  93932. */
  93933. protected onButtonDown(evt: PointerEvent): void;
  93934. /**
  93935. * Called each time a new POINTERUP event occurs. Ie, for each button
  93936. * release.
  93937. * Override this method to provide functionality.
  93938. */
  93939. protected onButtonUp(evt: PointerEvent): void;
  93940. /**
  93941. * Called when window becomes inactive.
  93942. * Override this method to provide functionality.
  93943. */
  93944. protected onLostFocus(): void;
  93945. private _pointerInput;
  93946. private _observer;
  93947. private _onLostFocus;
  93948. private pointA;
  93949. private pointB;
  93950. }
  93951. }
  93952. declare module BABYLON {
  93953. /**
  93954. * Manage the pointers inputs to control an arc rotate camera.
  93955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93956. */
  93957. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  93958. /**
  93959. * Defines the camera the input is attached to.
  93960. */
  93961. camera: ArcRotateCamera;
  93962. /**
  93963. * Gets the class name of the current input.
  93964. * @returns the class name
  93965. */
  93966. getClassName(): string;
  93967. /**
  93968. * Defines the buttons associated with the input to handle camera move.
  93969. */
  93970. buttons: number[];
  93971. /**
  93972. * Defines the pointer angular sensibility along the X axis or how fast is
  93973. * the camera rotating.
  93974. */
  93975. angularSensibilityX: number;
  93976. /**
  93977. * Defines the pointer angular sensibility along the Y axis or how fast is
  93978. * the camera rotating.
  93979. */
  93980. angularSensibilityY: number;
  93981. /**
  93982. * Defines the pointer pinch precision or how fast is the camera zooming.
  93983. */
  93984. pinchPrecision: number;
  93985. /**
  93986. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93987. * from 0.
  93988. * It defines the percentage of current camera.radius to use as delta when
  93989. * pinch zoom is used.
  93990. */
  93991. pinchDeltaPercentage: number;
  93992. /**
  93993. * Defines the pointer panning sensibility or how fast is the camera moving.
  93994. */
  93995. panningSensibility: number;
  93996. /**
  93997. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  93998. */
  93999. multiTouchPanning: boolean;
  94000. /**
  94001. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94002. * zoom (pinch) through multitouch.
  94003. */
  94004. multiTouchPanAndZoom: boolean;
  94005. /**
  94006. * Revers pinch action direction.
  94007. */
  94008. pinchInwards: boolean;
  94009. private _isPanClick;
  94010. private _twoFingerActivityCount;
  94011. private _isPinching;
  94012. /**
  94013. * Called on pointer POINTERMOVE event if only a single touch is active.
  94014. */
  94015. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94016. /**
  94017. * Called on pointer POINTERDOUBLETAP event.
  94018. */
  94019. protected onDoubleTap(type: string): void;
  94020. /**
  94021. * Called on pointer POINTERMOVE event if multiple touches are active.
  94022. */
  94023. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94024. /**
  94025. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94026. * press.
  94027. */
  94028. protected onButtonDown(evt: PointerEvent): void;
  94029. /**
  94030. * Called each time a new POINTERUP event occurs. Ie, for each button
  94031. * release.
  94032. */
  94033. protected onButtonUp(evt: PointerEvent): void;
  94034. /**
  94035. * Called when window becomes inactive.
  94036. */
  94037. protected onLostFocus(): void;
  94038. }
  94039. }
  94040. declare module BABYLON {
  94041. /**
  94042. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94043. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94044. */
  94045. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94046. /**
  94047. * Defines the camera the input is attached to.
  94048. */
  94049. camera: ArcRotateCamera;
  94050. /**
  94051. * Defines the list of key codes associated with the up action (increase alpha)
  94052. */
  94053. keysUp: number[];
  94054. /**
  94055. * Defines the list of key codes associated with the down action (decrease alpha)
  94056. */
  94057. keysDown: number[];
  94058. /**
  94059. * Defines the list of key codes associated with the left action (increase beta)
  94060. */
  94061. keysLeft: number[];
  94062. /**
  94063. * Defines the list of key codes associated with the right action (decrease beta)
  94064. */
  94065. keysRight: number[];
  94066. /**
  94067. * Defines the list of key codes associated with the reset action.
  94068. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94069. */
  94070. keysReset: number[];
  94071. /**
  94072. * Defines the panning sensibility of the inputs.
  94073. * (How fast is the camera paning)
  94074. */
  94075. panningSensibility: number;
  94076. /**
  94077. * Defines the zooming sensibility of the inputs.
  94078. * (How fast is the camera zooming)
  94079. */
  94080. zoomingSensibility: number;
  94081. /**
  94082. * Defines wether maintaining the alt key down switch the movement mode from
  94083. * orientation to zoom.
  94084. */
  94085. useAltToZoom: boolean;
  94086. /**
  94087. * Rotation speed of the camera
  94088. */
  94089. angularSpeed: number;
  94090. private _keys;
  94091. private _ctrlPressed;
  94092. private _altPressed;
  94093. private _onCanvasBlurObserver;
  94094. private _onKeyboardObserver;
  94095. private _engine;
  94096. private _scene;
  94097. /**
  94098. * Attach the input controls to a specific dom element to get the input from.
  94099. * @param element Defines the element the controls should be listened from
  94100. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94101. */
  94102. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94103. /**
  94104. * Detach the current controls from the specified dom element.
  94105. * @param element Defines the element to stop listening the inputs from
  94106. */
  94107. detachControl(element: Nullable<HTMLElement>): void;
  94108. /**
  94109. * Update the current camera state depending on the inputs that have been used this frame.
  94110. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94111. */
  94112. checkInputs(): void;
  94113. /**
  94114. * Gets the class name of the current intput.
  94115. * @returns the class name
  94116. */
  94117. getClassName(): string;
  94118. /**
  94119. * Get the friendly name associated with the input class.
  94120. * @returns the input friendly name
  94121. */
  94122. getSimpleName(): string;
  94123. }
  94124. }
  94125. declare module BABYLON {
  94126. /**
  94127. * Manage the mouse wheel inputs to control an arc rotate camera.
  94128. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94129. */
  94130. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94131. /**
  94132. * Defines the camera the input is attached to.
  94133. */
  94134. camera: ArcRotateCamera;
  94135. /**
  94136. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94137. */
  94138. wheelPrecision: number;
  94139. /**
  94140. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94141. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94142. */
  94143. wheelDeltaPercentage: number;
  94144. private _wheel;
  94145. private _observer;
  94146. /**
  94147. * Attach the input controls to a specific dom element to get the input from.
  94148. * @param element Defines the element the controls should be listened from
  94149. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94150. */
  94151. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94152. /**
  94153. * Detach the current controls from the specified dom element.
  94154. * @param element Defines the element to stop listening the inputs from
  94155. */
  94156. detachControl(element: Nullable<HTMLElement>): void;
  94157. /**
  94158. * Gets the class name of the current intput.
  94159. * @returns the class name
  94160. */
  94161. getClassName(): string;
  94162. /**
  94163. * Get the friendly name associated with the input class.
  94164. * @returns the input friendly name
  94165. */
  94166. getSimpleName(): string;
  94167. }
  94168. }
  94169. declare module BABYLON {
  94170. /**
  94171. * Default Inputs manager for the ArcRotateCamera.
  94172. * It groups all the default supported inputs for ease of use.
  94173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94174. */
  94175. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  94176. /**
  94177. * Instantiates a new ArcRotateCameraInputsManager.
  94178. * @param camera Defines the camera the inputs belong to
  94179. */
  94180. constructor(camera: ArcRotateCamera);
  94181. /**
  94182. * Add mouse wheel input support to the input manager.
  94183. * @returns the current input manager
  94184. */
  94185. addMouseWheel(): ArcRotateCameraInputsManager;
  94186. /**
  94187. * Add pointers input support to the input manager.
  94188. * @returns the current input manager
  94189. */
  94190. addPointers(): ArcRotateCameraInputsManager;
  94191. /**
  94192. * Add keyboard input support to the input manager.
  94193. * @returns the current input manager
  94194. */
  94195. addKeyboard(): ArcRotateCameraInputsManager;
  94196. }
  94197. }
  94198. declare module BABYLON {
  94199. /**
  94200. * This represents an orbital type of camera.
  94201. *
  94202. * 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.
  94203. * 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.
  94204. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  94205. */
  94206. export class ArcRotateCamera extends TargetCamera {
  94207. /**
  94208. * Defines the rotation angle of the camera along the longitudinal axis.
  94209. */
  94210. alpha: number;
  94211. /**
  94212. * Defines the rotation angle of the camera along the latitudinal axis.
  94213. */
  94214. beta: number;
  94215. /**
  94216. * Defines the radius of the camera from it s target point.
  94217. */
  94218. radius: number;
  94219. protected _target: Vector3;
  94220. protected _targetHost: Nullable<AbstractMesh>;
  94221. /**
  94222. * Defines the target point of the camera.
  94223. * The camera looks towards it form the radius distance.
  94224. */
  94225. target: Vector3;
  94226. /**
  94227. * Define the current local position of the camera in the scene
  94228. */
  94229. position: Vector3;
  94230. protected _upVector: Vector3;
  94231. protected _upToYMatrix: Matrix;
  94232. protected _YToUpMatrix: Matrix;
  94233. /**
  94234. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  94235. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  94236. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  94237. */
  94238. upVector: Vector3;
  94239. /**
  94240. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  94241. */
  94242. setMatUp(): void;
  94243. /**
  94244. * Current inertia value on the longitudinal axis.
  94245. * The bigger this number the longer it will take for the camera to stop.
  94246. */
  94247. inertialAlphaOffset: number;
  94248. /**
  94249. * Current inertia value on the latitudinal axis.
  94250. * The bigger this number the longer it will take for the camera to stop.
  94251. */
  94252. inertialBetaOffset: number;
  94253. /**
  94254. * Current inertia value on the radius axis.
  94255. * The bigger this number the longer it will take for the camera to stop.
  94256. */
  94257. inertialRadiusOffset: number;
  94258. /**
  94259. * Minimum allowed angle on the longitudinal axis.
  94260. * This can help limiting how the Camera is able to move in the scene.
  94261. */
  94262. lowerAlphaLimit: Nullable<number>;
  94263. /**
  94264. * Maximum allowed angle on the longitudinal axis.
  94265. * This can help limiting how the Camera is able to move in the scene.
  94266. */
  94267. upperAlphaLimit: Nullable<number>;
  94268. /**
  94269. * Minimum allowed angle on the latitudinal axis.
  94270. * This can help limiting how the Camera is able to move in the scene.
  94271. */
  94272. lowerBetaLimit: number;
  94273. /**
  94274. * Maximum allowed angle on the latitudinal axis.
  94275. * This can help limiting how the Camera is able to move in the scene.
  94276. */
  94277. upperBetaLimit: number;
  94278. /**
  94279. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  94280. * This can help limiting how the Camera is able to move in the scene.
  94281. */
  94282. lowerRadiusLimit: Nullable<number>;
  94283. /**
  94284. * Maximum allowed distance of the camera to the target (The camera can not get further).
  94285. * This can help limiting how the Camera is able to move in the scene.
  94286. */
  94287. upperRadiusLimit: Nullable<number>;
  94288. /**
  94289. * Defines the current inertia value used during panning of the camera along the X axis.
  94290. */
  94291. inertialPanningX: number;
  94292. /**
  94293. * Defines the current inertia value used during panning of the camera along the Y axis.
  94294. */
  94295. inertialPanningY: number;
  94296. /**
  94297. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  94298. * Basically if your fingers moves away from more than this distance you will be considered
  94299. * in pinch mode.
  94300. */
  94301. pinchToPanMaxDistance: number;
  94302. /**
  94303. * Defines the maximum distance the camera can pan.
  94304. * This could help keeping the cammera always in your scene.
  94305. */
  94306. panningDistanceLimit: Nullable<number>;
  94307. /**
  94308. * Defines the target of the camera before paning.
  94309. */
  94310. panningOriginTarget: Vector3;
  94311. /**
  94312. * Defines the value of the inertia used during panning.
  94313. * 0 would mean stop inertia and one would mean no decelleration at all.
  94314. */
  94315. panningInertia: number;
  94316. /**
  94317. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  94318. */
  94319. angularSensibilityX: number;
  94320. /**
  94321. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  94322. */
  94323. angularSensibilityY: number;
  94324. /**
  94325. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  94326. */
  94327. pinchPrecision: number;
  94328. /**
  94329. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  94330. * It will be used instead of pinchDeltaPrecision if different from 0.
  94331. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94332. */
  94333. pinchDeltaPercentage: number;
  94334. /**
  94335. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  94336. */
  94337. panningSensibility: number;
  94338. /**
  94339. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  94340. */
  94341. keysUp: number[];
  94342. /**
  94343. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  94344. */
  94345. keysDown: number[];
  94346. /**
  94347. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  94348. */
  94349. keysLeft: number[];
  94350. /**
  94351. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  94352. */
  94353. keysRight: number[];
  94354. /**
  94355. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94356. */
  94357. wheelPrecision: number;
  94358. /**
  94359. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  94360. * It will be used instead of pinchDeltaPrecision if different from 0.
  94361. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94362. */
  94363. wheelDeltaPercentage: number;
  94364. /**
  94365. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  94366. */
  94367. zoomOnFactor: number;
  94368. /**
  94369. * Defines a screen offset for the camera position.
  94370. */
  94371. targetScreenOffset: Vector2;
  94372. /**
  94373. * Allows the camera to be completely reversed.
  94374. * If false the camera can not arrive upside down.
  94375. */
  94376. allowUpsideDown: boolean;
  94377. /**
  94378. * Define if double tap/click is used to restore the previously saved state of the camera.
  94379. */
  94380. useInputToRestoreState: boolean;
  94381. /** @hidden */
  94382. _viewMatrix: Matrix;
  94383. /** @hidden */
  94384. _useCtrlForPanning: boolean;
  94385. /** @hidden */
  94386. _panningMouseButton: number;
  94387. /**
  94388. * Defines the input associated to the camera.
  94389. */
  94390. inputs: ArcRotateCameraInputsManager;
  94391. /** @hidden */
  94392. _reset: () => void;
  94393. /**
  94394. * Defines the allowed panning axis.
  94395. */
  94396. panningAxis: Vector3;
  94397. protected _localDirection: Vector3;
  94398. protected _transformedDirection: Vector3;
  94399. private _bouncingBehavior;
  94400. /**
  94401. * Gets the bouncing behavior of the camera if it has been enabled.
  94402. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94403. */
  94404. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  94405. /**
  94406. * Defines if the bouncing behavior of the camera is enabled on the camera.
  94407. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94408. */
  94409. useBouncingBehavior: boolean;
  94410. private _framingBehavior;
  94411. /**
  94412. * Gets the framing behavior of the camera if it has been enabled.
  94413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94414. */
  94415. readonly framingBehavior: Nullable<FramingBehavior>;
  94416. /**
  94417. * Defines if the framing behavior of the camera is enabled on the camera.
  94418. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94419. */
  94420. useFramingBehavior: boolean;
  94421. private _autoRotationBehavior;
  94422. /**
  94423. * Gets the auto rotation behavior of the camera if it has been enabled.
  94424. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94425. */
  94426. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  94427. /**
  94428. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  94429. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94430. */
  94431. useAutoRotationBehavior: boolean;
  94432. /**
  94433. * Observable triggered when the mesh target has been changed on the camera.
  94434. */
  94435. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  94436. /**
  94437. * Event raised when the camera is colliding with a mesh.
  94438. */
  94439. onCollide: (collidedMesh: AbstractMesh) => void;
  94440. /**
  94441. * Defines whether the camera should check collision with the objects oh the scene.
  94442. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  94443. */
  94444. checkCollisions: boolean;
  94445. /**
  94446. * Defines the collision radius of the camera.
  94447. * This simulates a sphere around the camera.
  94448. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94449. */
  94450. collisionRadius: Vector3;
  94451. protected _collider: Collider;
  94452. protected _previousPosition: Vector3;
  94453. protected _collisionVelocity: Vector3;
  94454. protected _newPosition: Vector3;
  94455. protected _previousAlpha: number;
  94456. protected _previousBeta: number;
  94457. protected _previousRadius: number;
  94458. protected _collisionTriggered: boolean;
  94459. protected _targetBoundingCenter: Nullable<Vector3>;
  94460. private _computationVector;
  94461. /**
  94462. * Instantiates a new ArcRotateCamera in a given scene
  94463. * @param name Defines the name of the camera
  94464. * @param alpha Defines the camera rotation along the logitudinal axis
  94465. * @param beta Defines the camera rotation along the latitudinal axis
  94466. * @param radius Defines the camera distance from its target
  94467. * @param target Defines the camera target
  94468. * @param scene Defines the scene the camera belongs to
  94469. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94470. */
  94471. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94472. /** @hidden */
  94473. _initCache(): void;
  94474. /** @hidden */
  94475. _updateCache(ignoreParentClass?: boolean): void;
  94476. protected _getTargetPosition(): Vector3;
  94477. private _storedAlpha;
  94478. private _storedBeta;
  94479. private _storedRadius;
  94480. private _storedTarget;
  94481. /**
  94482. * Stores the current state of the camera (alpha, beta, radius and target)
  94483. * @returns the camera itself
  94484. */
  94485. storeState(): Camera;
  94486. /**
  94487. * @hidden
  94488. * Restored camera state. You must call storeState() first
  94489. */
  94490. _restoreStateValues(): boolean;
  94491. /** @hidden */
  94492. _isSynchronizedViewMatrix(): boolean;
  94493. /**
  94494. * Attached controls to the current camera.
  94495. * @param element Defines the element the controls should be listened from
  94496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94497. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  94498. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  94499. */
  94500. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  94501. /**
  94502. * Detach the current controls from the camera.
  94503. * The camera will stop reacting to inputs.
  94504. * @param element Defines the element to stop listening the inputs from
  94505. */
  94506. detachControl(element: HTMLElement): void;
  94507. /** @hidden */
  94508. _checkInputs(): void;
  94509. protected _checkLimits(): void;
  94510. /**
  94511. * Rebuilds angles (alpha, beta) and radius from the give position and target
  94512. */
  94513. rebuildAnglesAndRadius(): void;
  94514. /**
  94515. * Use a position to define the current camera related information like aplha, beta and radius
  94516. * @param position Defines the position to set the camera at
  94517. */
  94518. setPosition(position: Vector3): void;
  94519. /**
  94520. * Defines the target the camera should look at.
  94521. * This will automatically adapt alpha beta and radius to fit within the new target.
  94522. * @param target Defines the new target as a Vector or a mesh
  94523. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  94524. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  94525. */
  94526. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  94527. /** @hidden */
  94528. _getViewMatrix(): Matrix;
  94529. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  94530. /**
  94531. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  94532. * @param meshes Defines the mesh to zoom on
  94533. * @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)
  94534. */
  94535. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  94536. /**
  94537. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  94538. * The target will be changed but the radius
  94539. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  94540. * @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)
  94541. */
  94542. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  94543. min: Vector3;
  94544. max: Vector3;
  94545. distance: number;
  94546. }, doNotUpdateMaxZ?: boolean): void;
  94547. /**
  94548. * @override
  94549. * Override Camera.createRigCamera
  94550. */
  94551. createRigCamera(name: string, cameraIndex: number): Camera;
  94552. /**
  94553. * @hidden
  94554. * @override
  94555. * Override Camera._updateRigCameras
  94556. */
  94557. _updateRigCameras(): void;
  94558. /**
  94559. * Destroy the camera and release the current resources hold by it.
  94560. */
  94561. dispose(): void;
  94562. /**
  94563. * Gets the current object class name.
  94564. * @return the class name
  94565. */
  94566. getClassName(): string;
  94567. }
  94568. }
  94569. declare module BABYLON {
  94570. /**
  94571. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  94572. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94573. */
  94574. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  94575. /**
  94576. * Gets the name of the behavior.
  94577. */
  94578. readonly name: string;
  94579. private _zoomStopsAnimation;
  94580. private _idleRotationSpeed;
  94581. private _idleRotationWaitTime;
  94582. private _idleRotationSpinupTime;
  94583. /**
  94584. * Sets the flag that indicates if user zooming should stop animation.
  94585. */
  94586. /**
  94587. * Gets the flag that indicates if user zooming should stop animation.
  94588. */
  94589. zoomStopsAnimation: boolean;
  94590. /**
  94591. * Sets the default speed at which the camera rotates around the model.
  94592. */
  94593. /**
  94594. * Gets the default speed at which the camera rotates around the model.
  94595. */
  94596. idleRotationSpeed: number;
  94597. /**
  94598. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  94599. */
  94600. /**
  94601. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  94602. */
  94603. idleRotationWaitTime: number;
  94604. /**
  94605. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94606. */
  94607. /**
  94608. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94609. */
  94610. idleRotationSpinupTime: number;
  94611. /**
  94612. * Gets a value indicating if the camera is currently rotating because of this behavior
  94613. */
  94614. readonly rotationInProgress: boolean;
  94615. private _onPrePointerObservableObserver;
  94616. private _onAfterCheckInputsObserver;
  94617. private _attachedCamera;
  94618. private _isPointerDown;
  94619. private _lastFrameTime;
  94620. private _lastInteractionTime;
  94621. private _cameraRotationSpeed;
  94622. /**
  94623. * Initializes the behavior.
  94624. */
  94625. init(): void;
  94626. /**
  94627. * Attaches the behavior to its arc rotate camera.
  94628. * @param camera Defines the camera to attach the behavior to
  94629. */
  94630. attach(camera: ArcRotateCamera): void;
  94631. /**
  94632. * Detaches the behavior from its current arc rotate camera.
  94633. */
  94634. detach(): void;
  94635. /**
  94636. * Returns true if user is scrolling.
  94637. * @return true if user is scrolling.
  94638. */
  94639. private _userIsZooming;
  94640. private _lastFrameRadius;
  94641. private _shouldAnimationStopForInteraction;
  94642. /**
  94643. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94644. */
  94645. private _applyUserInteraction;
  94646. private _userIsMoving;
  94647. }
  94648. }
  94649. declare module BABYLON {
  94650. /**
  94651. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  94652. */
  94653. export class AttachToBoxBehavior implements Behavior<Mesh> {
  94654. private ui;
  94655. /**
  94656. * The name of the behavior
  94657. */
  94658. name: string;
  94659. /**
  94660. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  94661. */
  94662. distanceAwayFromFace: number;
  94663. /**
  94664. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  94665. */
  94666. distanceAwayFromBottomOfFace: number;
  94667. private _faceVectors;
  94668. private _target;
  94669. private _scene;
  94670. private _onRenderObserver;
  94671. private _tmpMatrix;
  94672. private _tmpVector;
  94673. /**
  94674. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  94675. * @param ui The transform node that should be attched to the mesh
  94676. */
  94677. constructor(ui: TransformNode);
  94678. /**
  94679. * Initializes the behavior
  94680. */
  94681. init(): void;
  94682. private _closestFace;
  94683. private _zeroVector;
  94684. private _lookAtTmpMatrix;
  94685. private _lookAtToRef;
  94686. /**
  94687. * Attaches the AttachToBoxBehavior to the passed in mesh
  94688. * @param target The mesh that the specified node will be attached to
  94689. */
  94690. attach(target: Mesh): void;
  94691. /**
  94692. * Detaches the behavior from the mesh
  94693. */
  94694. detach(): void;
  94695. }
  94696. }
  94697. declare module BABYLON {
  94698. /**
  94699. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  94700. */
  94701. export class FadeInOutBehavior implements Behavior<Mesh> {
  94702. /**
  94703. * Time in milliseconds to delay before fading in (Default: 0)
  94704. */
  94705. delay: number;
  94706. /**
  94707. * Time in milliseconds for the mesh to fade in (Default: 300)
  94708. */
  94709. fadeInTime: number;
  94710. private _millisecondsPerFrame;
  94711. private _hovered;
  94712. private _hoverValue;
  94713. private _ownerNode;
  94714. /**
  94715. * Instatiates the FadeInOutBehavior
  94716. */
  94717. constructor();
  94718. /**
  94719. * The name of the behavior
  94720. */
  94721. readonly name: string;
  94722. /**
  94723. * Initializes the behavior
  94724. */
  94725. init(): void;
  94726. /**
  94727. * Attaches the fade behavior on the passed in mesh
  94728. * @param ownerNode The mesh that will be faded in/out once attached
  94729. */
  94730. attach(ownerNode: Mesh): void;
  94731. /**
  94732. * Detaches the behavior from the mesh
  94733. */
  94734. detach(): void;
  94735. /**
  94736. * Triggers the mesh to begin fading in or out
  94737. * @param value if the object should fade in or out (true to fade in)
  94738. */
  94739. fadeIn(value: boolean): void;
  94740. private _update;
  94741. private _setAllVisibility;
  94742. }
  94743. }
  94744. declare module BABYLON {
  94745. /**
  94746. * Class containing a set of static utilities functions for managing Pivots
  94747. * @hidden
  94748. */
  94749. export class PivotTools {
  94750. private static _PivotCached;
  94751. private static _OldPivotPoint;
  94752. private static _PivotTranslation;
  94753. private static _PivotTmpVector;
  94754. /** @hidden */
  94755. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  94756. /** @hidden */
  94757. static _RestorePivotPoint(mesh: AbstractMesh): void;
  94758. }
  94759. }
  94760. declare module BABYLON {
  94761. /**
  94762. * Class containing static functions to help procedurally build meshes
  94763. */
  94764. export class PlaneBuilder {
  94765. /**
  94766. * Creates a plane mesh
  94767. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  94768. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  94769. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  94770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94773. * @param name defines the name of the mesh
  94774. * @param options defines the options used to create the mesh
  94775. * @param scene defines the hosting scene
  94776. * @returns the plane mesh
  94777. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  94778. */
  94779. static CreatePlane(name: string, options: {
  94780. size?: number;
  94781. width?: number;
  94782. height?: number;
  94783. sideOrientation?: number;
  94784. frontUVs?: Vector4;
  94785. backUVs?: Vector4;
  94786. updatable?: boolean;
  94787. sourcePlane?: Plane;
  94788. }, scene?: Nullable<Scene>): Mesh;
  94789. }
  94790. }
  94791. declare module BABYLON {
  94792. /**
  94793. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  94794. */
  94795. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  94796. private static _AnyMouseID;
  94797. private _attachedNode;
  94798. private _dragPlane;
  94799. private _scene;
  94800. private _pointerObserver;
  94801. private _beforeRenderObserver;
  94802. private static _planeScene;
  94803. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  94804. /**
  94805. * 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)
  94806. */
  94807. maxDragAngle: number;
  94808. /**
  94809. * @hidden
  94810. */
  94811. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  94812. /**
  94813. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94814. */
  94815. currentDraggingPointerID: number;
  94816. /**
  94817. * The last position where the pointer hit the drag plane in world space
  94818. */
  94819. lastDragPosition: Vector3;
  94820. /**
  94821. * If the behavior is currently in a dragging state
  94822. */
  94823. dragging: boolean;
  94824. /**
  94825. * 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)
  94826. */
  94827. dragDeltaRatio: number;
  94828. /**
  94829. * If the drag plane orientation should be updated during the dragging (Default: true)
  94830. */
  94831. updateDragPlane: boolean;
  94832. private _debugMode;
  94833. private _moving;
  94834. /**
  94835. * Fires each time the attached mesh is dragged with the pointer
  94836. * * delta between last drag position and current drag position in world space
  94837. * * dragDistance along the drag axis
  94838. * * dragPlaneNormal normal of the current drag plane used during the drag
  94839. * * dragPlanePoint in world space where the drag intersects the drag plane
  94840. */
  94841. onDragObservable: Observable<{
  94842. delta: Vector3;
  94843. dragPlanePoint: Vector3;
  94844. dragPlaneNormal: Vector3;
  94845. dragDistance: number;
  94846. pointerId: number;
  94847. }>;
  94848. /**
  94849. * Fires each time a drag begins (eg. mouse down on mesh)
  94850. */
  94851. onDragStartObservable: Observable<{
  94852. dragPlanePoint: Vector3;
  94853. pointerId: number;
  94854. }>;
  94855. /**
  94856. * Fires each time a drag ends (eg. mouse release after drag)
  94857. */
  94858. onDragEndObservable: Observable<{
  94859. dragPlanePoint: Vector3;
  94860. pointerId: number;
  94861. }>;
  94862. /**
  94863. * If the attached mesh should be moved when dragged
  94864. */
  94865. moveAttached: boolean;
  94866. /**
  94867. * If the drag behavior will react to drag events (Default: true)
  94868. */
  94869. enabled: boolean;
  94870. /**
  94871. * If camera controls should be detached during the drag
  94872. */
  94873. detachCameraControls: boolean;
  94874. /**
  94875. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  94876. */
  94877. useObjectOrienationForDragging: boolean;
  94878. private _options;
  94879. /**
  94880. * Creates a pointer drag behavior that can be attached to a mesh
  94881. * @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)
  94882. */
  94883. constructor(options?: {
  94884. dragAxis?: Vector3;
  94885. dragPlaneNormal?: Vector3;
  94886. });
  94887. /**
  94888. * Predicate to determine if it is valid to move the object to a new position when it is moved
  94889. */
  94890. validateDrag: (targetPosition: Vector3) => boolean;
  94891. /**
  94892. * The name of the behavior
  94893. */
  94894. readonly name: string;
  94895. /**
  94896. * Initializes the behavior
  94897. */
  94898. init(): void;
  94899. private _tmpVector;
  94900. private _alternatePickedPoint;
  94901. private _worldDragAxis;
  94902. private _targetPosition;
  94903. private _attachedElement;
  94904. /**
  94905. * Attaches the drag behavior the passed in mesh
  94906. * @param ownerNode The mesh that will be dragged around once attached
  94907. */
  94908. attach(ownerNode: AbstractMesh): void;
  94909. /**
  94910. * Force relase the drag action by code.
  94911. */
  94912. releaseDrag(): void;
  94913. private _startDragRay;
  94914. private _lastPointerRay;
  94915. /**
  94916. * Simulates the start of a pointer drag event on the behavior
  94917. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  94918. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  94919. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  94920. */
  94921. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  94922. private _startDrag;
  94923. private _dragDelta;
  94924. private _moveDrag;
  94925. private _pickWithRayOnDragPlane;
  94926. private _pointA;
  94927. private _pointB;
  94928. private _pointC;
  94929. private _lineA;
  94930. private _lineB;
  94931. private _localAxis;
  94932. private _lookAt;
  94933. private _updateDragPlanePosition;
  94934. /**
  94935. * Detaches the behavior from the mesh
  94936. */
  94937. detach(): void;
  94938. }
  94939. }
  94940. declare module BABYLON {
  94941. /**
  94942. * A behavior that when attached to a mesh will allow the mesh to be scaled
  94943. */
  94944. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  94945. private _dragBehaviorA;
  94946. private _dragBehaviorB;
  94947. private _startDistance;
  94948. private _initialScale;
  94949. private _targetScale;
  94950. private _ownerNode;
  94951. private _sceneRenderObserver;
  94952. /**
  94953. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  94954. */
  94955. constructor();
  94956. /**
  94957. * The name of the behavior
  94958. */
  94959. readonly name: string;
  94960. /**
  94961. * Initializes the behavior
  94962. */
  94963. init(): void;
  94964. private _getCurrentDistance;
  94965. /**
  94966. * Attaches the scale behavior the passed in mesh
  94967. * @param ownerNode The mesh that will be scaled around once attached
  94968. */
  94969. attach(ownerNode: Mesh): void;
  94970. /**
  94971. * Detaches the behavior from the mesh
  94972. */
  94973. detach(): void;
  94974. }
  94975. }
  94976. declare module BABYLON {
  94977. /**
  94978. * 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
  94979. */
  94980. export class SixDofDragBehavior implements Behavior<Mesh> {
  94981. private static _virtualScene;
  94982. private _ownerNode;
  94983. private _sceneRenderObserver;
  94984. private _scene;
  94985. private _targetPosition;
  94986. private _virtualOriginMesh;
  94987. private _virtualDragMesh;
  94988. private _pointerObserver;
  94989. private _moving;
  94990. private _startingOrientation;
  94991. /**
  94992. * 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)
  94993. */
  94994. private zDragFactor;
  94995. /**
  94996. * If the object should rotate to face the drag origin
  94997. */
  94998. rotateDraggedObject: boolean;
  94999. /**
  95000. * If the behavior is currently in a dragging state
  95001. */
  95002. dragging: boolean;
  95003. /**
  95004. * 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)
  95005. */
  95006. dragDeltaRatio: number;
  95007. /**
  95008. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95009. */
  95010. currentDraggingPointerID: number;
  95011. /**
  95012. * If camera controls should be detached during the drag
  95013. */
  95014. detachCameraControls: boolean;
  95015. /**
  95016. * Fires each time a drag starts
  95017. */
  95018. onDragStartObservable: Observable<{}>;
  95019. /**
  95020. * Fires each time a drag ends (eg. mouse release after drag)
  95021. */
  95022. onDragEndObservable: Observable<{}>;
  95023. /**
  95024. * 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
  95025. */
  95026. constructor();
  95027. /**
  95028. * The name of the behavior
  95029. */
  95030. readonly name: string;
  95031. /**
  95032. * Initializes the behavior
  95033. */
  95034. init(): void;
  95035. /**
  95036. * Attaches the scale behavior the passed in mesh
  95037. * @param ownerNode The mesh that will be scaled around once attached
  95038. */
  95039. attach(ownerNode: Mesh): void;
  95040. /**
  95041. * Detaches the behavior from the mesh
  95042. */
  95043. detach(): void;
  95044. }
  95045. }
  95046. declare module BABYLON {
  95047. /**
  95048. * Class used to apply inverse kinematics to bones
  95049. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95050. */
  95051. export class BoneIKController {
  95052. private static _tmpVecs;
  95053. private static _tmpQuat;
  95054. private static _tmpMats;
  95055. /**
  95056. * Gets or sets the target mesh
  95057. */
  95058. targetMesh: AbstractMesh;
  95059. /** Gets or sets the mesh used as pole */
  95060. poleTargetMesh: AbstractMesh;
  95061. /**
  95062. * Gets or sets the bone used as pole
  95063. */
  95064. poleTargetBone: Nullable<Bone>;
  95065. /**
  95066. * Gets or sets the target position
  95067. */
  95068. targetPosition: Vector3;
  95069. /**
  95070. * Gets or sets the pole target position
  95071. */
  95072. poleTargetPosition: Vector3;
  95073. /**
  95074. * Gets or sets the pole target local offset
  95075. */
  95076. poleTargetLocalOffset: Vector3;
  95077. /**
  95078. * Gets or sets the pole angle
  95079. */
  95080. poleAngle: number;
  95081. /**
  95082. * Gets or sets the mesh associated with the controller
  95083. */
  95084. mesh: AbstractMesh;
  95085. /**
  95086. * 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)
  95087. */
  95088. slerpAmount: number;
  95089. private _bone1Quat;
  95090. private _bone1Mat;
  95091. private _bone2Ang;
  95092. private _bone1;
  95093. private _bone2;
  95094. private _bone1Length;
  95095. private _bone2Length;
  95096. private _maxAngle;
  95097. private _maxReach;
  95098. private _rightHandedSystem;
  95099. private _bendAxis;
  95100. private _slerping;
  95101. private _adjustRoll;
  95102. /**
  95103. * Gets or sets maximum allowed angle
  95104. */
  95105. maxAngle: number;
  95106. /**
  95107. * Creates a new BoneIKController
  95108. * @param mesh defines the mesh to control
  95109. * @param bone defines the bone to control
  95110. * @param options defines options to set up the controller
  95111. */
  95112. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95113. targetMesh?: AbstractMesh;
  95114. poleTargetMesh?: AbstractMesh;
  95115. poleTargetBone?: Bone;
  95116. poleTargetLocalOffset?: Vector3;
  95117. poleAngle?: number;
  95118. bendAxis?: Vector3;
  95119. maxAngle?: number;
  95120. slerpAmount?: number;
  95121. });
  95122. private _setMaxAngle;
  95123. /**
  95124. * Force the controller to update the bones
  95125. */
  95126. update(): void;
  95127. }
  95128. }
  95129. declare module BABYLON {
  95130. /**
  95131. * Class used to make a bone look toward a point in space
  95132. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95133. */
  95134. export class BoneLookController {
  95135. private static _tmpVecs;
  95136. private static _tmpQuat;
  95137. private static _tmpMats;
  95138. /**
  95139. * The target Vector3 that the bone will look at
  95140. */
  95141. target: Vector3;
  95142. /**
  95143. * The mesh that the bone is attached to
  95144. */
  95145. mesh: AbstractMesh;
  95146. /**
  95147. * The bone that will be looking to the target
  95148. */
  95149. bone: Bone;
  95150. /**
  95151. * The up axis of the coordinate system that is used when the bone is rotated
  95152. */
  95153. upAxis: Vector3;
  95154. /**
  95155. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95156. */
  95157. upAxisSpace: Space;
  95158. /**
  95159. * Used to make an adjustment to the yaw of the bone
  95160. */
  95161. adjustYaw: number;
  95162. /**
  95163. * Used to make an adjustment to the pitch of the bone
  95164. */
  95165. adjustPitch: number;
  95166. /**
  95167. * Used to make an adjustment to the roll of the bone
  95168. */
  95169. adjustRoll: number;
  95170. /**
  95171. * 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)
  95172. */
  95173. slerpAmount: number;
  95174. private _minYaw;
  95175. private _maxYaw;
  95176. private _minPitch;
  95177. private _maxPitch;
  95178. private _minYawSin;
  95179. private _minYawCos;
  95180. private _maxYawSin;
  95181. private _maxYawCos;
  95182. private _midYawConstraint;
  95183. private _minPitchTan;
  95184. private _maxPitchTan;
  95185. private _boneQuat;
  95186. private _slerping;
  95187. private _transformYawPitch;
  95188. private _transformYawPitchInv;
  95189. private _firstFrameSkipped;
  95190. private _yawRange;
  95191. private _fowardAxis;
  95192. /**
  95193. * Gets or sets the minimum yaw angle that the bone can look to
  95194. */
  95195. minYaw: number;
  95196. /**
  95197. * Gets or sets the maximum yaw angle that the bone can look to
  95198. */
  95199. maxYaw: number;
  95200. /**
  95201. * Gets or sets the minimum pitch angle that the bone can look to
  95202. */
  95203. minPitch: number;
  95204. /**
  95205. * Gets or sets the maximum pitch angle that the bone can look to
  95206. */
  95207. maxPitch: number;
  95208. /**
  95209. * Create a BoneLookController
  95210. * @param mesh the mesh that the bone belongs to
  95211. * @param bone the bone that will be looking to the target
  95212. * @param target the target Vector3 to look at
  95213. * @param options optional settings:
  95214. * * maxYaw: the maximum angle the bone will yaw to
  95215. * * minYaw: the minimum angle the bone will yaw to
  95216. * * maxPitch: the maximum angle the bone will pitch to
  95217. * * minPitch: the minimum angle the bone will yaw to
  95218. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  95219. * * upAxis: the up axis of the coordinate system
  95220. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  95221. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  95222. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  95223. * * adjustYaw: used to make an adjustment to the yaw of the bone
  95224. * * adjustPitch: used to make an adjustment to the pitch of the bone
  95225. * * adjustRoll: used to make an adjustment to the roll of the bone
  95226. **/
  95227. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  95228. maxYaw?: number;
  95229. minYaw?: number;
  95230. maxPitch?: number;
  95231. minPitch?: number;
  95232. slerpAmount?: number;
  95233. upAxis?: Vector3;
  95234. upAxisSpace?: Space;
  95235. yawAxis?: Vector3;
  95236. pitchAxis?: Vector3;
  95237. adjustYaw?: number;
  95238. adjustPitch?: number;
  95239. adjustRoll?: number;
  95240. });
  95241. /**
  95242. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  95243. */
  95244. update(): void;
  95245. private _getAngleDiff;
  95246. private _getAngleBetween;
  95247. private _isAngleBetween;
  95248. }
  95249. }
  95250. declare module BABYLON {
  95251. /**
  95252. * Manage the gamepad inputs to control an arc rotate camera.
  95253. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95254. */
  95255. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  95256. /**
  95257. * Defines the camera the input is attached to.
  95258. */
  95259. camera: ArcRotateCamera;
  95260. /**
  95261. * Defines the gamepad the input is gathering event from.
  95262. */
  95263. gamepad: Nullable<Gamepad>;
  95264. /**
  95265. * Defines the gamepad rotation sensiblity.
  95266. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95267. */
  95268. gamepadRotationSensibility: number;
  95269. /**
  95270. * Defines the gamepad move sensiblity.
  95271. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95272. */
  95273. gamepadMoveSensibility: number;
  95274. private _onGamepadConnectedObserver;
  95275. private _onGamepadDisconnectedObserver;
  95276. /**
  95277. * Attach the input controls to a specific dom element to get the input from.
  95278. * @param element Defines the element the controls should be listened from
  95279. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95280. */
  95281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95282. /**
  95283. * Detach the current controls from the specified dom element.
  95284. * @param element Defines the element to stop listening the inputs from
  95285. */
  95286. detachControl(element: Nullable<HTMLElement>): void;
  95287. /**
  95288. * Update the current camera state depending on the inputs that have been used this frame.
  95289. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95290. */
  95291. checkInputs(): void;
  95292. /**
  95293. * Gets the class name of the current intput.
  95294. * @returns the class name
  95295. */
  95296. getClassName(): string;
  95297. /**
  95298. * Get the friendly name associated with the input class.
  95299. * @returns the input friendly name
  95300. */
  95301. getSimpleName(): string;
  95302. }
  95303. }
  95304. declare module BABYLON {
  95305. interface ArcRotateCameraInputsManager {
  95306. /**
  95307. * Add orientation input support to the input manager.
  95308. * @returns the current input manager
  95309. */
  95310. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  95311. }
  95312. /**
  95313. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  95314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95315. */
  95316. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  95317. /**
  95318. * Defines the camera the input is attached to.
  95319. */
  95320. camera: ArcRotateCamera;
  95321. /**
  95322. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  95323. */
  95324. alphaCorrection: number;
  95325. /**
  95326. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  95327. */
  95328. gammaCorrection: number;
  95329. private _alpha;
  95330. private _gamma;
  95331. private _dirty;
  95332. private _deviceOrientationHandler;
  95333. /**
  95334. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  95335. */
  95336. constructor();
  95337. /**
  95338. * Attach the input controls to a specific dom element to get the input from.
  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. */
  95342. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95343. /** @hidden */
  95344. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  95345. /**
  95346. * Update the current camera state depending on the inputs that have been used this frame.
  95347. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95348. */
  95349. checkInputs(): void;
  95350. /**
  95351. * Detach the current controls from the specified dom element.
  95352. * @param element Defines the element to stop listening the inputs from
  95353. */
  95354. detachControl(element: Nullable<HTMLElement>): void;
  95355. /**
  95356. * Gets the class name of the current intput.
  95357. * @returns the class name
  95358. */
  95359. getClassName(): string;
  95360. /**
  95361. * Get the friendly name associated with the input class.
  95362. * @returns the input friendly name
  95363. */
  95364. getSimpleName(): string;
  95365. }
  95366. }
  95367. declare module BABYLON {
  95368. /**
  95369. * Listen to mouse events to control the camera.
  95370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95371. */
  95372. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  95373. /**
  95374. * Defines the camera the input is attached to.
  95375. */
  95376. camera: FlyCamera;
  95377. /**
  95378. * Defines if touch is enabled. (Default is true.)
  95379. */
  95380. touchEnabled: boolean;
  95381. /**
  95382. * Defines the buttons associated with the input to handle camera rotation.
  95383. */
  95384. buttons: number[];
  95385. /**
  95386. * Assign buttons for Yaw control.
  95387. */
  95388. buttonsYaw: number[];
  95389. /**
  95390. * Assign buttons for Pitch control.
  95391. */
  95392. buttonsPitch: number[];
  95393. /**
  95394. * Assign buttons for Roll control.
  95395. */
  95396. buttonsRoll: number[];
  95397. /**
  95398. * Detect if any button is being pressed while mouse is moved.
  95399. * -1 = Mouse locked.
  95400. * 0 = Left button.
  95401. * 1 = Middle Button.
  95402. * 2 = Right Button.
  95403. */
  95404. activeButton: number;
  95405. /**
  95406. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  95407. * Higher values reduce its sensitivity.
  95408. */
  95409. angularSensibility: number;
  95410. private _mousemoveCallback;
  95411. private _observer;
  95412. private _rollObserver;
  95413. private previousPosition;
  95414. private noPreventDefault;
  95415. private element;
  95416. /**
  95417. * Listen to mouse events to control the camera.
  95418. * @param touchEnabled Define if touch is enabled. (Default is true.)
  95419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95420. */
  95421. constructor(touchEnabled?: boolean);
  95422. /**
  95423. * Attach the mouse control to the HTML DOM element.
  95424. * @param element Defines the element that listens to the input events.
  95425. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  95426. */
  95427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95428. /**
  95429. * Detach the current controls from the specified dom element.
  95430. * @param element Defines the element to stop listening the inputs from
  95431. */
  95432. detachControl(element: Nullable<HTMLElement>): void;
  95433. /**
  95434. * Gets the class name of the current input.
  95435. * @returns the class name.
  95436. */
  95437. getClassName(): string;
  95438. /**
  95439. * Get the friendly name associated with the input class.
  95440. * @returns the input's friendly name.
  95441. */
  95442. getSimpleName(): string;
  95443. private _pointerInput;
  95444. private _onMouseMove;
  95445. /**
  95446. * Rotate camera by mouse offset.
  95447. */
  95448. private rotateCamera;
  95449. }
  95450. }
  95451. declare module BABYLON {
  95452. /**
  95453. * Default Inputs manager for the FlyCamera.
  95454. * It groups all the default supported inputs for ease of use.
  95455. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95456. */
  95457. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  95458. /**
  95459. * Instantiates a new FlyCameraInputsManager.
  95460. * @param camera Defines the camera the inputs belong to.
  95461. */
  95462. constructor(camera: FlyCamera);
  95463. /**
  95464. * Add keyboard input support to the input manager.
  95465. * @returns the new FlyCameraKeyboardMoveInput().
  95466. */
  95467. addKeyboard(): FlyCameraInputsManager;
  95468. /**
  95469. * Add mouse input support to the input manager.
  95470. * @param touchEnabled Enable touch screen support.
  95471. * @returns the new FlyCameraMouseInput().
  95472. */
  95473. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  95474. }
  95475. }
  95476. declare module BABYLON {
  95477. /**
  95478. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95479. * such as in a 3D Space Shooter or a Flight Simulator.
  95480. */
  95481. export class FlyCamera extends TargetCamera {
  95482. /**
  95483. * Define the collision ellipsoid of the camera.
  95484. * This is helpful for simulating a camera body, like a player's body.
  95485. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95486. */
  95487. ellipsoid: Vector3;
  95488. /**
  95489. * Define an offset for the position of the ellipsoid around the camera.
  95490. * This can be helpful if the camera is attached away from the player's body center,
  95491. * such as at its head.
  95492. */
  95493. ellipsoidOffset: Vector3;
  95494. /**
  95495. * Enable or disable collisions of the camera with the rest of the scene objects.
  95496. */
  95497. checkCollisions: boolean;
  95498. /**
  95499. * Enable or disable gravity on the camera.
  95500. */
  95501. applyGravity: boolean;
  95502. /**
  95503. * Define the current direction the camera is moving to.
  95504. */
  95505. cameraDirection: Vector3;
  95506. /**
  95507. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  95508. * This overrides and empties cameraRotation.
  95509. */
  95510. rotationQuaternion: Quaternion;
  95511. /**
  95512. * Track Roll to maintain the wanted Rolling when looking around.
  95513. */
  95514. _trackRoll: number;
  95515. /**
  95516. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  95517. */
  95518. rollCorrect: number;
  95519. /**
  95520. * Mimic a banked turn, Rolling the camera when Yawing.
  95521. * It's recommended to use rollCorrect = 10 for faster banking correction.
  95522. */
  95523. bankedTurn: boolean;
  95524. /**
  95525. * Limit in radians for how much Roll banking will add. (Default: 90°)
  95526. */
  95527. bankedTurnLimit: number;
  95528. /**
  95529. * Value of 0 disables the banked Roll.
  95530. * Value of 1 is equal to the Yaw angle in radians.
  95531. */
  95532. bankedTurnMultiplier: number;
  95533. /**
  95534. * The inputs manager loads all the input sources, such as keyboard and mouse.
  95535. */
  95536. inputs: FlyCameraInputsManager;
  95537. /**
  95538. * Gets the input sensibility for mouse input.
  95539. * Higher values reduce sensitivity.
  95540. */
  95541. /**
  95542. * Sets the input sensibility for a mouse input.
  95543. * Higher values reduce sensitivity.
  95544. */
  95545. angularSensibility: number;
  95546. /**
  95547. * Get the keys for camera movement forward.
  95548. */
  95549. /**
  95550. * Set the keys for camera movement forward.
  95551. */
  95552. keysForward: number[];
  95553. /**
  95554. * Get the keys for camera movement backward.
  95555. */
  95556. keysBackward: number[];
  95557. /**
  95558. * Get the keys for camera movement up.
  95559. */
  95560. /**
  95561. * Set the keys for camera movement up.
  95562. */
  95563. keysUp: number[];
  95564. /**
  95565. * Get the keys for camera movement down.
  95566. */
  95567. /**
  95568. * Set the keys for camera movement down.
  95569. */
  95570. keysDown: number[];
  95571. /**
  95572. * Get the keys for camera movement left.
  95573. */
  95574. /**
  95575. * Set the keys for camera movement left.
  95576. */
  95577. keysLeft: number[];
  95578. /**
  95579. * Set the keys for camera movement right.
  95580. */
  95581. /**
  95582. * Set the keys for camera movement right.
  95583. */
  95584. keysRight: number[];
  95585. /**
  95586. * Event raised when the camera collides with a mesh in the scene.
  95587. */
  95588. onCollide: (collidedMesh: AbstractMesh) => void;
  95589. private _collider;
  95590. private _needMoveForGravity;
  95591. private _oldPosition;
  95592. private _diffPosition;
  95593. private _newPosition;
  95594. /** @hidden */
  95595. _localDirection: Vector3;
  95596. /** @hidden */
  95597. _transformedDirection: Vector3;
  95598. /**
  95599. * Instantiates a FlyCamera.
  95600. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95601. * such as in a 3D Space Shooter or a Flight Simulator.
  95602. * @param name Define the name of the camera in the scene.
  95603. * @param position Define the starting position of the camera in the scene.
  95604. * @param scene Define the scene the camera belongs to.
  95605. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  95606. */
  95607. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95608. /**
  95609. * Attach a control to the HTML DOM element.
  95610. * @param element Defines the element that listens to the input events.
  95611. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  95612. */
  95613. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95614. /**
  95615. * Detach a control from the HTML DOM element.
  95616. * The camera will stop reacting to that input.
  95617. * @param element Defines the element that listens to the input events.
  95618. */
  95619. detachControl(element: HTMLElement): void;
  95620. private _collisionMask;
  95621. /**
  95622. * Get the mask that the camera ignores in collision events.
  95623. */
  95624. /**
  95625. * Set the mask that the camera ignores in collision events.
  95626. */
  95627. collisionMask: number;
  95628. /** @hidden */
  95629. _collideWithWorld(displacement: Vector3): void;
  95630. /** @hidden */
  95631. private _onCollisionPositionChange;
  95632. /** @hidden */
  95633. _checkInputs(): void;
  95634. /** @hidden */
  95635. _decideIfNeedsToMove(): boolean;
  95636. /** @hidden */
  95637. _updatePosition(): void;
  95638. /**
  95639. * Restore the Roll to its target value at the rate specified.
  95640. * @param rate - Higher means slower restoring.
  95641. * @hidden
  95642. */
  95643. restoreRoll(rate: number): void;
  95644. /**
  95645. * Destroy the camera and release the current resources held by it.
  95646. */
  95647. dispose(): void;
  95648. /**
  95649. * Get the current object class name.
  95650. * @returns the class name.
  95651. */
  95652. getClassName(): string;
  95653. }
  95654. }
  95655. declare module BABYLON {
  95656. /**
  95657. * Listen to keyboard events to control the camera.
  95658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95659. */
  95660. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  95661. /**
  95662. * Defines the camera the input is attached to.
  95663. */
  95664. camera: FlyCamera;
  95665. /**
  95666. * The list of keyboard keys used to control the forward move of the camera.
  95667. */
  95668. keysForward: number[];
  95669. /**
  95670. * The list of keyboard keys used to control the backward move of the camera.
  95671. */
  95672. keysBackward: number[];
  95673. /**
  95674. * The list of keyboard keys used to control the forward move of the camera.
  95675. */
  95676. keysUp: number[];
  95677. /**
  95678. * The list of keyboard keys used to control the backward move of the camera.
  95679. */
  95680. keysDown: number[];
  95681. /**
  95682. * The list of keyboard keys used to control the right strafe move of the camera.
  95683. */
  95684. keysRight: number[];
  95685. /**
  95686. * The list of keyboard keys used to control the left strafe move of the camera.
  95687. */
  95688. keysLeft: number[];
  95689. private _keys;
  95690. private _onCanvasBlurObserver;
  95691. private _onKeyboardObserver;
  95692. private _engine;
  95693. private _scene;
  95694. /**
  95695. * Attach the input controls to a specific dom element to get the input from.
  95696. * @param element Defines the element the controls should be listened from
  95697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95698. */
  95699. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95700. /**
  95701. * Detach the current controls from the specified dom element.
  95702. * @param element Defines the element to stop listening the inputs from
  95703. */
  95704. detachControl(element: Nullable<HTMLElement>): void;
  95705. /**
  95706. * Gets the class name of the current intput.
  95707. * @returns the class name
  95708. */
  95709. getClassName(): string;
  95710. /** @hidden */
  95711. _onLostFocus(e: FocusEvent): void;
  95712. /**
  95713. * Get the friendly name associated with the input class.
  95714. * @returns the input friendly name
  95715. */
  95716. getSimpleName(): string;
  95717. /**
  95718. * Update the current camera state depending on the inputs that have been used this frame.
  95719. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95720. */
  95721. checkInputs(): void;
  95722. }
  95723. }
  95724. declare module BABYLON {
  95725. /**
  95726. * Manage the mouse wheel inputs to control a follow camera.
  95727. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95728. */
  95729. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  95730. /**
  95731. * Defines the camera the input is attached to.
  95732. */
  95733. camera: FollowCamera;
  95734. /**
  95735. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  95736. */
  95737. axisControlRadius: boolean;
  95738. /**
  95739. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  95740. */
  95741. axisControlHeight: boolean;
  95742. /**
  95743. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  95744. */
  95745. axisControlRotation: boolean;
  95746. /**
  95747. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  95748. * relation to mouseWheel events.
  95749. */
  95750. wheelPrecision: number;
  95751. /**
  95752. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  95753. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  95754. */
  95755. wheelDeltaPercentage: number;
  95756. private _wheel;
  95757. private _observer;
  95758. /**
  95759. * Attach the input controls to a specific dom element to get the input from.
  95760. * @param element Defines the element the controls should be listened from
  95761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95762. */
  95763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95764. /**
  95765. * Detach the current controls from the specified dom element.
  95766. * @param element Defines the element to stop listening the inputs from
  95767. */
  95768. detachControl(element: Nullable<HTMLElement>): void;
  95769. /**
  95770. * Gets the class name of the current intput.
  95771. * @returns the class name
  95772. */
  95773. getClassName(): string;
  95774. /**
  95775. * Get the friendly name associated with the input class.
  95776. * @returns the input friendly name
  95777. */
  95778. getSimpleName(): string;
  95779. }
  95780. }
  95781. declare module BABYLON {
  95782. /**
  95783. * Manage the pointers inputs to control an follow camera.
  95784. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95785. */
  95786. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  95787. /**
  95788. * Defines the camera the input is attached to.
  95789. */
  95790. camera: FollowCamera;
  95791. /**
  95792. * Gets the class name of the current input.
  95793. * @returns the class name
  95794. */
  95795. getClassName(): string;
  95796. /**
  95797. * Defines the pointer angular sensibility along the X axis or how fast is
  95798. * the camera rotating.
  95799. * A negative number will reverse the axis direction.
  95800. */
  95801. angularSensibilityX: number;
  95802. /**
  95803. * Defines the pointer angular sensibility along the Y axis or how fast is
  95804. * the camera rotating.
  95805. * A negative number will reverse the axis direction.
  95806. */
  95807. angularSensibilityY: number;
  95808. /**
  95809. * Defines the pointer pinch precision or how fast is the camera zooming.
  95810. * A negative number will reverse the axis direction.
  95811. */
  95812. pinchPrecision: number;
  95813. /**
  95814. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  95815. * from 0.
  95816. * It defines the percentage of current camera.radius to use as delta when
  95817. * pinch zoom is used.
  95818. */
  95819. pinchDeltaPercentage: number;
  95820. /**
  95821. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  95822. */
  95823. axisXControlRadius: boolean;
  95824. /**
  95825. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  95826. */
  95827. axisXControlHeight: boolean;
  95828. /**
  95829. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  95830. */
  95831. axisXControlRotation: boolean;
  95832. /**
  95833. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  95834. */
  95835. axisYControlRadius: boolean;
  95836. /**
  95837. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  95838. */
  95839. axisYControlHeight: boolean;
  95840. /**
  95841. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  95842. */
  95843. axisYControlRotation: boolean;
  95844. /**
  95845. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  95846. */
  95847. axisPinchControlRadius: boolean;
  95848. /**
  95849. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  95850. */
  95851. axisPinchControlHeight: boolean;
  95852. /**
  95853. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  95854. */
  95855. axisPinchControlRotation: boolean;
  95856. /**
  95857. * Log error messages if basic misconfiguration has occurred.
  95858. */
  95859. warningEnable: boolean;
  95860. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  95861. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  95862. private _warningCounter;
  95863. private _warning;
  95864. }
  95865. }
  95866. declare module BABYLON {
  95867. /**
  95868. * Default Inputs manager for the FollowCamera.
  95869. * It groups all the default supported inputs for ease of use.
  95870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95871. */
  95872. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  95873. /**
  95874. * Instantiates a new FollowCameraInputsManager.
  95875. * @param camera Defines the camera the inputs belong to
  95876. */
  95877. constructor(camera: FollowCamera);
  95878. /**
  95879. * Add keyboard input support to the input manager.
  95880. * @returns the current input manager
  95881. */
  95882. addKeyboard(): FollowCameraInputsManager;
  95883. /**
  95884. * Add mouse wheel input support to the input manager.
  95885. * @returns the current input manager
  95886. */
  95887. addMouseWheel(): FollowCameraInputsManager;
  95888. /**
  95889. * Add pointers input support to the input manager.
  95890. * @returns the current input manager
  95891. */
  95892. addPointers(): FollowCameraInputsManager;
  95893. /**
  95894. * Add orientation input support to the input manager.
  95895. * @returns the current input manager
  95896. */
  95897. addVRDeviceOrientation(): FollowCameraInputsManager;
  95898. }
  95899. }
  95900. declare module BABYLON {
  95901. /**
  95902. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  95903. * an arc rotate version arcFollowCamera are available.
  95904. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95905. */
  95906. export class FollowCamera extends TargetCamera {
  95907. /**
  95908. * Distance the follow camera should follow an object at
  95909. */
  95910. radius: number;
  95911. /**
  95912. * Minimum allowed distance of the camera to the axis of rotation
  95913. * (The camera can not get closer).
  95914. * This can help limiting how the Camera is able to move in the scene.
  95915. */
  95916. lowerRadiusLimit: Nullable<number>;
  95917. /**
  95918. * Maximum allowed distance of the camera to the axis of rotation
  95919. * (The camera can not get further).
  95920. * This can help limiting how the Camera is able to move in the scene.
  95921. */
  95922. upperRadiusLimit: Nullable<number>;
  95923. /**
  95924. * Define a rotation offset between the camera and the object it follows
  95925. */
  95926. rotationOffset: number;
  95927. /**
  95928. * Minimum allowed angle to camera position relative to target object.
  95929. * This can help limiting how the Camera is able to move in the scene.
  95930. */
  95931. lowerRotationOffsetLimit: Nullable<number>;
  95932. /**
  95933. * Maximum allowed angle to camera position relative to target object.
  95934. * This can help limiting how the Camera is able to move in the scene.
  95935. */
  95936. upperRotationOffsetLimit: Nullable<number>;
  95937. /**
  95938. * Define a height offset between the camera and the object it follows.
  95939. * It can help following an object from the top (like a car chaing a plane)
  95940. */
  95941. heightOffset: number;
  95942. /**
  95943. * Minimum allowed height of camera position relative to target object.
  95944. * This can help limiting how the Camera is able to move in the scene.
  95945. */
  95946. lowerHeightOffsetLimit: Nullable<number>;
  95947. /**
  95948. * Maximum allowed height of camera position relative to target object.
  95949. * This can help limiting how the Camera is able to move in the scene.
  95950. */
  95951. upperHeightOffsetLimit: Nullable<number>;
  95952. /**
  95953. * Define how fast the camera can accelerate to follow it s target.
  95954. */
  95955. cameraAcceleration: number;
  95956. /**
  95957. * Define the speed limit of the camera following an object.
  95958. */
  95959. maxCameraSpeed: number;
  95960. /**
  95961. * Define the target of the camera.
  95962. */
  95963. lockedTarget: Nullable<AbstractMesh>;
  95964. /**
  95965. * Defines the input associated with the camera.
  95966. */
  95967. inputs: FollowCameraInputsManager;
  95968. /**
  95969. * Instantiates the follow camera.
  95970. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  95971. * @param name Define the name of the camera in the scene
  95972. * @param position Define the position of the camera
  95973. * @param scene Define the scene the camera belong to
  95974. * @param lockedTarget Define the target of the camera
  95975. */
  95976. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  95977. private _follow;
  95978. /**
  95979. * Attached controls to the current camera.
  95980. * @param element Defines the element the controls should be listened from
  95981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95982. */
  95983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95984. /**
  95985. * Detach the current controls from the camera.
  95986. * The camera will stop reacting to inputs.
  95987. * @param element Defines the element to stop listening the inputs from
  95988. */
  95989. detachControl(element: HTMLElement): void;
  95990. /** @hidden */
  95991. _checkInputs(): void;
  95992. private _checkLimits;
  95993. /**
  95994. * Gets the camera class name.
  95995. * @returns the class name
  95996. */
  95997. getClassName(): string;
  95998. }
  95999. /**
  96000. * Arc Rotate version of the follow camera.
  96001. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96002. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96003. */
  96004. export class ArcFollowCamera extends TargetCamera {
  96005. /** The longitudinal angle of the camera */
  96006. alpha: number;
  96007. /** The latitudinal angle of the camera */
  96008. beta: number;
  96009. /** The radius of the camera from its target */
  96010. radius: number;
  96011. /** Define the camera target (the messh it should follow) */
  96012. target: Nullable<AbstractMesh>;
  96013. private _cartesianCoordinates;
  96014. /**
  96015. * Instantiates a new ArcFollowCamera
  96016. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96017. * @param name Define the name of the camera
  96018. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96019. * @param beta Define the rotation angle of the camera around the elevation axis
  96020. * @param radius Define the radius of the camera from its target point
  96021. * @param target Define the target of the camera
  96022. * @param scene Define the scene the camera belongs to
  96023. */
  96024. constructor(name: string,
  96025. /** The longitudinal angle of the camera */
  96026. alpha: number,
  96027. /** The latitudinal angle of the camera */
  96028. beta: number,
  96029. /** The radius of the camera from its target */
  96030. radius: number,
  96031. /** Define the camera target (the messh it should follow) */
  96032. target: Nullable<AbstractMesh>, scene: Scene);
  96033. private _follow;
  96034. /** @hidden */
  96035. _checkInputs(): void;
  96036. /**
  96037. * Returns the class name of the object.
  96038. * It is mostly used internally for serialization purposes.
  96039. */
  96040. getClassName(): string;
  96041. }
  96042. }
  96043. declare module BABYLON {
  96044. /**
  96045. * Manage the keyboard inputs to control the movement of a follow camera.
  96046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96047. */
  96048. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96049. /**
  96050. * Defines the camera the input is attached to.
  96051. */
  96052. camera: FollowCamera;
  96053. /**
  96054. * Defines the list of key codes associated with the up action (increase heightOffset)
  96055. */
  96056. keysHeightOffsetIncr: number[];
  96057. /**
  96058. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96059. */
  96060. keysHeightOffsetDecr: number[];
  96061. /**
  96062. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96063. */
  96064. keysHeightOffsetModifierAlt: boolean;
  96065. /**
  96066. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96067. */
  96068. keysHeightOffsetModifierCtrl: boolean;
  96069. /**
  96070. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96071. */
  96072. keysHeightOffsetModifierShift: boolean;
  96073. /**
  96074. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96075. */
  96076. keysRotationOffsetIncr: number[];
  96077. /**
  96078. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96079. */
  96080. keysRotationOffsetDecr: number[];
  96081. /**
  96082. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96083. */
  96084. keysRotationOffsetModifierAlt: boolean;
  96085. /**
  96086. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96087. */
  96088. keysRotationOffsetModifierCtrl: boolean;
  96089. /**
  96090. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96091. */
  96092. keysRotationOffsetModifierShift: boolean;
  96093. /**
  96094. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96095. */
  96096. keysRadiusIncr: number[];
  96097. /**
  96098. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96099. */
  96100. keysRadiusDecr: number[];
  96101. /**
  96102. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96103. */
  96104. keysRadiusModifierAlt: boolean;
  96105. /**
  96106. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96107. */
  96108. keysRadiusModifierCtrl: boolean;
  96109. /**
  96110. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96111. */
  96112. keysRadiusModifierShift: boolean;
  96113. /**
  96114. * Defines the rate of change of heightOffset.
  96115. */
  96116. heightSensibility: number;
  96117. /**
  96118. * Defines the rate of change of rotationOffset.
  96119. */
  96120. rotationSensibility: number;
  96121. /**
  96122. * Defines the rate of change of radius.
  96123. */
  96124. radiusSensibility: number;
  96125. private _keys;
  96126. private _ctrlPressed;
  96127. private _altPressed;
  96128. private _shiftPressed;
  96129. private _onCanvasBlurObserver;
  96130. private _onKeyboardObserver;
  96131. private _engine;
  96132. private _scene;
  96133. /**
  96134. * Attach the input controls to a specific dom element to get the input from.
  96135. * @param element Defines the element the controls should be listened from
  96136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96137. */
  96138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96139. /**
  96140. * Detach the current controls from the specified dom element.
  96141. * @param element Defines the element to stop listening the inputs from
  96142. */
  96143. detachControl(element: Nullable<HTMLElement>): void;
  96144. /**
  96145. * Update the current camera state depending on the inputs that have been used this frame.
  96146. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96147. */
  96148. checkInputs(): void;
  96149. /**
  96150. * Gets the class name of the current input.
  96151. * @returns the class name
  96152. */
  96153. getClassName(): string;
  96154. /**
  96155. * Get the friendly name associated with the input class.
  96156. * @returns the input friendly name
  96157. */
  96158. getSimpleName(): string;
  96159. /**
  96160. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96161. * allow modification of the heightOffset value.
  96162. */
  96163. private _modifierHeightOffset;
  96164. /**
  96165. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96166. * allow modification of the rotationOffset value.
  96167. */
  96168. private _modifierRotationOffset;
  96169. /**
  96170. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96171. * allow modification of the radius value.
  96172. */
  96173. private _modifierRadius;
  96174. }
  96175. }
  96176. declare module BABYLON {
  96177. interface FreeCameraInputsManager {
  96178. /**
  96179. * @hidden
  96180. */
  96181. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  96182. /**
  96183. * Add orientation input support to the input manager.
  96184. * @returns the current input manager
  96185. */
  96186. addDeviceOrientation(): FreeCameraInputsManager;
  96187. }
  96188. /**
  96189. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  96190. * Screen rotation is taken into account.
  96191. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96192. */
  96193. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  96194. private _camera;
  96195. private _screenOrientationAngle;
  96196. private _constantTranform;
  96197. private _screenQuaternion;
  96198. private _alpha;
  96199. private _beta;
  96200. private _gamma;
  96201. /**
  96202. * @hidden
  96203. */
  96204. _onDeviceOrientationChangedObservable: Observable<void>;
  96205. /**
  96206. * Instantiates a new input
  96207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96208. */
  96209. constructor();
  96210. /**
  96211. * Define the camera controlled by the input.
  96212. */
  96213. camera: FreeCamera;
  96214. /**
  96215. * Attach the input controls to a specific dom element to get the input from.
  96216. * @param element Defines the element the controls should be listened from
  96217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96218. */
  96219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96220. private _orientationChanged;
  96221. private _deviceOrientation;
  96222. /**
  96223. * Detach the current controls from the specified dom element.
  96224. * @param element Defines the element to stop listening the inputs from
  96225. */
  96226. detachControl(element: Nullable<HTMLElement>): void;
  96227. /**
  96228. * Update the current camera state depending on the inputs that have been used this frame.
  96229. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96230. */
  96231. checkInputs(): void;
  96232. /**
  96233. * Gets the class name of the current intput.
  96234. * @returns the class name
  96235. */
  96236. getClassName(): string;
  96237. /**
  96238. * Get the friendly name associated with the input class.
  96239. * @returns the input friendly name
  96240. */
  96241. getSimpleName(): string;
  96242. }
  96243. }
  96244. declare module BABYLON {
  96245. /**
  96246. * Manage the gamepad inputs to control a free camera.
  96247. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96248. */
  96249. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  96250. /**
  96251. * Define the camera the input is attached to.
  96252. */
  96253. camera: FreeCamera;
  96254. /**
  96255. * Define the Gamepad controlling the input
  96256. */
  96257. gamepad: Nullable<Gamepad>;
  96258. /**
  96259. * Defines the gamepad rotation sensiblity.
  96260. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96261. */
  96262. gamepadAngularSensibility: number;
  96263. /**
  96264. * Defines the gamepad move sensiblity.
  96265. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96266. */
  96267. gamepadMoveSensibility: number;
  96268. private _onGamepadConnectedObserver;
  96269. private _onGamepadDisconnectedObserver;
  96270. private _cameraTransform;
  96271. private _deltaTransform;
  96272. private _vector3;
  96273. private _vector2;
  96274. /**
  96275. * Attach the input controls to a specific dom element to get the input from.
  96276. * @param element Defines the element the controls should be listened from
  96277. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96278. */
  96279. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96280. /**
  96281. * Detach the current controls from the specified dom element.
  96282. * @param element Defines the element to stop listening the inputs from
  96283. */
  96284. detachControl(element: Nullable<HTMLElement>): void;
  96285. /**
  96286. * Update the current camera state depending on the inputs that have been used this frame.
  96287. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96288. */
  96289. checkInputs(): void;
  96290. /**
  96291. * Gets the class name of the current intput.
  96292. * @returns the class name
  96293. */
  96294. getClassName(): string;
  96295. /**
  96296. * Get the friendly name associated with the input class.
  96297. * @returns the input friendly name
  96298. */
  96299. getSimpleName(): string;
  96300. }
  96301. }
  96302. declare module BABYLON {
  96303. /**
  96304. * Defines the potential axis of a Joystick
  96305. */
  96306. export enum JoystickAxis {
  96307. /** X axis */
  96308. X = 0,
  96309. /** Y axis */
  96310. Y = 1,
  96311. /** Z axis */
  96312. Z = 2
  96313. }
  96314. /**
  96315. * Class used to define virtual joystick (used in touch mode)
  96316. */
  96317. export class VirtualJoystick {
  96318. /**
  96319. * Gets or sets a boolean indicating that left and right values must be inverted
  96320. */
  96321. reverseLeftRight: boolean;
  96322. /**
  96323. * Gets or sets a boolean indicating that up and down values must be inverted
  96324. */
  96325. reverseUpDown: boolean;
  96326. /**
  96327. * Gets the offset value for the position (ie. the change of the position value)
  96328. */
  96329. deltaPosition: Vector3;
  96330. /**
  96331. * Gets a boolean indicating if the virtual joystick was pressed
  96332. */
  96333. pressed: boolean;
  96334. /**
  96335. * Canvas the virtual joystick will render onto, default z-index of this is 5
  96336. */
  96337. static Canvas: Nullable<HTMLCanvasElement>;
  96338. private static _globalJoystickIndex;
  96339. private static vjCanvasContext;
  96340. private static vjCanvasWidth;
  96341. private static vjCanvasHeight;
  96342. private static halfWidth;
  96343. private _action;
  96344. private _axisTargetedByLeftAndRight;
  96345. private _axisTargetedByUpAndDown;
  96346. private _joystickSensibility;
  96347. private _inversedSensibility;
  96348. private _joystickPointerID;
  96349. private _joystickColor;
  96350. private _joystickPointerPos;
  96351. private _joystickPreviousPointerPos;
  96352. private _joystickPointerStartPos;
  96353. private _deltaJoystickVector;
  96354. private _leftJoystick;
  96355. private _touches;
  96356. private _onPointerDownHandlerRef;
  96357. private _onPointerMoveHandlerRef;
  96358. private _onPointerUpHandlerRef;
  96359. private _onResize;
  96360. /**
  96361. * Creates a new virtual joystick
  96362. * @param leftJoystick defines that the joystick is for left hand (false by default)
  96363. */
  96364. constructor(leftJoystick?: boolean);
  96365. /**
  96366. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  96367. * @param newJoystickSensibility defines the new sensibility
  96368. */
  96369. setJoystickSensibility(newJoystickSensibility: number): void;
  96370. private _onPointerDown;
  96371. private _onPointerMove;
  96372. private _onPointerUp;
  96373. /**
  96374. * Change the color of the virtual joystick
  96375. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  96376. */
  96377. setJoystickColor(newColor: string): void;
  96378. /**
  96379. * Defines a callback to call when the joystick is touched
  96380. * @param action defines the callback
  96381. */
  96382. setActionOnTouch(action: () => any): void;
  96383. /**
  96384. * Defines which axis you'd like to control for left & right
  96385. * @param axis defines the axis to use
  96386. */
  96387. setAxisForLeftRight(axis: JoystickAxis): void;
  96388. /**
  96389. * Defines which axis you'd like to control for up & down
  96390. * @param axis defines the axis to use
  96391. */
  96392. setAxisForUpDown(axis: JoystickAxis): void;
  96393. private _drawVirtualJoystick;
  96394. /**
  96395. * Release internal HTML canvas
  96396. */
  96397. releaseCanvas(): void;
  96398. }
  96399. }
  96400. declare module BABYLON {
  96401. interface FreeCameraInputsManager {
  96402. /**
  96403. * Add virtual joystick input support to the input manager.
  96404. * @returns the current input manager
  96405. */
  96406. addVirtualJoystick(): FreeCameraInputsManager;
  96407. }
  96408. /**
  96409. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  96410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96411. */
  96412. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  96413. /**
  96414. * Defines the camera the input is attached to.
  96415. */
  96416. camera: FreeCamera;
  96417. private _leftjoystick;
  96418. private _rightjoystick;
  96419. /**
  96420. * Gets the left stick of the virtual joystick.
  96421. * @returns The virtual Joystick
  96422. */
  96423. getLeftJoystick(): VirtualJoystick;
  96424. /**
  96425. * Gets the right stick of the virtual joystick.
  96426. * @returns The virtual Joystick
  96427. */
  96428. getRightJoystick(): VirtualJoystick;
  96429. /**
  96430. * Update the current camera state depending on the inputs that have been used this frame.
  96431. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96432. */
  96433. checkInputs(): void;
  96434. /**
  96435. * Attach the input controls to a specific dom element to get the input from.
  96436. * @param element Defines the element the controls should be listened from
  96437. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96438. */
  96439. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96440. /**
  96441. * Detach the current controls from the specified dom element.
  96442. * @param element Defines the element to stop listening the inputs from
  96443. */
  96444. detachControl(element: Nullable<HTMLElement>): void;
  96445. /**
  96446. * Gets the class name of the current intput.
  96447. * @returns the class name
  96448. */
  96449. getClassName(): string;
  96450. /**
  96451. * Get the friendly name associated with the input class.
  96452. * @returns the input friendly name
  96453. */
  96454. getSimpleName(): string;
  96455. }
  96456. }
  96457. declare module BABYLON {
  96458. /**
  96459. * This represents a FPS type of camera controlled by touch.
  96460. * This is like a universal camera minus the Gamepad controls.
  96461. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96462. */
  96463. export class TouchCamera extends FreeCamera {
  96464. /**
  96465. * Defines the touch sensibility for rotation.
  96466. * The higher the faster.
  96467. */
  96468. touchAngularSensibility: number;
  96469. /**
  96470. * Defines the touch sensibility for move.
  96471. * The higher the faster.
  96472. */
  96473. touchMoveSensibility: number;
  96474. /**
  96475. * Instantiates a new touch camera.
  96476. * This represents a FPS type of camera controlled by touch.
  96477. * This is like a universal camera minus the Gamepad controls.
  96478. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96479. * @param name Define the name of the camera in the scene
  96480. * @param position Define the start position of the camera in the scene
  96481. * @param scene Define the scene the camera belongs to
  96482. */
  96483. constructor(name: string, position: Vector3, scene: Scene);
  96484. /**
  96485. * Gets the current object class name.
  96486. * @return the class name
  96487. */
  96488. getClassName(): string;
  96489. /** @hidden */
  96490. _setupInputs(): void;
  96491. }
  96492. }
  96493. declare module BABYLON {
  96494. /**
  96495. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  96496. * being tilted forward or back and left or right.
  96497. */
  96498. export class DeviceOrientationCamera extends FreeCamera {
  96499. private _initialQuaternion;
  96500. private _quaternionCache;
  96501. private _tmpDragQuaternion;
  96502. /**
  96503. * Creates a new device orientation camera
  96504. * @param name The name of the camera
  96505. * @param position The start position camera
  96506. * @param scene The scene the camera belongs to
  96507. */
  96508. constructor(name: string, position: Vector3, scene: Scene);
  96509. /**
  96510. * Disabled pointer input on first orientation sensor update (Default: true)
  96511. */
  96512. disablePointerInputWhenUsingDeviceOrientation: boolean;
  96513. private _dragFactor;
  96514. /**
  96515. * Enabled turning on the y axis when the orientation sensor is active
  96516. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  96517. */
  96518. enableHorizontalDragging(dragFactor?: number): void;
  96519. /**
  96520. * Gets the current instance class name ("DeviceOrientationCamera").
  96521. * This helps avoiding instanceof at run time.
  96522. * @returns the class name
  96523. */
  96524. getClassName(): string;
  96525. /**
  96526. * @hidden
  96527. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  96528. */
  96529. _checkInputs(): void;
  96530. /**
  96531. * Reset the camera to its default orientation on the specified axis only.
  96532. * @param axis The axis to reset
  96533. */
  96534. resetToCurrentRotation(axis?: Axis): void;
  96535. }
  96536. }
  96537. declare module BABYLON {
  96538. /**
  96539. * 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,
  96540. * which still works and will still be found in many Playgrounds.
  96541. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96542. */
  96543. export class UniversalCamera extends TouchCamera {
  96544. /**
  96545. * Defines the gamepad rotation sensiblity.
  96546. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96547. */
  96548. gamepadAngularSensibility: number;
  96549. /**
  96550. * Defines the gamepad move sensiblity.
  96551. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96552. */
  96553. gamepadMoveSensibility: number;
  96554. /**
  96555. * 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,
  96556. * which still works and will still be found in many Playgrounds.
  96557. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96558. * @param name Define the name of the camera in the scene
  96559. * @param position Define the start position of the camera in the scene
  96560. * @param scene Define the scene the camera belongs to
  96561. */
  96562. constructor(name: string, position: Vector3, scene: Scene);
  96563. /**
  96564. * Gets the current object class name.
  96565. * @return the class name
  96566. */
  96567. getClassName(): string;
  96568. }
  96569. }
  96570. declare module BABYLON {
  96571. /**
  96572. * This represents a FPS type of camera. This is only here for back compat purpose.
  96573. * Please use the UniversalCamera instead as both are identical.
  96574. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96575. */
  96576. export class GamepadCamera extends UniversalCamera {
  96577. /**
  96578. * Instantiates a new Gamepad Camera
  96579. * This represents a FPS type of camera. This is only here for back compat purpose.
  96580. * Please use the UniversalCamera instead as both are identical.
  96581. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96582. * @param name Define the name of the camera in the scene
  96583. * @param position Define the start position of the camera in the scene
  96584. * @param scene Define the scene the camera belongs to
  96585. */
  96586. constructor(name: string, position: Vector3, scene: Scene);
  96587. /**
  96588. * Gets the current object class name.
  96589. * @return the class name
  96590. */
  96591. getClassName(): string;
  96592. }
  96593. }
  96594. declare module BABYLON {
  96595. /** @hidden */
  96596. export var passPixelShader: {
  96597. name: string;
  96598. shader: string;
  96599. };
  96600. }
  96601. declare module BABYLON {
  96602. /** @hidden */
  96603. export var passCubePixelShader: {
  96604. name: string;
  96605. shader: string;
  96606. };
  96607. }
  96608. declare module BABYLON {
  96609. /**
  96610. * PassPostProcess which produces an output the same as it's input
  96611. */
  96612. export class PassPostProcess extends PostProcess {
  96613. /**
  96614. * Creates the PassPostProcess
  96615. * @param name The name of the effect.
  96616. * @param options The required width/height ratio to downsize to before computing the render pass.
  96617. * @param camera The camera to apply the render pass to.
  96618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96619. * @param engine The engine which the post process will be applied. (default: current engine)
  96620. * @param reusable If the post process can be reused on the same frame. (default: false)
  96621. * @param textureType The type of texture to be used when performing the post processing.
  96622. * @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)
  96623. */
  96624. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96625. }
  96626. /**
  96627. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  96628. */
  96629. export class PassCubePostProcess extends PostProcess {
  96630. private _face;
  96631. /**
  96632. * Gets or sets the cube face to display.
  96633. * * 0 is +X
  96634. * * 1 is -X
  96635. * * 2 is +Y
  96636. * * 3 is -Y
  96637. * * 4 is +Z
  96638. * * 5 is -Z
  96639. */
  96640. face: number;
  96641. /**
  96642. * Creates the PassCubePostProcess
  96643. * @param name The name of the effect.
  96644. * @param options The required width/height ratio to downsize to before computing the render pass.
  96645. * @param camera The camera to apply the render pass to.
  96646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96647. * @param engine The engine which the post process will be applied. (default: current engine)
  96648. * @param reusable If the post process can be reused on the same frame. (default: false)
  96649. * @param textureType The type of texture to be used when performing the post processing.
  96650. * @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)
  96651. */
  96652. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96653. }
  96654. }
  96655. declare module BABYLON {
  96656. /** @hidden */
  96657. export var anaglyphPixelShader: {
  96658. name: string;
  96659. shader: string;
  96660. };
  96661. }
  96662. declare module BABYLON {
  96663. /**
  96664. * Postprocess used to generate anaglyphic rendering
  96665. */
  96666. export class AnaglyphPostProcess extends PostProcess {
  96667. private _passedProcess;
  96668. /**
  96669. * Creates a new AnaglyphPostProcess
  96670. * @param name defines postprocess name
  96671. * @param options defines creation options or target ratio scale
  96672. * @param rigCameras defines cameras using this postprocess
  96673. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  96674. * @param engine defines hosting engine
  96675. * @param reusable defines if the postprocess will be reused multiple times per frame
  96676. */
  96677. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  96678. }
  96679. }
  96680. declare module BABYLON {
  96681. /**
  96682. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  96683. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96684. */
  96685. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  96686. /**
  96687. * Creates a new AnaglyphArcRotateCamera
  96688. * @param name defines camera name
  96689. * @param alpha defines alpha angle (in radians)
  96690. * @param beta defines beta angle (in radians)
  96691. * @param radius defines radius
  96692. * @param target defines camera target
  96693. * @param interaxialDistance defines distance between each color axis
  96694. * @param scene defines the hosting scene
  96695. */
  96696. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  96697. /**
  96698. * Gets camera class name
  96699. * @returns AnaglyphArcRotateCamera
  96700. */
  96701. getClassName(): string;
  96702. }
  96703. }
  96704. declare module BABYLON {
  96705. /**
  96706. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  96707. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96708. */
  96709. export class AnaglyphFreeCamera extends FreeCamera {
  96710. /**
  96711. * Creates a new AnaglyphFreeCamera
  96712. * @param name defines camera name
  96713. * @param position defines initial position
  96714. * @param interaxialDistance defines distance between each color axis
  96715. * @param scene defines the hosting scene
  96716. */
  96717. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96718. /**
  96719. * Gets camera class name
  96720. * @returns AnaglyphFreeCamera
  96721. */
  96722. getClassName(): string;
  96723. }
  96724. }
  96725. declare module BABYLON {
  96726. /**
  96727. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  96728. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96729. */
  96730. export class AnaglyphGamepadCamera extends GamepadCamera {
  96731. /**
  96732. * Creates a new AnaglyphGamepadCamera
  96733. * @param name defines camera name
  96734. * @param position defines initial position
  96735. * @param interaxialDistance defines distance between each color axis
  96736. * @param scene defines the hosting scene
  96737. */
  96738. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96739. /**
  96740. * Gets camera class name
  96741. * @returns AnaglyphGamepadCamera
  96742. */
  96743. getClassName(): string;
  96744. }
  96745. }
  96746. declare module BABYLON {
  96747. /**
  96748. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  96749. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96750. */
  96751. export class AnaglyphUniversalCamera extends UniversalCamera {
  96752. /**
  96753. * Creates a new AnaglyphUniversalCamera
  96754. * @param name defines camera name
  96755. * @param position defines initial position
  96756. * @param interaxialDistance defines distance between each color axis
  96757. * @param scene defines the hosting scene
  96758. */
  96759. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96760. /**
  96761. * Gets camera class name
  96762. * @returns AnaglyphUniversalCamera
  96763. */
  96764. getClassName(): string;
  96765. }
  96766. }
  96767. declare module BABYLON {
  96768. /** @hidden */
  96769. export var stereoscopicInterlacePixelShader: {
  96770. name: string;
  96771. shader: string;
  96772. };
  96773. }
  96774. declare module BABYLON {
  96775. /**
  96776. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  96777. */
  96778. export class StereoscopicInterlacePostProcess extends PostProcess {
  96779. private _stepSize;
  96780. private _passedProcess;
  96781. /**
  96782. * Initializes a StereoscopicInterlacePostProcess
  96783. * @param name The name of the effect.
  96784. * @param rigCameras The rig cameras to be appled to the post process
  96785. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  96786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96787. * @param engine The engine which the post process will be applied. (default: current engine)
  96788. * @param reusable If the post process can be reused on the same frame. (default: false)
  96789. */
  96790. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  96791. }
  96792. }
  96793. declare module BABYLON {
  96794. /**
  96795. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  96796. * @see http://doc.babylonjs.com/features/cameras
  96797. */
  96798. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  96799. /**
  96800. * Creates a new StereoscopicArcRotateCamera
  96801. * @param name defines camera name
  96802. * @param alpha defines alpha angle (in radians)
  96803. * @param beta defines beta angle (in radians)
  96804. * @param radius defines radius
  96805. * @param target defines camera target
  96806. * @param interaxialDistance defines distance between each color axis
  96807. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96808. * @param scene defines the hosting scene
  96809. */
  96810. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96811. /**
  96812. * Gets camera class name
  96813. * @returns StereoscopicArcRotateCamera
  96814. */
  96815. getClassName(): string;
  96816. }
  96817. }
  96818. declare module BABYLON {
  96819. /**
  96820. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  96821. * @see http://doc.babylonjs.com/features/cameras
  96822. */
  96823. export class StereoscopicFreeCamera extends FreeCamera {
  96824. /**
  96825. * Creates a new StereoscopicFreeCamera
  96826. * @param name defines camera name
  96827. * @param position defines initial position
  96828. * @param interaxialDistance defines distance between each color axis
  96829. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96830. * @param scene defines the hosting scene
  96831. */
  96832. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96833. /**
  96834. * Gets camera class name
  96835. * @returns StereoscopicFreeCamera
  96836. */
  96837. getClassName(): string;
  96838. }
  96839. }
  96840. declare module BABYLON {
  96841. /**
  96842. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  96843. * @see http://doc.babylonjs.com/features/cameras
  96844. */
  96845. export class StereoscopicGamepadCamera extends GamepadCamera {
  96846. /**
  96847. * Creates a new StereoscopicGamepadCamera
  96848. * @param name defines camera name
  96849. * @param position defines initial position
  96850. * @param interaxialDistance defines distance between each color axis
  96851. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96852. * @param scene defines the hosting scene
  96853. */
  96854. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96855. /**
  96856. * Gets camera class name
  96857. * @returns StereoscopicGamepadCamera
  96858. */
  96859. getClassName(): string;
  96860. }
  96861. }
  96862. declare module BABYLON {
  96863. /**
  96864. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  96865. * @see http://doc.babylonjs.com/features/cameras
  96866. */
  96867. export class StereoscopicUniversalCamera extends UniversalCamera {
  96868. /**
  96869. * Creates a new StereoscopicUniversalCamera
  96870. * @param name defines camera name
  96871. * @param position defines initial position
  96872. * @param interaxialDistance defines distance between each color axis
  96873. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96874. * @param scene defines the hosting scene
  96875. */
  96876. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96877. /**
  96878. * Gets camera class name
  96879. * @returns StereoscopicUniversalCamera
  96880. */
  96881. getClassName(): string;
  96882. }
  96883. }
  96884. declare module BABYLON {
  96885. /**
  96886. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96887. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96888. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96889. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96890. */
  96891. export class VirtualJoysticksCamera extends FreeCamera {
  96892. /**
  96893. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  96894. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  96895. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  96896. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  96897. * @param name Define the name of the camera in the scene
  96898. * @param position Define the start position of the camera in the scene
  96899. * @param scene Define the scene the camera belongs to
  96900. */
  96901. constructor(name: string, position: Vector3, scene: Scene);
  96902. /**
  96903. * Gets the current object class name.
  96904. * @return the class name
  96905. */
  96906. getClassName(): string;
  96907. }
  96908. }
  96909. declare module BABYLON {
  96910. /**
  96911. * This represents all the required metrics to create a VR camera.
  96912. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  96913. */
  96914. export class VRCameraMetrics {
  96915. /**
  96916. * Define the horizontal resolution off the screen.
  96917. */
  96918. hResolution: number;
  96919. /**
  96920. * Define the vertical resolution off the screen.
  96921. */
  96922. vResolution: number;
  96923. /**
  96924. * Define the horizontal screen size.
  96925. */
  96926. hScreenSize: number;
  96927. /**
  96928. * Define the vertical screen size.
  96929. */
  96930. vScreenSize: number;
  96931. /**
  96932. * Define the vertical screen center position.
  96933. */
  96934. vScreenCenter: number;
  96935. /**
  96936. * Define the distance of the eyes to the screen.
  96937. */
  96938. eyeToScreenDistance: number;
  96939. /**
  96940. * Define the distance between both lenses
  96941. */
  96942. lensSeparationDistance: number;
  96943. /**
  96944. * Define the distance between both viewer's eyes.
  96945. */
  96946. interpupillaryDistance: number;
  96947. /**
  96948. * Define the distortion factor of the VR postprocess.
  96949. * Please, touch with care.
  96950. */
  96951. distortionK: number[];
  96952. /**
  96953. * Define the chromatic aberration correction factors for the VR post process.
  96954. */
  96955. chromaAbCorrection: number[];
  96956. /**
  96957. * Define the scale factor of the post process.
  96958. * The smaller the better but the slower.
  96959. */
  96960. postProcessScaleFactor: number;
  96961. /**
  96962. * Define an offset for the lens center.
  96963. */
  96964. lensCenterOffset: number;
  96965. /**
  96966. * Define if the current vr camera should compensate the distortion of the lense or not.
  96967. */
  96968. compensateDistortion: boolean;
  96969. /**
  96970. * Defines if multiview should be enabled when rendering (Default: false)
  96971. */
  96972. multiviewEnabled: boolean;
  96973. /**
  96974. * Gets the rendering aspect ratio based on the provided resolutions.
  96975. */
  96976. readonly aspectRatio: number;
  96977. /**
  96978. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  96979. */
  96980. readonly aspectRatioFov: number;
  96981. /**
  96982. * @hidden
  96983. */
  96984. readonly leftHMatrix: Matrix;
  96985. /**
  96986. * @hidden
  96987. */
  96988. readonly rightHMatrix: Matrix;
  96989. /**
  96990. * @hidden
  96991. */
  96992. readonly leftPreViewMatrix: Matrix;
  96993. /**
  96994. * @hidden
  96995. */
  96996. readonly rightPreViewMatrix: Matrix;
  96997. /**
  96998. * Get the default VRMetrics based on the most generic setup.
  96999. * @returns the default vr metrics
  97000. */
  97001. static GetDefault(): VRCameraMetrics;
  97002. }
  97003. }
  97004. declare module BABYLON {
  97005. /** @hidden */
  97006. export var vrDistortionCorrectionPixelShader: {
  97007. name: string;
  97008. shader: string;
  97009. };
  97010. }
  97011. declare module BABYLON {
  97012. /**
  97013. * VRDistortionCorrectionPostProcess used for mobile VR
  97014. */
  97015. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97016. private _isRightEye;
  97017. private _distortionFactors;
  97018. private _postProcessScaleFactor;
  97019. private _lensCenterOffset;
  97020. private _scaleIn;
  97021. private _scaleFactor;
  97022. private _lensCenter;
  97023. /**
  97024. * Initializes the VRDistortionCorrectionPostProcess
  97025. * @param name The name of the effect.
  97026. * @param camera The camera to apply the render pass to.
  97027. * @param isRightEye If this is for the right eye distortion
  97028. * @param vrMetrics All the required metrics for the VR camera
  97029. */
  97030. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97031. }
  97032. }
  97033. declare module BABYLON {
  97034. /**
  97035. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97036. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97037. */
  97038. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97039. /**
  97040. * Creates a new VRDeviceOrientationArcRotateCamera
  97041. * @param name defines camera name
  97042. * @param alpha defines the camera rotation along the logitudinal axis
  97043. * @param beta defines the camera rotation along the latitudinal axis
  97044. * @param radius defines the camera distance from its target
  97045. * @param target defines the camera target
  97046. * @param scene defines the scene the camera belongs to
  97047. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97048. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97049. */
  97050. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97051. /**
  97052. * Gets camera class name
  97053. * @returns VRDeviceOrientationArcRotateCamera
  97054. */
  97055. getClassName(): string;
  97056. }
  97057. }
  97058. declare module BABYLON {
  97059. /**
  97060. * Camera used to simulate VR rendering (based on FreeCamera)
  97061. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97062. */
  97063. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97064. /**
  97065. * Creates a new VRDeviceOrientationFreeCamera
  97066. * @param name defines camera name
  97067. * @param position defines the start position of the camera
  97068. * @param scene defines the scene the camera belongs to
  97069. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97070. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97071. */
  97072. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97073. /**
  97074. * Gets camera class name
  97075. * @returns VRDeviceOrientationFreeCamera
  97076. */
  97077. getClassName(): string;
  97078. }
  97079. }
  97080. declare module BABYLON {
  97081. /**
  97082. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97083. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97084. */
  97085. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97086. /**
  97087. * Creates a new VRDeviceOrientationGamepadCamera
  97088. * @param name defines camera name
  97089. * @param position defines the start position of the camera
  97090. * @param scene defines the scene the camera belongs to
  97091. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97092. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97093. */
  97094. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97095. /**
  97096. * Gets camera class name
  97097. * @returns VRDeviceOrientationGamepadCamera
  97098. */
  97099. getClassName(): string;
  97100. }
  97101. }
  97102. declare module BABYLON {
  97103. /**
  97104. * Defines supported buttons for XBox360 compatible gamepads
  97105. */
  97106. export enum Xbox360Button {
  97107. /** A */
  97108. A = 0,
  97109. /** B */
  97110. B = 1,
  97111. /** X */
  97112. X = 2,
  97113. /** Y */
  97114. Y = 3,
  97115. /** Start */
  97116. Start = 4,
  97117. /** Back */
  97118. Back = 5,
  97119. /** Left button */
  97120. LB = 6,
  97121. /** Right button */
  97122. RB = 7,
  97123. /** Left stick */
  97124. LeftStick = 8,
  97125. /** Right stick */
  97126. RightStick = 9
  97127. }
  97128. /** Defines values for XBox360 DPad */
  97129. export enum Xbox360Dpad {
  97130. /** Up */
  97131. Up = 0,
  97132. /** Down */
  97133. Down = 1,
  97134. /** Left */
  97135. Left = 2,
  97136. /** Right */
  97137. Right = 3
  97138. }
  97139. /**
  97140. * Defines a XBox360 gamepad
  97141. */
  97142. export class Xbox360Pad extends Gamepad {
  97143. private _leftTrigger;
  97144. private _rightTrigger;
  97145. private _onlefttriggerchanged;
  97146. private _onrighttriggerchanged;
  97147. private _onbuttondown;
  97148. private _onbuttonup;
  97149. private _ondpaddown;
  97150. private _ondpadup;
  97151. /** Observable raised when a button is pressed */
  97152. onButtonDownObservable: Observable<Xbox360Button>;
  97153. /** Observable raised when a button is released */
  97154. onButtonUpObservable: Observable<Xbox360Button>;
  97155. /** Observable raised when a pad is pressed */
  97156. onPadDownObservable: Observable<Xbox360Dpad>;
  97157. /** Observable raised when a pad is released */
  97158. onPadUpObservable: Observable<Xbox360Dpad>;
  97159. private _buttonA;
  97160. private _buttonB;
  97161. private _buttonX;
  97162. private _buttonY;
  97163. private _buttonBack;
  97164. private _buttonStart;
  97165. private _buttonLB;
  97166. private _buttonRB;
  97167. private _buttonLeftStick;
  97168. private _buttonRightStick;
  97169. private _dPadUp;
  97170. private _dPadDown;
  97171. private _dPadLeft;
  97172. private _dPadRight;
  97173. private _isXboxOnePad;
  97174. /**
  97175. * Creates a new XBox360 gamepad object
  97176. * @param id defines the id of this gamepad
  97177. * @param index defines its index
  97178. * @param gamepad defines the internal HTML gamepad object
  97179. * @param xboxOne defines if it is a XBox One gamepad
  97180. */
  97181. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  97182. /**
  97183. * Defines the callback to call when left trigger is pressed
  97184. * @param callback defines the callback to use
  97185. */
  97186. onlefttriggerchanged(callback: (value: number) => void): void;
  97187. /**
  97188. * Defines the callback to call when right trigger is pressed
  97189. * @param callback defines the callback to use
  97190. */
  97191. onrighttriggerchanged(callback: (value: number) => void): void;
  97192. /**
  97193. * Gets the left trigger value
  97194. */
  97195. /**
  97196. * Sets the left trigger value
  97197. */
  97198. leftTrigger: number;
  97199. /**
  97200. * Gets the right trigger value
  97201. */
  97202. /**
  97203. * Sets the right trigger value
  97204. */
  97205. rightTrigger: number;
  97206. /**
  97207. * Defines the callback to call when a button is pressed
  97208. * @param callback defines the callback to use
  97209. */
  97210. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  97211. /**
  97212. * Defines the callback to call when a button is released
  97213. * @param callback defines the callback to use
  97214. */
  97215. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  97216. /**
  97217. * Defines the callback to call when a pad is pressed
  97218. * @param callback defines the callback to use
  97219. */
  97220. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  97221. /**
  97222. * Defines the callback to call when a pad is released
  97223. * @param callback defines the callback to use
  97224. */
  97225. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  97226. private _setButtonValue;
  97227. private _setDPadValue;
  97228. /**
  97229. * Gets the value of the `A` button
  97230. */
  97231. /**
  97232. * Sets the value of the `A` button
  97233. */
  97234. buttonA: number;
  97235. /**
  97236. * Gets the value of the `B` button
  97237. */
  97238. /**
  97239. * Sets the value of the `B` button
  97240. */
  97241. buttonB: number;
  97242. /**
  97243. * Gets the value of the `X` button
  97244. */
  97245. /**
  97246. * Sets the value of the `X` button
  97247. */
  97248. buttonX: number;
  97249. /**
  97250. * Gets the value of the `Y` button
  97251. */
  97252. /**
  97253. * Sets the value of the `Y` button
  97254. */
  97255. buttonY: number;
  97256. /**
  97257. * Gets the value of the `Start` button
  97258. */
  97259. /**
  97260. * Sets the value of the `Start` button
  97261. */
  97262. buttonStart: number;
  97263. /**
  97264. * Gets the value of the `Back` button
  97265. */
  97266. /**
  97267. * Sets the value of the `Back` button
  97268. */
  97269. buttonBack: number;
  97270. /**
  97271. * Gets the value of the `Left` button
  97272. */
  97273. /**
  97274. * Sets the value of the `Left` button
  97275. */
  97276. buttonLB: number;
  97277. /**
  97278. * Gets the value of the `Right` button
  97279. */
  97280. /**
  97281. * Sets the value of the `Right` button
  97282. */
  97283. buttonRB: number;
  97284. /**
  97285. * Gets the value of the Left joystick
  97286. */
  97287. /**
  97288. * Sets the value of the Left joystick
  97289. */
  97290. buttonLeftStick: number;
  97291. /**
  97292. * Gets the value of the Right joystick
  97293. */
  97294. /**
  97295. * Sets the value of the Right joystick
  97296. */
  97297. buttonRightStick: number;
  97298. /**
  97299. * Gets the value of D-pad up
  97300. */
  97301. /**
  97302. * Sets the value of D-pad up
  97303. */
  97304. dPadUp: number;
  97305. /**
  97306. * Gets the value of D-pad down
  97307. */
  97308. /**
  97309. * Sets the value of D-pad down
  97310. */
  97311. dPadDown: number;
  97312. /**
  97313. * Gets the value of D-pad left
  97314. */
  97315. /**
  97316. * Sets the value of D-pad left
  97317. */
  97318. dPadLeft: number;
  97319. /**
  97320. * Gets the value of D-pad right
  97321. */
  97322. /**
  97323. * Sets the value of D-pad right
  97324. */
  97325. dPadRight: number;
  97326. /**
  97327. * Force the gamepad to synchronize with device values
  97328. */
  97329. update(): void;
  97330. /**
  97331. * Disposes the gamepad
  97332. */
  97333. dispose(): void;
  97334. }
  97335. }
  97336. declare module BABYLON {
  97337. /**
  97338. * Base class of materials working in push mode in babylon JS
  97339. * @hidden
  97340. */
  97341. export class PushMaterial extends Material {
  97342. protected _activeEffect: Effect;
  97343. protected _normalMatrix: Matrix;
  97344. /**
  97345. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  97346. * This means that the material can keep using a previous shader while a new one is being compiled.
  97347. * This is mostly used when shader parallel compilation is supported (true by default)
  97348. */
  97349. allowShaderHotSwapping: boolean;
  97350. constructor(name: string, scene: Scene);
  97351. getEffect(): Effect;
  97352. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97353. /**
  97354. * Binds the given world matrix to the active effect
  97355. *
  97356. * @param world the matrix to bind
  97357. */
  97358. bindOnlyWorldMatrix(world: Matrix): void;
  97359. /**
  97360. * Binds the given normal matrix to the active effect
  97361. *
  97362. * @param normalMatrix the matrix to bind
  97363. */
  97364. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  97365. bind(world: Matrix, mesh?: Mesh): void;
  97366. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  97367. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  97368. }
  97369. }
  97370. declare module BABYLON {
  97371. /**
  97372. * This groups all the flags used to control the materials channel.
  97373. */
  97374. export class MaterialFlags {
  97375. private static _DiffuseTextureEnabled;
  97376. /**
  97377. * Are diffuse textures enabled in the application.
  97378. */
  97379. static DiffuseTextureEnabled: boolean;
  97380. private static _AmbientTextureEnabled;
  97381. /**
  97382. * Are ambient textures enabled in the application.
  97383. */
  97384. static AmbientTextureEnabled: boolean;
  97385. private static _OpacityTextureEnabled;
  97386. /**
  97387. * Are opacity textures enabled in the application.
  97388. */
  97389. static OpacityTextureEnabled: boolean;
  97390. private static _ReflectionTextureEnabled;
  97391. /**
  97392. * Are reflection textures enabled in the application.
  97393. */
  97394. static ReflectionTextureEnabled: boolean;
  97395. private static _EmissiveTextureEnabled;
  97396. /**
  97397. * Are emissive textures enabled in the application.
  97398. */
  97399. static EmissiveTextureEnabled: boolean;
  97400. private static _SpecularTextureEnabled;
  97401. /**
  97402. * Are specular textures enabled in the application.
  97403. */
  97404. static SpecularTextureEnabled: boolean;
  97405. private static _BumpTextureEnabled;
  97406. /**
  97407. * Are bump textures enabled in the application.
  97408. */
  97409. static BumpTextureEnabled: boolean;
  97410. private static _LightmapTextureEnabled;
  97411. /**
  97412. * Are lightmap textures enabled in the application.
  97413. */
  97414. static LightmapTextureEnabled: boolean;
  97415. private static _RefractionTextureEnabled;
  97416. /**
  97417. * Are refraction textures enabled in the application.
  97418. */
  97419. static RefractionTextureEnabled: boolean;
  97420. private static _ColorGradingTextureEnabled;
  97421. /**
  97422. * Are color grading textures enabled in the application.
  97423. */
  97424. static ColorGradingTextureEnabled: boolean;
  97425. private static _FresnelEnabled;
  97426. /**
  97427. * Are fresnels enabled in the application.
  97428. */
  97429. static FresnelEnabled: boolean;
  97430. private static _ClearCoatTextureEnabled;
  97431. /**
  97432. * Are clear coat textures enabled in the application.
  97433. */
  97434. static ClearCoatTextureEnabled: boolean;
  97435. private static _ClearCoatBumpTextureEnabled;
  97436. /**
  97437. * Are clear coat bump textures enabled in the application.
  97438. */
  97439. static ClearCoatBumpTextureEnabled: boolean;
  97440. private static _ClearCoatTintTextureEnabled;
  97441. /**
  97442. * Are clear coat tint textures enabled in the application.
  97443. */
  97444. static ClearCoatTintTextureEnabled: boolean;
  97445. private static _SheenTextureEnabled;
  97446. /**
  97447. * Are sheen textures enabled in the application.
  97448. */
  97449. static SheenTextureEnabled: boolean;
  97450. private static _AnisotropicTextureEnabled;
  97451. /**
  97452. * Are anisotropic textures enabled in the application.
  97453. */
  97454. static AnisotropicTextureEnabled: boolean;
  97455. private static _ThicknessTextureEnabled;
  97456. /**
  97457. * Are thickness textures enabled in the application.
  97458. */
  97459. static ThicknessTextureEnabled: boolean;
  97460. }
  97461. }
  97462. declare module BABYLON {
  97463. /** @hidden */
  97464. export var defaultFragmentDeclaration: {
  97465. name: string;
  97466. shader: string;
  97467. };
  97468. }
  97469. declare module BABYLON {
  97470. /** @hidden */
  97471. export var defaultUboDeclaration: {
  97472. name: string;
  97473. shader: string;
  97474. };
  97475. }
  97476. declare module BABYLON {
  97477. /** @hidden */
  97478. export var lightFragmentDeclaration: {
  97479. name: string;
  97480. shader: string;
  97481. };
  97482. }
  97483. declare module BABYLON {
  97484. /** @hidden */
  97485. export var lightUboDeclaration: {
  97486. name: string;
  97487. shader: string;
  97488. };
  97489. }
  97490. declare module BABYLON {
  97491. /** @hidden */
  97492. export var lightsFragmentFunctions: {
  97493. name: string;
  97494. shader: string;
  97495. };
  97496. }
  97497. declare module BABYLON {
  97498. /** @hidden */
  97499. export var shadowsFragmentFunctions: {
  97500. name: string;
  97501. shader: string;
  97502. };
  97503. }
  97504. declare module BABYLON {
  97505. /** @hidden */
  97506. export var fresnelFunction: {
  97507. name: string;
  97508. shader: string;
  97509. };
  97510. }
  97511. declare module BABYLON {
  97512. /** @hidden */
  97513. export var reflectionFunction: {
  97514. name: string;
  97515. shader: string;
  97516. };
  97517. }
  97518. declare module BABYLON {
  97519. /** @hidden */
  97520. export var bumpFragmentFunctions: {
  97521. name: string;
  97522. shader: string;
  97523. };
  97524. }
  97525. declare module BABYLON {
  97526. /** @hidden */
  97527. export var logDepthDeclaration: {
  97528. name: string;
  97529. shader: string;
  97530. };
  97531. }
  97532. declare module BABYLON {
  97533. /** @hidden */
  97534. export var bumpFragment: {
  97535. name: string;
  97536. shader: string;
  97537. };
  97538. }
  97539. declare module BABYLON {
  97540. /** @hidden */
  97541. export var depthPrePass: {
  97542. name: string;
  97543. shader: string;
  97544. };
  97545. }
  97546. declare module BABYLON {
  97547. /** @hidden */
  97548. export var lightFragment: {
  97549. name: string;
  97550. shader: string;
  97551. };
  97552. }
  97553. declare module BABYLON {
  97554. /** @hidden */
  97555. export var logDepthFragment: {
  97556. name: string;
  97557. shader: string;
  97558. };
  97559. }
  97560. declare module BABYLON {
  97561. /** @hidden */
  97562. export var defaultPixelShader: {
  97563. name: string;
  97564. shader: string;
  97565. };
  97566. }
  97567. declare module BABYLON {
  97568. /** @hidden */
  97569. export var defaultVertexDeclaration: {
  97570. name: string;
  97571. shader: string;
  97572. };
  97573. }
  97574. declare module BABYLON {
  97575. /** @hidden */
  97576. export var bumpVertexDeclaration: {
  97577. name: string;
  97578. shader: string;
  97579. };
  97580. }
  97581. declare module BABYLON {
  97582. /** @hidden */
  97583. export var bumpVertex: {
  97584. name: string;
  97585. shader: string;
  97586. };
  97587. }
  97588. declare module BABYLON {
  97589. /** @hidden */
  97590. export var fogVertex: {
  97591. name: string;
  97592. shader: string;
  97593. };
  97594. }
  97595. declare module BABYLON {
  97596. /** @hidden */
  97597. export var shadowsVertex: {
  97598. name: string;
  97599. shader: string;
  97600. };
  97601. }
  97602. declare module BABYLON {
  97603. /** @hidden */
  97604. export var pointCloudVertex: {
  97605. name: string;
  97606. shader: string;
  97607. };
  97608. }
  97609. declare module BABYLON {
  97610. /** @hidden */
  97611. export var logDepthVertex: {
  97612. name: string;
  97613. shader: string;
  97614. };
  97615. }
  97616. declare module BABYLON {
  97617. /** @hidden */
  97618. export var defaultVertexShader: {
  97619. name: string;
  97620. shader: string;
  97621. };
  97622. }
  97623. declare module BABYLON {
  97624. /** @hidden */
  97625. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  97626. MAINUV1: boolean;
  97627. MAINUV2: boolean;
  97628. DIFFUSE: boolean;
  97629. DIFFUSEDIRECTUV: number;
  97630. AMBIENT: boolean;
  97631. AMBIENTDIRECTUV: number;
  97632. OPACITY: boolean;
  97633. OPACITYDIRECTUV: number;
  97634. OPACITYRGB: boolean;
  97635. REFLECTION: boolean;
  97636. EMISSIVE: boolean;
  97637. EMISSIVEDIRECTUV: number;
  97638. SPECULAR: boolean;
  97639. SPECULARDIRECTUV: number;
  97640. BUMP: boolean;
  97641. BUMPDIRECTUV: number;
  97642. PARALLAX: boolean;
  97643. PARALLAXOCCLUSION: boolean;
  97644. SPECULAROVERALPHA: boolean;
  97645. CLIPPLANE: boolean;
  97646. CLIPPLANE2: boolean;
  97647. CLIPPLANE3: boolean;
  97648. CLIPPLANE4: boolean;
  97649. ALPHATEST: boolean;
  97650. DEPTHPREPASS: boolean;
  97651. ALPHAFROMDIFFUSE: boolean;
  97652. POINTSIZE: boolean;
  97653. FOG: boolean;
  97654. SPECULARTERM: boolean;
  97655. DIFFUSEFRESNEL: boolean;
  97656. OPACITYFRESNEL: boolean;
  97657. REFLECTIONFRESNEL: boolean;
  97658. REFRACTIONFRESNEL: boolean;
  97659. EMISSIVEFRESNEL: boolean;
  97660. FRESNEL: boolean;
  97661. NORMAL: boolean;
  97662. UV1: boolean;
  97663. UV2: boolean;
  97664. VERTEXCOLOR: boolean;
  97665. VERTEXALPHA: boolean;
  97666. NUM_BONE_INFLUENCERS: number;
  97667. BonesPerMesh: number;
  97668. BONETEXTURE: boolean;
  97669. INSTANCES: boolean;
  97670. GLOSSINESS: boolean;
  97671. ROUGHNESS: boolean;
  97672. EMISSIVEASILLUMINATION: boolean;
  97673. LINKEMISSIVEWITHDIFFUSE: boolean;
  97674. REFLECTIONFRESNELFROMSPECULAR: boolean;
  97675. LIGHTMAP: boolean;
  97676. LIGHTMAPDIRECTUV: number;
  97677. OBJECTSPACE_NORMALMAP: boolean;
  97678. USELIGHTMAPASSHADOWMAP: boolean;
  97679. REFLECTIONMAP_3D: boolean;
  97680. REFLECTIONMAP_SPHERICAL: boolean;
  97681. REFLECTIONMAP_PLANAR: boolean;
  97682. REFLECTIONMAP_CUBIC: boolean;
  97683. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  97684. REFLECTIONMAP_PROJECTION: boolean;
  97685. REFLECTIONMAP_SKYBOX: boolean;
  97686. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  97687. REFLECTIONMAP_EXPLICIT: boolean;
  97688. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  97689. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  97690. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  97691. INVERTCUBICMAP: boolean;
  97692. LOGARITHMICDEPTH: boolean;
  97693. REFRACTION: boolean;
  97694. REFRACTIONMAP_3D: boolean;
  97695. REFLECTIONOVERALPHA: boolean;
  97696. TWOSIDEDLIGHTING: boolean;
  97697. SHADOWFLOAT: boolean;
  97698. MORPHTARGETS: boolean;
  97699. MORPHTARGETS_NORMAL: boolean;
  97700. MORPHTARGETS_TANGENT: boolean;
  97701. NUM_MORPH_INFLUENCERS: number;
  97702. NONUNIFORMSCALING: boolean;
  97703. PREMULTIPLYALPHA: boolean;
  97704. IMAGEPROCESSING: boolean;
  97705. VIGNETTE: boolean;
  97706. VIGNETTEBLENDMODEMULTIPLY: boolean;
  97707. VIGNETTEBLENDMODEOPAQUE: boolean;
  97708. TONEMAPPING: boolean;
  97709. TONEMAPPING_ACES: boolean;
  97710. CONTRAST: boolean;
  97711. COLORCURVES: boolean;
  97712. COLORGRADING: boolean;
  97713. COLORGRADING3D: boolean;
  97714. SAMPLER3DGREENDEPTH: boolean;
  97715. SAMPLER3DBGRMAP: boolean;
  97716. IMAGEPROCESSINGPOSTPROCESS: boolean;
  97717. MULTIVIEW: boolean;
  97718. /**
  97719. * If the reflection texture on this material is in linear color space
  97720. * @hidden
  97721. */
  97722. IS_REFLECTION_LINEAR: boolean;
  97723. /**
  97724. * If the refraction texture on this material is in linear color space
  97725. * @hidden
  97726. */
  97727. IS_REFRACTION_LINEAR: boolean;
  97728. EXPOSURE: boolean;
  97729. constructor();
  97730. setReflectionMode(modeToEnable: string): void;
  97731. }
  97732. /**
  97733. * This is the default material used in Babylon. It is the best trade off between quality
  97734. * and performances.
  97735. * @see http://doc.babylonjs.com/babylon101/materials
  97736. */
  97737. export class StandardMaterial extends PushMaterial {
  97738. private _diffuseTexture;
  97739. /**
  97740. * The basic texture of the material as viewed under a light.
  97741. */
  97742. diffuseTexture: Nullable<BaseTexture>;
  97743. private _ambientTexture;
  97744. /**
  97745. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  97746. */
  97747. ambientTexture: Nullable<BaseTexture>;
  97748. private _opacityTexture;
  97749. /**
  97750. * Define the transparency of the material from a texture.
  97751. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  97752. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  97753. */
  97754. opacityTexture: Nullable<BaseTexture>;
  97755. private _reflectionTexture;
  97756. /**
  97757. * Define the texture used to display the reflection.
  97758. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97759. */
  97760. reflectionTexture: Nullable<BaseTexture>;
  97761. private _emissiveTexture;
  97762. /**
  97763. * Define texture of the material as if self lit.
  97764. * This will be mixed in the final result even in the absence of light.
  97765. */
  97766. emissiveTexture: Nullable<BaseTexture>;
  97767. private _specularTexture;
  97768. /**
  97769. * Define how the color and intensity of the highlight given by the light in the material.
  97770. */
  97771. specularTexture: Nullable<BaseTexture>;
  97772. private _bumpTexture;
  97773. /**
  97774. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  97775. * 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.
  97776. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  97777. */
  97778. bumpTexture: Nullable<BaseTexture>;
  97779. private _lightmapTexture;
  97780. /**
  97781. * Complex lighting can be computationally expensive to compute at runtime.
  97782. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  97783. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  97784. */
  97785. lightmapTexture: Nullable<BaseTexture>;
  97786. private _refractionTexture;
  97787. /**
  97788. * Define the texture used to display the refraction.
  97789. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97790. */
  97791. refractionTexture: Nullable<BaseTexture>;
  97792. /**
  97793. * The color of the material lit by the environmental background lighting.
  97794. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  97795. */
  97796. ambientColor: Color3;
  97797. /**
  97798. * The basic color of the material as viewed under a light.
  97799. */
  97800. diffuseColor: Color3;
  97801. /**
  97802. * Define how the color and intensity of the highlight given by the light in the material.
  97803. */
  97804. specularColor: Color3;
  97805. /**
  97806. * Define the color of the material as if self lit.
  97807. * This will be mixed in the final result even in the absence of light.
  97808. */
  97809. emissiveColor: Color3;
  97810. /**
  97811. * Defines how sharp are the highlights in the material.
  97812. * The bigger the value the sharper giving a more glossy feeling to the result.
  97813. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  97814. */
  97815. specularPower: number;
  97816. private _useAlphaFromDiffuseTexture;
  97817. /**
  97818. * Does the transparency come from the diffuse texture alpha channel.
  97819. */
  97820. useAlphaFromDiffuseTexture: boolean;
  97821. private _useEmissiveAsIllumination;
  97822. /**
  97823. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  97824. */
  97825. useEmissiveAsIllumination: boolean;
  97826. private _linkEmissiveWithDiffuse;
  97827. /**
  97828. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  97829. * the emissive level when the final color is close to one.
  97830. */
  97831. linkEmissiveWithDiffuse: boolean;
  97832. private _useSpecularOverAlpha;
  97833. /**
  97834. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  97835. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  97836. */
  97837. useSpecularOverAlpha: boolean;
  97838. private _useReflectionOverAlpha;
  97839. /**
  97840. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  97841. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  97842. */
  97843. useReflectionOverAlpha: boolean;
  97844. private _disableLighting;
  97845. /**
  97846. * Does lights from the scene impacts this material.
  97847. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  97848. */
  97849. disableLighting: boolean;
  97850. private _useObjectSpaceNormalMap;
  97851. /**
  97852. * Allows using an object space normal map (instead of tangent space).
  97853. */
  97854. useObjectSpaceNormalMap: boolean;
  97855. private _useParallax;
  97856. /**
  97857. * Is parallax enabled or not.
  97858. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97859. */
  97860. useParallax: boolean;
  97861. private _useParallaxOcclusion;
  97862. /**
  97863. * Is parallax occlusion enabled or not.
  97864. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  97865. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97866. */
  97867. useParallaxOcclusion: boolean;
  97868. /**
  97869. * 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.
  97870. */
  97871. parallaxScaleBias: number;
  97872. private _roughness;
  97873. /**
  97874. * Helps to define how blurry the reflections should appears in the material.
  97875. */
  97876. roughness: number;
  97877. /**
  97878. * In case of refraction, define the value of the indice of refraction.
  97879. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97880. */
  97881. indexOfRefraction: number;
  97882. /**
  97883. * Invert the refraction texture alongside the y axis.
  97884. * It can be useful with procedural textures or probe for instance.
  97885. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97886. */
  97887. invertRefractionY: boolean;
  97888. /**
  97889. * Defines the alpha limits in alpha test mode.
  97890. */
  97891. alphaCutOff: number;
  97892. private _useLightmapAsShadowmap;
  97893. /**
  97894. * In case of light mapping, define whether the map contains light or shadow informations.
  97895. */
  97896. useLightmapAsShadowmap: boolean;
  97897. private _diffuseFresnelParameters;
  97898. /**
  97899. * Define the diffuse fresnel parameters of the material.
  97900. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97901. */
  97902. diffuseFresnelParameters: FresnelParameters;
  97903. private _opacityFresnelParameters;
  97904. /**
  97905. * Define the opacity fresnel parameters of the material.
  97906. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97907. */
  97908. opacityFresnelParameters: FresnelParameters;
  97909. private _reflectionFresnelParameters;
  97910. /**
  97911. * Define the reflection fresnel parameters of the material.
  97912. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97913. */
  97914. reflectionFresnelParameters: FresnelParameters;
  97915. private _refractionFresnelParameters;
  97916. /**
  97917. * Define the refraction fresnel parameters of the material.
  97918. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97919. */
  97920. refractionFresnelParameters: FresnelParameters;
  97921. private _emissiveFresnelParameters;
  97922. /**
  97923. * Define the emissive fresnel parameters of the material.
  97924. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97925. */
  97926. emissiveFresnelParameters: FresnelParameters;
  97927. private _useReflectionFresnelFromSpecular;
  97928. /**
  97929. * If true automatically deducts the fresnels values from the material specularity.
  97930. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97931. */
  97932. useReflectionFresnelFromSpecular: boolean;
  97933. private _useGlossinessFromSpecularMapAlpha;
  97934. /**
  97935. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  97936. */
  97937. useGlossinessFromSpecularMapAlpha: boolean;
  97938. private _maxSimultaneousLights;
  97939. /**
  97940. * Defines the maximum number of lights that can be used in the material
  97941. */
  97942. maxSimultaneousLights: number;
  97943. private _invertNormalMapX;
  97944. /**
  97945. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  97946. */
  97947. invertNormalMapX: boolean;
  97948. private _invertNormalMapY;
  97949. /**
  97950. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  97951. */
  97952. invertNormalMapY: boolean;
  97953. private _twoSidedLighting;
  97954. /**
  97955. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  97956. */
  97957. twoSidedLighting: boolean;
  97958. /**
  97959. * Default configuration related to image processing available in the standard Material.
  97960. */
  97961. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97962. /**
  97963. * Gets the image processing configuration used either in this material.
  97964. */
  97965. /**
  97966. * Sets the Default image processing configuration used either in the this material.
  97967. *
  97968. * If sets to null, the scene one is in use.
  97969. */
  97970. imageProcessingConfiguration: ImageProcessingConfiguration;
  97971. /**
  97972. * Keep track of the image processing observer to allow dispose and replace.
  97973. */
  97974. private _imageProcessingObserver;
  97975. /**
  97976. * Attaches a new image processing configuration to the Standard Material.
  97977. * @param configuration
  97978. */
  97979. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  97980. /**
  97981. * Gets wether the color curves effect is enabled.
  97982. */
  97983. /**
  97984. * Sets wether the color curves effect is enabled.
  97985. */
  97986. cameraColorCurvesEnabled: boolean;
  97987. /**
  97988. * Gets wether the color grading effect is enabled.
  97989. */
  97990. /**
  97991. * Gets wether the color grading effect is enabled.
  97992. */
  97993. cameraColorGradingEnabled: boolean;
  97994. /**
  97995. * Gets wether tonemapping is enabled or not.
  97996. */
  97997. /**
  97998. * Sets wether tonemapping is enabled or not
  97999. */
  98000. cameraToneMappingEnabled: boolean;
  98001. /**
  98002. * The camera exposure used on this material.
  98003. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98004. * This corresponds to a photographic exposure.
  98005. */
  98006. /**
  98007. * The camera exposure used on this material.
  98008. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98009. * This corresponds to a photographic exposure.
  98010. */
  98011. cameraExposure: number;
  98012. /**
  98013. * Gets The camera contrast used on this material.
  98014. */
  98015. /**
  98016. * Sets The camera contrast used on this material.
  98017. */
  98018. cameraContrast: number;
  98019. /**
  98020. * Gets the Color Grading 2D Lookup Texture.
  98021. */
  98022. /**
  98023. * Sets the Color Grading 2D Lookup Texture.
  98024. */
  98025. cameraColorGradingTexture: Nullable<BaseTexture>;
  98026. /**
  98027. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98028. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98029. * 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;
  98030. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98031. */
  98032. /**
  98033. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98034. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98035. * 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;
  98036. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98037. */
  98038. cameraColorCurves: Nullable<ColorCurves>;
  98039. /**
  98040. * Custom callback helping to override the default shader used in the material.
  98041. */
  98042. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98043. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98044. protected _worldViewProjectionMatrix: Matrix;
  98045. protected _globalAmbientColor: Color3;
  98046. protected _useLogarithmicDepth: boolean;
  98047. /**
  98048. * Instantiates a new standard material.
  98049. * This is the default material used in Babylon. It is the best trade off between quality
  98050. * and performances.
  98051. * @see http://doc.babylonjs.com/babylon101/materials
  98052. * @param name Define the name of the material in the scene
  98053. * @param scene Define the scene the material belong to
  98054. */
  98055. constructor(name: string, scene: Scene);
  98056. /**
  98057. * Gets a boolean indicating that current material needs to register RTT
  98058. */
  98059. readonly hasRenderTargetTextures: boolean;
  98060. /**
  98061. * Gets the current class name of the material e.g. "StandardMaterial"
  98062. * Mainly use in serialization.
  98063. * @returns the class name
  98064. */
  98065. getClassName(): string;
  98066. /**
  98067. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98068. * You can try switching to logarithmic depth.
  98069. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98070. */
  98071. useLogarithmicDepth: boolean;
  98072. /**
  98073. * Specifies if the material will require alpha blending
  98074. * @returns a boolean specifying if alpha blending is needed
  98075. */
  98076. needAlphaBlending(): boolean;
  98077. /**
  98078. * Specifies if this material should be rendered in alpha test mode
  98079. * @returns a boolean specifying if an alpha test is needed.
  98080. */
  98081. needAlphaTesting(): boolean;
  98082. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98083. /**
  98084. * Get the texture used for alpha test purpose.
  98085. * @returns the diffuse texture in case of the standard material.
  98086. */
  98087. getAlphaTestTexture(): Nullable<BaseTexture>;
  98088. /**
  98089. * Get if the submesh is ready to be used and all its information available.
  98090. * Child classes can use it to update shaders
  98091. * @param mesh defines the mesh to check
  98092. * @param subMesh defines which submesh to check
  98093. * @param useInstances specifies that instances should be used
  98094. * @returns a boolean indicating that the submesh is ready or not
  98095. */
  98096. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98097. /**
  98098. * Builds the material UBO layouts.
  98099. * Used internally during the effect preparation.
  98100. */
  98101. buildUniformLayout(): void;
  98102. /**
  98103. * Unbinds the material from the mesh
  98104. */
  98105. unbind(): void;
  98106. /**
  98107. * Binds the submesh to this material by preparing the effect and shader to draw
  98108. * @param world defines the world transformation matrix
  98109. * @param mesh defines the mesh containing the submesh
  98110. * @param subMesh defines the submesh to bind the material to
  98111. */
  98112. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98113. /**
  98114. * Get the list of animatables in the material.
  98115. * @returns the list of animatables object used in the material
  98116. */
  98117. getAnimatables(): IAnimatable[];
  98118. /**
  98119. * Gets the active textures from the material
  98120. * @returns an array of textures
  98121. */
  98122. getActiveTextures(): BaseTexture[];
  98123. /**
  98124. * Specifies if the material uses a texture
  98125. * @param texture defines the texture to check against the material
  98126. * @returns a boolean specifying if the material uses the texture
  98127. */
  98128. hasTexture(texture: BaseTexture): boolean;
  98129. /**
  98130. * Disposes the material
  98131. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98132. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98133. */
  98134. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98135. /**
  98136. * Makes a duplicate of the material, and gives it a new name
  98137. * @param name defines the new name for the duplicated material
  98138. * @returns the cloned material
  98139. */
  98140. clone(name: string): StandardMaterial;
  98141. /**
  98142. * Serializes this material in a JSON representation
  98143. * @returns the serialized material object
  98144. */
  98145. serialize(): any;
  98146. /**
  98147. * Creates a standard material from parsed material data
  98148. * @param source defines the JSON representation of the material
  98149. * @param scene defines the hosting scene
  98150. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98151. * @returns a new standard material
  98152. */
  98153. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98154. /**
  98155. * Are diffuse textures enabled in the application.
  98156. */
  98157. static DiffuseTextureEnabled: boolean;
  98158. /**
  98159. * Are ambient textures enabled in the application.
  98160. */
  98161. static AmbientTextureEnabled: boolean;
  98162. /**
  98163. * Are opacity textures enabled in the application.
  98164. */
  98165. static OpacityTextureEnabled: boolean;
  98166. /**
  98167. * Are reflection textures enabled in the application.
  98168. */
  98169. static ReflectionTextureEnabled: boolean;
  98170. /**
  98171. * Are emissive textures enabled in the application.
  98172. */
  98173. static EmissiveTextureEnabled: boolean;
  98174. /**
  98175. * Are specular textures enabled in the application.
  98176. */
  98177. static SpecularTextureEnabled: boolean;
  98178. /**
  98179. * Are bump textures enabled in the application.
  98180. */
  98181. static BumpTextureEnabled: boolean;
  98182. /**
  98183. * Are lightmap textures enabled in the application.
  98184. */
  98185. static LightmapTextureEnabled: boolean;
  98186. /**
  98187. * Are refraction textures enabled in the application.
  98188. */
  98189. static RefractionTextureEnabled: boolean;
  98190. /**
  98191. * Are color grading textures enabled in the application.
  98192. */
  98193. static ColorGradingTextureEnabled: boolean;
  98194. /**
  98195. * Are fresnels enabled in the application.
  98196. */
  98197. static FresnelEnabled: boolean;
  98198. }
  98199. }
  98200. declare module BABYLON {
  98201. /**
  98202. * A class extending Texture allowing drawing on a texture
  98203. * @see http://doc.babylonjs.com/how_to/dynamictexture
  98204. */
  98205. export class DynamicTexture extends Texture {
  98206. private _generateMipMaps;
  98207. private _canvas;
  98208. private _context;
  98209. private _engine;
  98210. /**
  98211. * Creates a DynamicTexture
  98212. * @param name defines the name of the texture
  98213. * @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
  98214. * @param scene defines the scene where you want the texture
  98215. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  98216. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  98217. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  98218. */
  98219. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  98220. /**
  98221. * Get the current class name of the texture useful for serialization or dynamic coding.
  98222. * @returns "DynamicTexture"
  98223. */
  98224. getClassName(): string;
  98225. /**
  98226. * Gets the current state of canRescale
  98227. */
  98228. readonly canRescale: boolean;
  98229. private _recreate;
  98230. /**
  98231. * Scales the texture
  98232. * @param ratio the scale factor to apply to both width and height
  98233. */
  98234. scale(ratio: number): void;
  98235. /**
  98236. * Resizes the texture
  98237. * @param width the new width
  98238. * @param height the new height
  98239. */
  98240. scaleTo(width: number, height: number): void;
  98241. /**
  98242. * Gets the context of the canvas used by the texture
  98243. * @returns the canvas context of the dynamic texture
  98244. */
  98245. getContext(): CanvasRenderingContext2D;
  98246. /**
  98247. * Clears the texture
  98248. */
  98249. clear(): void;
  98250. /**
  98251. * Updates the texture
  98252. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98253. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  98254. */
  98255. update(invertY?: boolean, premulAlpha?: boolean): void;
  98256. /**
  98257. * Draws text onto the texture
  98258. * @param text defines the text to be drawn
  98259. * @param x defines the placement of the text from the left
  98260. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  98261. * @param font defines the font to be used with font-style, font-size, font-name
  98262. * @param color defines the color used for the text
  98263. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  98264. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98265. * @param update defines whether texture is immediately update (default is true)
  98266. */
  98267. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  98268. /**
  98269. * Clones the texture
  98270. * @returns the clone of the texture.
  98271. */
  98272. clone(): DynamicTexture;
  98273. /**
  98274. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  98275. * @returns a serialized dynamic texture object
  98276. */
  98277. serialize(): any;
  98278. /** @hidden */
  98279. _rebuild(): void;
  98280. }
  98281. }
  98282. declare module BABYLON {
  98283. /** @hidden */
  98284. export var imageProcessingPixelShader: {
  98285. name: string;
  98286. shader: string;
  98287. };
  98288. }
  98289. declare module BABYLON {
  98290. /**
  98291. * ImageProcessingPostProcess
  98292. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  98293. */
  98294. export class ImageProcessingPostProcess extends PostProcess {
  98295. /**
  98296. * Default configuration related to image processing available in the PBR Material.
  98297. */
  98298. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98299. /**
  98300. * Gets the image processing configuration used either in this material.
  98301. */
  98302. /**
  98303. * Sets the Default image processing configuration used either in the this material.
  98304. *
  98305. * If sets to null, the scene one is in use.
  98306. */
  98307. imageProcessingConfiguration: ImageProcessingConfiguration;
  98308. /**
  98309. * Keep track of the image processing observer to allow dispose and replace.
  98310. */
  98311. private _imageProcessingObserver;
  98312. /**
  98313. * Attaches a new image processing configuration to the PBR Material.
  98314. * @param configuration
  98315. */
  98316. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  98317. /**
  98318. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98319. */
  98320. /**
  98321. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98322. */
  98323. colorCurves: Nullable<ColorCurves>;
  98324. /**
  98325. * Gets wether the color curves effect is enabled.
  98326. */
  98327. /**
  98328. * Sets wether the color curves effect is enabled.
  98329. */
  98330. colorCurvesEnabled: boolean;
  98331. /**
  98332. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98333. */
  98334. /**
  98335. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98336. */
  98337. colorGradingTexture: Nullable<BaseTexture>;
  98338. /**
  98339. * Gets wether the color grading effect is enabled.
  98340. */
  98341. /**
  98342. * Gets wether the color grading effect is enabled.
  98343. */
  98344. colorGradingEnabled: boolean;
  98345. /**
  98346. * Gets exposure used in the effect.
  98347. */
  98348. /**
  98349. * Sets exposure used in the effect.
  98350. */
  98351. exposure: number;
  98352. /**
  98353. * Gets wether tonemapping is enabled or not.
  98354. */
  98355. /**
  98356. * Sets wether tonemapping is enabled or not
  98357. */
  98358. toneMappingEnabled: boolean;
  98359. /**
  98360. * Gets the type of tone mapping effect.
  98361. */
  98362. /**
  98363. * Sets the type of tone mapping effect.
  98364. */
  98365. toneMappingType: number;
  98366. /**
  98367. * Gets contrast used in the effect.
  98368. */
  98369. /**
  98370. * Sets contrast used in the effect.
  98371. */
  98372. contrast: number;
  98373. /**
  98374. * Gets Vignette stretch size.
  98375. */
  98376. /**
  98377. * Sets Vignette stretch size.
  98378. */
  98379. vignetteStretch: number;
  98380. /**
  98381. * Gets Vignette centre X Offset.
  98382. */
  98383. /**
  98384. * Sets Vignette centre X Offset.
  98385. */
  98386. vignetteCentreX: number;
  98387. /**
  98388. * Gets Vignette centre Y Offset.
  98389. */
  98390. /**
  98391. * Sets Vignette centre Y Offset.
  98392. */
  98393. vignetteCentreY: number;
  98394. /**
  98395. * Gets Vignette weight or intensity of the vignette effect.
  98396. */
  98397. /**
  98398. * Sets Vignette weight or intensity of the vignette effect.
  98399. */
  98400. vignetteWeight: number;
  98401. /**
  98402. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98403. * if vignetteEnabled is set to true.
  98404. */
  98405. /**
  98406. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98407. * if vignetteEnabled is set to true.
  98408. */
  98409. vignetteColor: Color4;
  98410. /**
  98411. * Gets Camera field of view used by the Vignette effect.
  98412. */
  98413. /**
  98414. * Sets Camera field of view used by the Vignette effect.
  98415. */
  98416. vignetteCameraFov: number;
  98417. /**
  98418. * Gets the vignette blend mode allowing different kind of effect.
  98419. */
  98420. /**
  98421. * Sets the vignette blend mode allowing different kind of effect.
  98422. */
  98423. vignetteBlendMode: number;
  98424. /**
  98425. * Gets wether the vignette effect is enabled.
  98426. */
  98427. /**
  98428. * Sets wether the vignette effect is enabled.
  98429. */
  98430. vignetteEnabled: boolean;
  98431. private _fromLinearSpace;
  98432. /**
  98433. * Gets wether the input of the processing is in Gamma or Linear Space.
  98434. */
  98435. /**
  98436. * Sets wether the input of the processing is in Gamma or Linear Space.
  98437. */
  98438. fromLinearSpace: boolean;
  98439. /**
  98440. * Defines cache preventing GC.
  98441. */
  98442. private _defines;
  98443. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  98444. /**
  98445. * "ImageProcessingPostProcess"
  98446. * @returns "ImageProcessingPostProcess"
  98447. */
  98448. getClassName(): string;
  98449. protected _updateParameters(): void;
  98450. dispose(camera?: Camera): void;
  98451. }
  98452. }
  98453. declare module BABYLON {
  98454. /**
  98455. * Class containing static functions to help procedurally build meshes
  98456. */
  98457. export class GroundBuilder {
  98458. /**
  98459. * Creates a ground mesh
  98460. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  98461. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  98462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98463. * @param name defines the name of the mesh
  98464. * @param options defines the options used to create the mesh
  98465. * @param scene defines the hosting scene
  98466. * @returns the ground mesh
  98467. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  98468. */
  98469. static CreateGround(name: string, options: {
  98470. width?: number;
  98471. height?: number;
  98472. subdivisions?: number;
  98473. subdivisionsX?: number;
  98474. subdivisionsY?: number;
  98475. updatable?: boolean;
  98476. }, scene: any): Mesh;
  98477. /**
  98478. * Creates a tiled ground mesh
  98479. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  98480. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  98481. * * 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
  98482. * * 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
  98483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98484. * @param name defines the name of the mesh
  98485. * @param options defines the options used to create the mesh
  98486. * @param scene defines the hosting scene
  98487. * @returns the tiled ground mesh
  98488. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  98489. */
  98490. static CreateTiledGround(name: string, options: {
  98491. xmin: number;
  98492. zmin: number;
  98493. xmax: number;
  98494. zmax: number;
  98495. subdivisions?: {
  98496. w: number;
  98497. h: number;
  98498. };
  98499. precision?: {
  98500. w: number;
  98501. h: number;
  98502. };
  98503. updatable?: boolean;
  98504. }, scene?: Nullable<Scene>): Mesh;
  98505. /**
  98506. * Creates a ground mesh from a height map
  98507. * * The parameter `url` sets the URL of the height map image resource.
  98508. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  98509. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  98510. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  98511. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  98512. * * 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.
  98513. * * 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).
  98514. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98516. * @param name defines the name of the mesh
  98517. * @param url defines the url to the height map
  98518. * @param options defines the options used to create the mesh
  98519. * @param scene defines the hosting scene
  98520. * @returns the ground mesh
  98521. * @see https://doc.babylonjs.com/babylon101/height_map
  98522. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  98523. */
  98524. static CreateGroundFromHeightMap(name: string, url: string, options: {
  98525. width?: number;
  98526. height?: number;
  98527. subdivisions?: number;
  98528. minHeight?: number;
  98529. maxHeight?: number;
  98530. colorFilter?: Color3;
  98531. alphaFilter?: number;
  98532. updatable?: boolean;
  98533. onReady?: (mesh: GroundMesh) => void;
  98534. }, scene?: Nullable<Scene>): GroundMesh;
  98535. }
  98536. }
  98537. declare module BABYLON {
  98538. /**
  98539. * Class containing static functions to help procedurally build meshes
  98540. */
  98541. export class TorusBuilder {
  98542. /**
  98543. * Creates a torus mesh
  98544. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  98545. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  98546. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  98547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98550. * @param name defines the name of the mesh
  98551. * @param options defines the options used to create the mesh
  98552. * @param scene defines the hosting scene
  98553. * @returns the torus mesh
  98554. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  98555. */
  98556. static CreateTorus(name: string, options: {
  98557. diameter?: number;
  98558. thickness?: number;
  98559. tessellation?: number;
  98560. updatable?: boolean;
  98561. sideOrientation?: number;
  98562. frontUVs?: Vector4;
  98563. backUVs?: Vector4;
  98564. }, scene: any): Mesh;
  98565. }
  98566. }
  98567. declare module BABYLON {
  98568. /**
  98569. * Class containing static functions to help procedurally build meshes
  98570. */
  98571. export class CylinderBuilder {
  98572. /**
  98573. * Creates a cylinder or a cone mesh
  98574. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  98575. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  98576. * * 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.
  98577. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  98578. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  98579. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  98580. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  98581. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  98582. * * 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).
  98583. * * 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
  98584. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  98585. * * 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
  98586. * * 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.
  98587. * * If `enclose` is false, a ring surface is one element.
  98588. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  98589. * * 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
  98590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98593. * @param name defines the name of the mesh
  98594. * @param options defines the options used to create the mesh
  98595. * @param scene defines the hosting scene
  98596. * @returns the cylinder mesh
  98597. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  98598. */
  98599. static CreateCylinder(name: string, options: {
  98600. height?: number;
  98601. diameterTop?: number;
  98602. diameterBottom?: number;
  98603. diameter?: number;
  98604. tessellation?: number;
  98605. subdivisions?: number;
  98606. arc?: number;
  98607. faceColors?: Color4[];
  98608. faceUV?: Vector4[];
  98609. updatable?: boolean;
  98610. hasRings?: boolean;
  98611. enclose?: boolean;
  98612. sideOrientation?: number;
  98613. frontUVs?: Vector4;
  98614. backUVs?: Vector4;
  98615. }, scene: any): Mesh;
  98616. }
  98617. }
  98618. declare module BABYLON {
  98619. /**
  98620. * Manager for handling gamepads
  98621. */
  98622. export class GamepadManager {
  98623. private _scene?;
  98624. private _babylonGamepads;
  98625. private _oneGamepadConnected;
  98626. /** @hidden */
  98627. _isMonitoring: boolean;
  98628. private _gamepadEventSupported;
  98629. private _gamepadSupport;
  98630. /**
  98631. * observable to be triggered when the gamepad controller has been connected
  98632. */
  98633. onGamepadConnectedObservable: Observable<Gamepad>;
  98634. /**
  98635. * observable to be triggered when the gamepad controller has been disconnected
  98636. */
  98637. onGamepadDisconnectedObservable: Observable<Gamepad>;
  98638. private _onGamepadConnectedEvent;
  98639. private _onGamepadDisconnectedEvent;
  98640. /**
  98641. * Initializes the gamepad manager
  98642. * @param _scene BabylonJS scene
  98643. */
  98644. constructor(_scene?: Scene | undefined);
  98645. /**
  98646. * The gamepads in the game pad manager
  98647. */
  98648. readonly gamepads: Gamepad[];
  98649. /**
  98650. * Get the gamepad controllers based on type
  98651. * @param type The type of gamepad controller
  98652. * @returns Nullable gamepad
  98653. */
  98654. getGamepadByType(type?: number): Nullable<Gamepad>;
  98655. /**
  98656. * Disposes the gamepad manager
  98657. */
  98658. dispose(): void;
  98659. private _addNewGamepad;
  98660. private _startMonitoringGamepads;
  98661. private _stopMonitoringGamepads;
  98662. /** @hidden */
  98663. _checkGamepadsStatus(): void;
  98664. private _updateGamepadObjects;
  98665. }
  98666. }
  98667. declare module BABYLON {
  98668. interface Scene {
  98669. /** @hidden */
  98670. _gamepadManager: Nullable<GamepadManager>;
  98671. /**
  98672. * Gets the gamepad manager associated with the scene
  98673. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  98674. */
  98675. gamepadManager: GamepadManager;
  98676. }
  98677. /**
  98678. * Interface representing a free camera inputs manager
  98679. */
  98680. interface FreeCameraInputsManager {
  98681. /**
  98682. * Adds gamepad input support to the FreeCameraInputsManager.
  98683. * @returns the FreeCameraInputsManager
  98684. */
  98685. addGamepad(): FreeCameraInputsManager;
  98686. }
  98687. /**
  98688. * Interface representing an arc rotate camera inputs manager
  98689. */
  98690. interface ArcRotateCameraInputsManager {
  98691. /**
  98692. * Adds gamepad input support to the ArcRotateCamera InputManager.
  98693. * @returns the camera inputs manager
  98694. */
  98695. addGamepad(): ArcRotateCameraInputsManager;
  98696. }
  98697. /**
  98698. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  98699. */
  98700. export class GamepadSystemSceneComponent implements ISceneComponent {
  98701. /**
  98702. * The component name helpfull to identify the component in the list of scene components.
  98703. */
  98704. readonly name: string;
  98705. /**
  98706. * The scene the component belongs to.
  98707. */
  98708. scene: Scene;
  98709. /**
  98710. * Creates a new instance of the component for the given scene
  98711. * @param scene Defines the scene to register the component in
  98712. */
  98713. constructor(scene: Scene);
  98714. /**
  98715. * Registers the component in a given scene
  98716. */
  98717. register(): void;
  98718. /**
  98719. * Rebuilds the elements related to this component in case of
  98720. * context lost for instance.
  98721. */
  98722. rebuild(): void;
  98723. /**
  98724. * Disposes the component and the associated ressources
  98725. */
  98726. dispose(): void;
  98727. private _beforeCameraUpdate;
  98728. }
  98729. }
  98730. declare module BABYLON {
  98731. /**
  98732. * Options to modify the vr teleportation behavior.
  98733. */
  98734. export interface VRTeleportationOptions {
  98735. /**
  98736. * The name of the mesh which should be used as the teleportation floor. (default: null)
  98737. */
  98738. floorMeshName?: string;
  98739. /**
  98740. * A list of meshes to be used as the teleportation floor. (default: empty)
  98741. */
  98742. floorMeshes?: Mesh[];
  98743. }
  98744. /**
  98745. * Options to modify the vr experience helper's behavior.
  98746. */
  98747. export interface VRExperienceHelperOptions extends WebVROptions {
  98748. /**
  98749. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  98750. */
  98751. createDeviceOrientationCamera?: boolean;
  98752. /**
  98753. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  98754. */
  98755. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  98756. /**
  98757. * Uses the main button on the controller to toggle the laser casted. (default: true)
  98758. */
  98759. laserToggle?: boolean;
  98760. /**
  98761. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  98762. */
  98763. floorMeshes?: Mesh[];
  98764. /**
  98765. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  98766. */
  98767. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  98768. }
  98769. /**
  98770. * Event containing information after VR has been entered
  98771. */
  98772. export class OnAfterEnteringVRObservableEvent {
  98773. /**
  98774. * If entering vr was successful
  98775. */
  98776. success: boolean;
  98777. }
  98778. /**
  98779. * Helps to quickly add VR support to an existing scene.
  98780. * See http://doc.babylonjs.com/how_to/webvr_helper
  98781. */
  98782. export class VRExperienceHelper {
  98783. /** Options to modify the vr experience helper's behavior. */
  98784. webVROptions: VRExperienceHelperOptions;
  98785. private _scene;
  98786. private _position;
  98787. private _btnVR;
  98788. private _btnVRDisplayed;
  98789. private _webVRsupported;
  98790. private _webVRready;
  98791. private _webVRrequesting;
  98792. private _webVRpresenting;
  98793. private _hasEnteredVR;
  98794. private _fullscreenVRpresenting;
  98795. private _canvas;
  98796. private _webVRCamera;
  98797. private _vrDeviceOrientationCamera;
  98798. private _deviceOrientationCamera;
  98799. private _existingCamera;
  98800. private _onKeyDown;
  98801. private _onVrDisplayPresentChange;
  98802. private _onVRDisplayChanged;
  98803. private _onVRRequestPresentStart;
  98804. private _onVRRequestPresentComplete;
  98805. /**
  98806. * Observable raised right before entering VR.
  98807. */
  98808. onEnteringVRObservable: Observable<VRExperienceHelper>;
  98809. /**
  98810. * Observable raised when entering VR has completed.
  98811. */
  98812. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  98813. /**
  98814. * Observable raised when exiting VR.
  98815. */
  98816. onExitingVRObservable: Observable<VRExperienceHelper>;
  98817. /**
  98818. * Observable raised when controller mesh is loaded.
  98819. */
  98820. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98821. /** Return this.onEnteringVRObservable
  98822. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  98823. */
  98824. readonly onEnteringVR: Observable<VRExperienceHelper>;
  98825. /** Return this.onExitingVRObservable
  98826. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  98827. */
  98828. readonly onExitingVR: Observable<VRExperienceHelper>;
  98829. /** Return this.onControllerMeshLoadedObservable
  98830. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  98831. */
  98832. readonly onControllerMeshLoaded: Observable<WebVRController>;
  98833. private _rayLength;
  98834. private _useCustomVRButton;
  98835. private _teleportationRequested;
  98836. private _teleportActive;
  98837. private _floorMeshName;
  98838. private _floorMeshesCollection;
  98839. private _rotationAllowed;
  98840. private _teleportBackwardsVector;
  98841. private _teleportationTarget;
  98842. private _isDefaultTeleportationTarget;
  98843. private _postProcessMove;
  98844. private _teleportationFillColor;
  98845. private _teleportationBorderColor;
  98846. private _rotationAngle;
  98847. private _haloCenter;
  98848. private _cameraGazer;
  98849. private _padSensibilityUp;
  98850. private _padSensibilityDown;
  98851. private _leftController;
  98852. private _rightController;
  98853. /**
  98854. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  98855. */
  98856. onNewMeshSelected: Observable<AbstractMesh>;
  98857. /**
  98858. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  98859. */
  98860. onNewMeshPicked: Observable<PickingInfo>;
  98861. private _circleEase;
  98862. /**
  98863. * Observable raised before camera teleportation
  98864. */
  98865. onBeforeCameraTeleport: Observable<Vector3>;
  98866. /**
  98867. * Observable raised after camera teleportation
  98868. */
  98869. onAfterCameraTeleport: Observable<Vector3>;
  98870. /**
  98871. * Observable raised when current selected mesh gets unselected
  98872. */
  98873. onSelectedMeshUnselected: Observable<AbstractMesh>;
  98874. private _raySelectionPredicate;
  98875. /**
  98876. * To be optionaly changed by user to define custom ray selection
  98877. */
  98878. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  98879. /**
  98880. * To be optionaly changed by user to define custom selection logic (after ray selection)
  98881. */
  98882. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  98883. /**
  98884. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  98885. */
  98886. teleportationEnabled: boolean;
  98887. private _defaultHeight;
  98888. private _teleportationInitialized;
  98889. private _interactionsEnabled;
  98890. private _interactionsRequested;
  98891. private _displayGaze;
  98892. private _displayLaserPointer;
  98893. /**
  98894. * The mesh used to display where the user is going to teleport.
  98895. */
  98896. /**
  98897. * Sets the mesh to be used to display where the user is going to teleport.
  98898. */
  98899. teleportationTarget: Mesh;
  98900. /**
  98901. * 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
  98902. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  98903. * See http://doc.babylonjs.com/resources/baking_transformations
  98904. */
  98905. gazeTrackerMesh: Mesh;
  98906. /**
  98907. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  98908. */
  98909. updateGazeTrackerScale: boolean;
  98910. /**
  98911. * If the gaze trackers color should be updated when selecting meshes
  98912. */
  98913. updateGazeTrackerColor: boolean;
  98914. /**
  98915. * The gaze tracking mesh corresponding to the left controller
  98916. */
  98917. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  98918. /**
  98919. * The gaze tracking mesh corresponding to the right controller
  98920. */
  98921. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  98922. /**
  98923. * If the ray of the gaze should be displayed.
  98924. */
  98925. /**
  98926. * Sets if the ray of the gaze should be displayed.
  98927. */
  98928. displayGaze: boolean;
  98929. /**
  98930. * If the ray of the LaserPointer should be displayed.
  98931. */
  98932. /**
  98933. * Sets if the ray of the LaserPointer should be displayed.
  98934. */
  98935. displayLaserPointer: boolean;
  98936. /**
  98937. * The deviceOrientationCamera used as the camera when not in VR.
  98938. */
  98939. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  98940. /**
  98941. * Based on the current WebVR support, returns the current VR camera used.
  98942. */
  98943. readonly currentVRCamera: Nullable<Camera>;
  98944. /**
  98945. * The webVRCamera which is used when in VR.
  98946. */
  98947. readonly webVRCamera: WebVRFreeCamera;
  98948. /**
  98949. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  98950. */
  98951. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  98952. private readonly _teleportationRequestInitiated;
  98953. /**
  98954. * Defines wether or not Pointer lock should be requested when switching to
  98955. * full screen.
  98956. */
  98957. requestPointerLockOnFullScreen: boolean;
  98958. /**
  98959. * Instantiates a VRExperienceHelper.
  98960. * Helps to quickly add VR support to an existing scene.
  98961. * @param scene The scene the VRExperienceHelper belongs to.
  98962. * @param webVROptions Options to modify the vr experience helper's behavior.
  98963. */
  98964. constructor(scene: Scene,
  98965. /** Options to modify the vr experience helper's behavior. */
  98966. webVROptions?: VRExperienceHelperOptions);
  98967. private _onDefaultMeshLoaded;
  98968. private _onResize;
  98969. private _onFullscreenChange;
  98970. /**
  98971. * Gets a value indicating if we are currently in VR mode.
  98972. */
  98973. readonly isInVRMode: boolean;
  98974. private onVrDisplayPresentChange;
  98975. private onVRDisplayChanged;
  98976. private moveButtonToBottomRight;
  98977. private displayVRButton;
  98978. private updateButtonVisibility;
  98979. private _cachedAngularSensibility;
  98980. /**
  98981. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  98982. * Otherwise, will use the fullscreen API.
  98983. */
  98984. enterVR(): void;
  98985. /**
  98986. * Attempt to exit VR, or fullscreen.
  98987. */
  98988. exitVR(): void;
  98989. /**
  98990. * The position of the vr experience helper.
  98991. */
  98992. /**
  98993. * Sets the position of the vr experience helper.
  98994. */
  98995. position: Vector3;
  98996. /**
  98997. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  98998. */
  98999. enableInteractions(): void;
  99000. private readonly _noControllerIsActive;
  99001. private beforeRender;
  99002. private _isTeleportationFloor;
  99003. /**
  99004. * Adds a floor mesh to be used for teleportation.
  99005. * @param floorMesh the mesh to be used for teleportation.
  99006. */
  99007. addFloorMesh(floorMesh: Mesh): void;
  99008. /**
  99009. * Removes a floor mesh from being used for teleportation.
  99010. * @param floorMesh the mesh to be removed.
  99011. */
  99012. removeFloorMesh(floorMesh: Mesh): void;
  99013. /**
  99014. * Enables interactions and teleportation using the VR controllers and gaze.
  99015. * @param vrTeleportationOptions options to modify teleportation behavior.
  99016. */
  99017. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99018. private _onNewGamepadConnected;
  99019. private _tryEnableInteractionOnController;
  99020. private _onNewGamepadDisconnected;
  99021. private _enableInteractionOnController;
  99022. private _checkTeleportWithRay;
  99023. private _checkRotate;
  99024. private _checkTeleportBackwards;
  99025. private _enableTeleportationOnController;
  99026. private _createTeleportationCircles;
  99027. private _displayTeleportationTarget;
  99028. private _hideTeleportationTarget;
  99029. private _rotateCamera;
  99030. private _moveTeleportationSelectorTo;
  99031. private _workingVector;
  99032. private _workingQuaternion;
  99033. private _workingMatrix;
  99034. /**
  99035. * Teleports the users feet to the desired location
  99036. * @param location The location where the user's feet should be placed
  99037. */
  99038. teleportCamera(location: Vector3): void;
  99039. private _convertNormalToDirectionOfRay;
  99040. private _castRayAndSelectObject;
  99041. private _notifySelectedMeshUnselected;
  99042. /**
  99043. * Sets the color of the laser ray from the vr controllers.
  99044. * @param color new color for the ray.
  99045. */
  99046. changeLaserColor(color: Color3): void;
  99047. /**
  99048. * Sets the color of the ray from the vr headsets gaze.
  99049. * @param color new color for the ray.
  99050. */
  99051. changeGazeColor(color: Color3): void;
  99052. /**
  99053. * Exits VR and disposes of the vr experience helper
  99054. */
  99055. dispose(): void;
  99056. /**
  99057. * Gets the name of the VRExperienceHelper class
  99058. * @returns "VRExperienceHelper"
  99059. */
  99060. getClassName(): string;
  99061. }
  99062. }
  99063. declare module BABYLON {
  99064. /**
  99065. * Manages an XRSession
  99066. * @see https://doc.babylonjs.com/how_to/webxr
  99067. */
  99068. export class WebXRSessionManager implements IDisposable {
  99069. private scene;
  99070. /**
  99071. * Fires every time a new xrFrame arrives which can be used to update the camera
  99072. */
  99073. onXRFrameObservable: Observable<any>;
  99074. /**
  99075. * Fires when the xr session is ended either by the device or manually done
  99076. */
  99077. onXRSessionEnded: Observable<any>;
  99078. /** @hidden */
  99079. _xrSession: XRSession;
  99080. /** @hidden */
  99081. _frameOfReference: XRFrameOfReference;
  99082. /** @hidden */
  99083. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99084. /** @hidden */
  99085. _currentXRFrame: Nullable<XRFrame>;
  99086. private _xrNavigator;
  99087. private _xrDevice;
  99088. private _tmpMatrix;
  99089. /**
  99090. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99091. * @param scene The scene which the session should be created for
  99092. */
  99093. constructor(scene: Scene);
  99094. /**
  99095. * Initializes the manager
  99096. * After initialization enterXR can be called to start an XR session
  99097. * @returns Promise which resolves after it is initialized
  99098. */
  99099. initializeAsync(): Promise<void>;
  99100. /**
  99101. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99102. * @param sessionCreationOptions xr options to create the session with
  99103. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99104. * @returns Promise which resolves after it enters XR
  99105. */
  99106. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99107. /**
  99108. * Stops the xrSession and restores the renderloop
  99109. * @returns Promise which resolves after it exits XR
  99110. */
  99111. exitXRAsync(): Promise<void>;
  99112. /**
  99113. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99114. * @param ray ray to cast into the environment
  99115. * @returns Promise which resolves with a collision point in the environment if it exists
  99116. */
  99117. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99118. /**
  99119. * Checks if a session would be supported for the creation options specified
  99120. * @param options creation options to check if they are supported
  99121. * @returns true if supported
  99122. */
  99123. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99124. /**
  99125. * @hidden
  99126. * Converts the render layer of xrSession to a render target
  99127. * @param session session to create render target for
  99128. * @param scene scene the new render target should be created for
  99129. */
  99130. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99131. /**
  99132. * Disposes of the session manager
  99133. */
  99134. dispose(): void;
  99135. }
  99136. }
  99137. declare module BABYLON {
  99138. /**
  99139. * WebXR Camera which holds the views for the xrSession
  99140. * @see https://doc.babylonjs.com/how_to/webxr
  99141. */
  99142. export class WebXRCamera extends FreeCamera {
  99143. private static _TmpMatrix;
  99144. /**
  99145. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99146. * @param name the name of the camera
  99147. * @param scene the scene to add the camera to
  99148. */
  99149. constructor(name: string, scene: Scene);
  99150. private _updateNumberOfRigCameras;
  99151. /** @hidden */
  99152. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99153. /**
  99154. * Updates the cameras position from the current pose information of the XR session
  99155. * @param xrSessionManager the session containing pose information
  99156. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99157. */
  99158. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  99159. }
  99160. }
  99161. declare module BABYLON {
  99162. /**
  99163. * States of the webXR experience
  99164. */
  99165. export enum WebXRState {
  99166. /**
  99167. * Transitioning to being in XR mode
  99168. */
  99169. ENTERING_XR = 0,
  99170. /**
  99171. * Transitioning to non XR mode
  99172. */
  99173. EXITING_XR = 1,
  99174. /**
  99175. * In XR mode and presenting
  99176. */
  99177. IN_XR = 2,
  99178. /**
  99179. * Not entered XR mode
  99180. */
  99181. NOT_IN_XR = 3
  99182. }
  99183. /**
  99184. * Helper class used to enable XR
  99185. * @see https://doc.babylonjs.com/how_to/webxr
  99186. */
  99187. export class WebXRExperienceHelper implements IDisposable {
  99188. private scene;
  99189. /**
  99190. * 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
  99191. */
  99192. container: AbstractMesh;
  99193. /**
  99194. * Camera used to render xr content
  99195. */
  99196. camera: WebXRCamera;
  99197. /**
  99198. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  99199. */
  99200. state: WebXRState;
  99201. private _setState;
  99202. private static _TmpVector;
  99203. /**
  99204. * Fires when the state of the experience helper has changed
  99205. */
  99206. onStateChangedObservable: Observable<WebXRState>;
  99207. /** @hidden */
  99208. _sessionManager: WebXRSessionManager;
  99209. private _nonVRCamera;
  99210. private _originalSceneAutoClear;
  99211. private _supported;
  99212. /**
  99213. * Creates the experience helper
  99214. * @param scene the scene to attach the experience helper to
  99215. * @returns a promise for the experience helper
  99216. */
  99217. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  99218. /**
  99219. * Creates a WebXRExperienceHelper
  99220. * @param scene The scene the helper should be created in
  99221. */
  99222. private constructor();
  99223. /**
  99224. * Exits XR mode and returns the scene to its original state
  99225. * @returns promise that resolves after xr mode has exited
  99226. */
  99227. exitXRAsync(): Promise<void>;
  99228. /**
  99229. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  99230. * @param sessionCreationOptions options for the XR session
  99231. * @param frameOfReference frame of reference of the XR session
  99232. * @returns promise that resolves after xr mode has entered
  99233. */
  99234. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  99235. /**
  99236. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99237. * @param ray ray to cast into the environment
  99238. * @returns Promise which resolves with a collision point in the environment if it exists
  99239. */
  99240. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99241. /**
  99242. * Updates the global position of the camera by moving the camera's container
  99243. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  99244. * @param position The desired global position of the camera
  99245. */
  99246. setPositionOfCameraUsingContainer(position: Vector3): void;
  99247. /**
  99248. * Rotates the xr camera by rotating the camera's container around the camera's position
  99249. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  99250. * @param rotation the desired quaternion rotation to apply to the camera
  99251. */
  99252. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  99253. /**
  99254. * Checks if the creation options are supported by the xr session
  99255. * @param options creation options
  99256. * @returns true if supported
  99257. */
  99258. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99259. /**
  99260. * Disposes of the experience helper
  99261. */
  99262. dispose(): void;
  99263. }
  99264. }
  99265. declare module BABYLON {
  99266. /**
  99267. * Button which can be used to enter a different mode of XR
  99268. */
  99269. export class WebXREnterExitUIButton {
  99270. /** button element */
  99271. element: HTMLElement;
  99272. /** XR initialization options for the button */
  99273. initializationOptions: XRSessionCreationOptions;
  99274. /**
  99275. * Creates a WebXREnterExitUIButton
  99276. * @param element button element
  99277. * @param initializationOptions XR initialization options for the button
  99278. */
  99279. constructor(
  99280. /** button element */
  99281. element: HTMLElement,
  99282. /** XR initialization options for the button */
  99283. initializationOptions: XRSessionCreationOptions);
  99284. /**
  99285. * Overwritable function which can be used to update the button's visuals when the state changes
  99286. * @param activeButton the current active button in the UI
  99287. */
  99288. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  99289. }
  99290. /**
  99291. * Options to create the webXR UI
  99292. */
  99293. export class WebXREnterExitUIOptions {
  99294. /**
  99295. * Context to enter xr with
  99296. */
  99297. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  99298. /**
  99299. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  99300. */
  99301. customButtons?: Array<WebXREnterExitUIButton>;
  99302. }
  99303. /**
  99304. * UI to allow the user to enter/exit XR mode
  99305. */
  99306. export class WebXREnterExitUI implements IDisposable {
  99307. private scene;
  99308. private _overlay;
  99309. private _buttons;
  99310. private _activeButton;
  99311. /**
  99312. * Fired every time the active button is changed.
  99313. *
  99314. * When xr is entered via a button that launches xr that button will be the callback parameter
  99315. *
  99316. * When exiting xr the callback parameter will be null)
  99317. */
  99318. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  99319. /**
  99320. * Creates UI to allow the user to enter/exit XR mode
  99321. * @param scene the scene to add the ui to
  99322. * @param helper the xr experience helper to enter/exit xr with
  99323. * @param options options to configure the UI
  99324. * @returns the created ui
  99325. */
  99326. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  99327. private constructor();
  99328. private _updateButtons;
  99329. /**
  99330. * Disposes of the object
  99331. */
  99332. dispose(): void;
  99333. }
  99334. }
  99335. declare module BABYLON {
  99336. /**
  99337. * Represents an XR input
  99338. */
  99339. export class WebXRController {
  99340. /**
  99341. * 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
  99342. */
  99343. grip?: AbstractMesh;
  99344. /**
  99345. * Pointer which can be used to select objects or attach a visible laser to
  99346. */
  99347. pointer: AbstractMesh;
  99348. /**
  99349. * Creates the controller
  99350. * @see https://doc.babylonjs.com/how_to/webxr
  99351. * @param scene the scene which the controller should be associated to
  99352. */
  99353. constructor(scene: Scene);
  99354. /**
  99355. * Disposes of the object
  99356. */
  99357. dispose(): void;
  99358. }
  99359. /**
  99360. * XR input used to track XR inputs such as controllers/rays
  99361. */
  99362. export class WebXRInput implements IDisposable {
  99363. private helper;
  99364. /**
  99365. * XR controllers being tracked
  99366. */
  99367. controllers: Array<WebXRController>;
  99368. private _tmpMatrix;
  99369. private _frameObserver;
  99370. /**
  99371. * Initializes the WebXRInput
  99372. * @param helper experience helper which the input should be created for
  99373. */
  99374. constructor(helper: WebXRExperienceHelper);
  99375. /**
  99376. * Disposes of the object
  99377. */
  99378. dispose(): void;
  99379. }
  99380. }
  99381. declare module BABYLON {
  99382. /**
  99383. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  99384. */
  99385. export class WebXRManagedOutputCanvas implements IDisposable {
  99386. private _canvas;
  99387. /**
  99388. * xrpresent context of the canvas which can be used to display/mirror xr content
  99389. */
  99390. canvasContext: Nullable<WebGLRenderingContext>;
  99391. /**
  99392. * Initializes the canvas to be added/removed upon entering/exiting xr
  99393. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  99394. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  99395. */
  99396. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  99397. /**
  99398. * Disposes of the object
  99399. */
  99400. dispose(): void;
  99401. private _setManagedOutputCanvas;
  99402. private _addCanvas;
  99403. private _removeCanvas;
  99404. }
  99405. }
  99406. declare module BABYLON {
  99407. /**
  99408. * Contains an array of blocks representing the octree
  99409. */
  99410. export interface IOctreeContainer<T> {
  99411. /**
  99412. * Blocks within the octree
  99413. */
  99414. blocks: Array<OctreeBlock<T>>;
  99415. }
  99416. /**
  99417. * Class used to store a cell in an octree
  99418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99419. */
  99420. export class OctreeBlock<T> {
  99421. /**
  99422. * Gets the content of the current block
  99423. */
  99424. entries: T[];
  99425. /**
  99426. * Gets the list of block children
  99427. */
  99428. blocks: Array<OctreeBlock<T>>;
  99429. private _depth;
  99430. private _maxDepth;
  99431. private _capacity;
  99432. private _minPoint;
  99433. private _maxPoint;
  99434. private _boundingVectors;
  99435. private _creationFunc;
  99436. /**
  99437. * Creates a new block
  99438. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  99439. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  99440. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99441. * @param depth defines the current depth of this block in the octree
  99442. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  99443. * @param creationFunc defines a callback to call when an element is added to the block
  99444. */
  99445. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  99446. /**
  99447. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99448. */
  99449. readonly capacity: number;
  99450. /**
  99451. * Gets the minimum vector (in world space) of the block's bounding box
  99452. */
  99453. readonly minPoint: Vector3;
  99454. /**
  99455. * Gets the maximum vector (in world space) of the block's bounding box
  99456. */
  99457. readonly maxPoint: Vector3;
  99458. /**
  99459. * Add a new element to this block
  99460. * @param entry defines the element to add
  99461. */
  99462. addEntry(entry: T): void;
  99463. /**
  99464. * Remove an element from this block
  99465. * @param entry defines the element to remove
  99466. */
  99467. removeEntry(entry: T): void;
  99468. /**
  99469. * Add an array of elements to this block
  99470. * @param entries defines the array of elements to add
  99471. */
  99472. addEntries(entries: T[]): void;
  99473. /**
  99474. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  99475. * @param frustumPlanes defines the frustum planes to test
  99476. * @param selection defines the array to store current content if selection is positive
  99477. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99478. */
  99479. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99480. /**
  99481. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  99482. * @param sphereCenter defines the bounding sphere center
  99483. * @param sphereRadius defines the bounding sphere radius
  99484. * @param selection defines the array to store current content if selection is positive
  99485. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99486. */
  99487. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99488. /**
  99489. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  99490. * @param ray defines the ray to test with
  99491. * @param selection defines the array to store current content if selection is positive
  99492. */
  99493. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  99494. /**
  99495. * Subdivide the content into child blocks (this block will then be empty)
  99496. */
  99497. createInnerBlocks(): void;
  99498. /**
  99499. * @hidden
  99500. */
  99501. 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;
  99502. }
  99503. }
  99504. declare module BABYLON {
  99505. /**
  99506. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  99507. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99508. */
  99509. export class Octree<T> {
  99510. /** 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.) */
  99511. maxDepth: number;
  99512. /**
  99513. * Blocks within the octree containing objects
  99514. */
  99515. blocks: Array<OctreeBlock<T>>;
  99516. /**
  99517. * Content stored in the octree
  99518. */
  99519. dynamicContent: T[];
  99520. private _maxBlockCapacity;
  99521. private _selectionContent;
  99522. private _creationFunc;
  99523. /**
  99524. * Creates a octree
  99525. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99526. * @param creationFunc function to be used to instatiate the octree
  99527. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  99528. * @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.)
  99529. */
  99530. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  99531. /** 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.) */
  99532. maxDepth?: number);
  99533. /**
  99534. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  99535. * @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);
  99536. * @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);
  99537. * @param entries meshes to be added to the octree blocks
  99538. */
  99539. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  99540. /**
  99541. * Adds a mesh to the octree
  99542. * @param entry Mesh to add to the octree
  99543. */
  99544. addMesh(entry: T): void;
  99545. /**
  99546. * Remove an element from the octree
  99547. * @param entry defines the element to remove
  99548. */
  99549. removeMesh(entry: T): void;
  99550. /**
  99551. * Selects an array of meshes within the frustum
  99552. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  99553. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  99554. * @returns array of meshes within the frustum
  99555. */
  99556. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  99557. /**
  99558. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  99559. * @param sphereCenter defines the bounding sphere center
  99560. * @param sphereRadius defines the bounding sphere radius
  99561. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99562. * @returns an array of objects that intersect the sphere
  99563. */
  99564. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  99565. /**
  99566. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  99567. * @param ray defines the ray to test with
  99568. * @returns array of intersected objects
  99569. */
  99570. intersectsRay(ray: Ray): SmartArray<T>;
  99571. /**
  99572. * Adds a mesh into the octree block if it intersects the block
  99573. */
  99574. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  99575. /**
  99576. * Adds a submesh into the octree block if it intersects the block
  99577. */
  99578. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  99579. }
  99580. }
  99581. declare module BABYLON {
  99582. interface Scene {
  99583. /**
  99584. * @hidden
  99585. * Backing Filed
  99586. */
  99587. _selectionOctree: Octree<AbstractMesh>;
  99588. /**
  99589. * Gets the octree used to boost mesh selection (picking)
  99590. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99591. */
  99592. selectionOctree: Octree<AbstractMesh>;
  99593. /**
  99594. * Creates or updates the octree used to boost selection (picking)
  99595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99596. * @param maxCapacity defines the maximum capacity per leaf
  99597. * @param maxDepth defines the maximum depth of the octree
  99598. * @returns an octree of AbstractMesh
  99599. */
  99600. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  99601. }
  99602. interface AbstractMesh {
  99603. /**
  99604. * @hidden
  99605. * Backing Field
  99606. */
  99607. _submeshesOctree: Octree<SubMesh>;
  99608. /**
  99609. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  99610. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99611. * @param maxCapacity defines the maximum size of each block (64 by default)
  99612. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  99613. * @returns the new octree
  99614. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  99615. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99616. */
  99617. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  99618. }
  99619. /**
  99620. * Defines the octree scene component responsible to manage any octrees
  99621. * in a given scene.
  99622. */
  99623. export class OctreeSceneComponent {
  99624. /**
  99625. * The component name helpfull to identify the component in the list of scene components.
  99626. */
  99627. readonly name: string;
  99628. /**
  99629. * The scene the component belongs to.
  99630. */
  99631. scene: Scene;
  99632. /**
  99633. * Indicates if the meshes have been checked to make sure they are isEnabled()
  99634. */
  99635. readonly checksIsEnabled: boolean;
  99636. /**
  99637. * Creates a new instance of the component for the given scene
  99638. * @param scene Defines the scene to register the component in
  99639. */
  99640. constructor(scene: Scene);
  99641. /**
  99642. * Registers the component in a given scene
  99643. */
  99644. register(): void;
  99645. /**
  99646. * Return the list of active meshes
  99647. * @returns the list of active meshes
  99648. */
  99649. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99650. /**
  99651. * Return the list of active sub meshes
  99652. * @param mesh The mesh to get the candidates sub meshes from
  99653. * @returns the list of active sub meshes
  99654. */
  99655. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99656. private _tempRay;
  99657. /**
  99658. * Return the list of sub meshes intersecting with a given local ray
  99659. * @param mesh defines the mesh to find the submesh for
  99660. * @param localRay defines the ray in local space
  99661. * @returns the list of intersecting sub meshes
  99662. */
  99663. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  99664. /**
  99665. * Return the list of sub meshes colliding with a collider
  99666. * @param mesh defines the mesh to find the submesh for
  99667. * @param collider defines the collider to evaluate the collision against
  99668. * @returns the list of colliding sub meshes
  99669. */
  99670. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  99671. /**
  99672. * Rebuilds the elements related to this component in case of
  99673. * context lost for instance.
  99674. */
  99675. rebuild(): void;
  99676. /**
  99677. * Disposes the component and the associated ressources.
  99678. */
  99679. dispose(): void;
  99680. }
  99681. }
  99682. declare module BABYLON {
  99683. /**
  99684. * Renders a layer on top of an existing scene
  99685. */
  99686. export class UtilityLayerRenderer implements IDisposable {
  99687. /** the original scene that will be rendered on top of */
  99688. originalScene: Scene;
  99689. private _pointerCaptures;
  99690. private _lastPointerEvents;
  99691. private static _DefaultUtilityLayer;
  99692. private static _DefaultKeepDepthUtilityLayer;
  99693. private _sharedGizmoLight;
  99694. /**
  99695. * @hidden
  99696. * Light which used by gizmos to get light shading
  99697. */
  99698. _getSharedGizmoLight(): HemisphericLight;
  99699. /**
  99700. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  99701. */
  99702. pickUtilitySceneFirst: boolean;
  99703. /**
  99704. * 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)
  99705. */
  99706. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  99707. /**
  99708. * 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)
  99709. */
  99710. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  99711. /**
  99712. * The scene that is rendered on top of the original scene
  99713. */
  99714. utilityLayerScene: Scene;
  99715. /**
  99716. * If the utility layer should automatically be rendered on top of existing scene
  99717. */
  99718. shouldRender: boolean;
  99719. /**
  99720. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  99721. */
  99722. onlyCheckPointerDownEvents: boolean;
  99723. /**
  99724. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  99725. */
  99726. processAllEvents: boolean;
  99727. /**
  99728. * Observable raised when the pointer move from the utility layer scene to the main scene
  99729. */
  99730. onPointerOutObservable: Observable<number>;
  99731. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  99732. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  99733. private _afterRenderObserver;
  99734. private _sceneDisposeObserver;
  99735. private _originalPointerObserver;
  99736. /**
  99737. * Instantiates a UtilityLayerRenderer
  99738. * @param originalScene the original scene that will be rendered on top of
  99739. * @param handleEvents boolean indicating if the utility layer should handle events
  99740. */
  99741. constructor(
  99742. /** the original scene that will be rendered on top of */
  99743. originalScene: Scene, handleEvents?: boolean);
  99744. private _notifyObservers;
  99745. /**
  99746. * Renders the utility layers scene on top of the original scene
  99747. */
  99748. render(): void;
  99749. /**
  99750. * Disposes of the renderer
  99751. */
  99752. dispose(): void;
  99753. private _updateCamera;
  99754. }
  99755. }
  99756. declare module BABYLON {
  99757. /**
  99758. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  99759. */
  99760. export class Gizmo implements IDisposable {
  99761. /** The utility layer the gizmo will be added to */
  99762. gizmoLayer: UtilityLayerRenderer;
  99763. /**
  99764. * The root mesh of the gizmo
  99765. */
  99766. _rootMesh: Mesh;
  99767. private _attachedMesh;
  99768. /**
  99769. * Ratio for the scale of the gizmo (Default: 1)
  99770. */
  99771. scaleRatio: number;
  99772. private _tmpMatrix;
  99773. /**
  99774. * If a custom mesh has been set (Default: false)
  99775. */
  99776. protected _customMeshSet: boolean;
  99777. /**
  99778. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  99779. * * When set, interactions will be enabled
  99780. */
  99781. attachedMesh: Nullable<AbstractMesh>;
  99782. /**
  99783. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99784. * @param mesh The mesh to replace the default mesh of the gizmo
  99785. */
  99786. setCustomMesh(mesh: Mesh): void;
  99787. /**
  99788. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  99789. */
  99790. updateGizmoRotationToMatchAttachedMesh: boolean;
  99791. /**
  99792. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  99793. */
  99794. updateGizmoPositionToMatchAttachedMesh: boolean;
  99795. /**
  99796. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  99797. */
  99798. protected _updateScale: boolean;
  99799. protected _interactionsEnabled: boolean;
  99800. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99801. private _beforeRenderObserver;
  99802. /**
  99803. * Creates a gizmo
  99804. * @param gizmoLayer The utility layer the gizmo will be added to
  99805. */
  99806. constructor(
  99807. /** The utility layer the gizmo will be added to */
  99808. gizmoLayer?: UtilityLayerRenderer);
  99809. private _tempVector;
  99810. /**
  99811. * @hidden
  99812. * Updates the gizmo to match the attached mesh's position/rotation
  99813. */
  99814. protected _update(): void;
  99815. /**
  99816. * Disposes of the gizmo
  99817. */
  99818. dispose(): void;
  99819. }
  99820. }
  99821. declare module BABYLON {
  99822. /**
  99823. * Single axis drag gizmo
  99824. */
  99825. export class AxisDragGizmo extends Gizmo {
  99826. /**
  99827. * Drag behavior responsible for the gizmos dragging interactions
  99828. */
  99829. dragBehavior: PointerDragBehavior;
  99830. private _pointerObserver;
  99831. /**
  99832. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99833. */
  99834. snapDistance: number;
  99835. /**
  99836. * Event that fires each time the gizmo snaps to a new location.
  99837. * * snapDistance is the the change in distance
  99838. */
  99839. onSnapObservable: Observable<{
  99840. snapDistance: number;
  99841. }>;
  99842. /** @hidden */
  99843. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  99844. /** @hidden */
  99845. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  99846. /**
  99847. * Creates an AxisDragGizmo
  99848. * @param gizmoLayer The utility layer the gizmo will be added to
  99849. * @param dragAxis The axis which the gizmo will be able to drag on
  99850. * @param color The color of the gizmo
  99851. */
  99852. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99853. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99854. /**
  99855. * Disposes of the gizmo
  99856. */
  99857. dispose(): void;
  99858. }
  99859. }
  99860. declare module BABYLON.Debug {
  99861. /**
  99862. * The Axes viewer will show 3 axes in a specific point in space
  99863. */
  99864. export class AxesViewer {
  99865. private _xAxis;
  99866. private _yAxis;
  99867. private _zAxis;
  99868. private _scaleLinesFactor;
  99869. private _instanced;
  99870. /**
  99871. * Gets the hosting scene
  99872. */
  99873. scene: Scene;
  99874. /**
  99875. * Gets or sets a number used to scale line length
  99876. */
  99877. scaleLines: number;
  99878. /** Gets the node hierarchy used to render x-axis */
  99879. readonly xAxis: TransformNode;
  99880. /** Gets the node hierarchy used to render y-axis */
  99881. readonly yAxis: TransformNode;
  99882. /** Gets the node hierarchy used to render z-axis */
  99883. readonly zAxis: TransformNode;
  99884. /**
  99885. * Creates a new AxesViewer
  99886. * @param scene defines the hosting scene
  99887. * @param scaleLines defines a number used to scale line length (1 by default)
  99888. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  99889. * @param xAxis defines the node hierarchy used to render the x-axis
  99890. * @param yAxis defines the node hierarchy used to render the y-axis
  99891. * @param zAxis defines the node hierarchy used to render the z-axis
  99892. */
  99893. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  99894. /**
  99895. * Force the viewer to update
  99896. * @param position defines the position of the viewer
  99897. * @param xaxis defines the x axis of the viewer
  99898. * @param yaxis defines the y axis of the viewer
  99899. * @param zaxis defines the z axis of the viewer
  99900. */
  99901. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  99902. /**
  99903. * Creates an instance of this axes viewer.
  99904. * @returns a new axes viewer with instanced meshes
  99905. */
  99906. createInstance(): AxesViewer;
  99907. /** Releases resources */
  99908. dispose(): void;
  99909. private static _SetRenderingGroupId;
  99910. }
  99911. }
  99912. declare module BABYLON.Debug {
  99913. /**
  99914. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  99915. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  99916. */
  99917. export class BoneAxesViewer extends AxesViewer {
  99918. /**
  99919. * Gets or sets the target mesh where to display the axes viewer
  99920. */
  99921. mesh: Nullable<Mesh>;
  99922. /**
  99923. * Gets or sets the target bone where to display the axes viewer
  99924. */
  99925. bone: Nullable<Bone>;
  99926. /** Gets current position */
  99927. pos: Vector3;
  99928. /** Gets direction of X axis */
  99929. xaxis: Vector3;
  99930. /** Gets direction of Y axis */
  99931. yaxis: Vector3;
  99932. /** Gets direction of Z axis */
  99933. zaxis: Vector3;
  99934. /**
  99935. * Creates a new BoneAxesViewer
  99936. * @param scene defines the hosting scene
  99937. * @param bone defines the target bone
  99938. * @param mesh defines the target mesh
  99939. * @param scaleLines defines a scaling factor for line length (1 by default)
  99940. */
  99941. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  99942. /**
  99943. * Force the viewer to update
  99944. */
  99945. update(): void;
  99946. /** Releases resources */
  99947. dispose(): void;
  99948. }
  99949. }
  99950. declare module BABYLON {
  99951. /**
  99952. * Interface used to define scene explorer extensibility option
  99953. */
  99954. export interface IExplorerExtensibilityOption {
  99955. /**
  99956. * Define the option label
  99957. */
  99958. label: string;
  99959. /**
  99960. * Defines the action to execute on click
  99961. */
  99962. action: (entity: any) => void;
  99963. }
  99964. /**
  99965. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  99966. */
  99967. export interface IExplorerExtensibilityGroup {
  99968. /**
  99969. * Defines a predicate to test if a given type mut be extended
  99970. */
  99971. predicate: (entity: any) => boolean;
  99972. /**
  99973. * Gets the list of options added to a type
  99974. */
  99975. entries: IExplorerExtensibilityOption[];
  99976. }
  99977. /**
  99978. * Interface used to define the options to use to create the Inspector
  99979. */
  99980. export interface IInspectorOptions {
  99981. /**
  99982. * Display in overlay mode (default: false)
  99983. */
  99984. overlay?: boolean;
  99985. /**
  99986. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  99987. */
  99988. globalRoot?: HTMLElement;
  99989. /**
  99990. * Display the Scene explorer
  99991. */
  99992. showExplorer?: boolean;
  99993. /**
  99994. * Display the property inspector
  99995. */
  99996. showInspector?: boolean;
  99997. /**
  99998. * Display in embed mode (both panes on the right)
  99999. */
  100000. embedMode?: boolean;
  100001. /**
  100002. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100003. */
  100004. handleResize?: boolean;
  100005. /**
  100006. * Allow the panes to popup (default: true)
  100007. */
  100008. enablePopup?: boolean;
  100009. /**
  100010. * Allow the panes to be closed by users (default: true)
  100011. */
  100012. enableClose?: boolean;
  100013. /**
  100014. * Optional list of extensibility entries
  100015. */
  100016. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100017. /**
  100018. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100019. */
  100020. inspectorURL?: string;
  100021. }
  100022. interface Scene {
  100023. /**
  100024. * @hidden
  100025. * Backing field
  100026. */
  100027. _debugLayer: DebugLayer;
  100028. /**
  100029. * Gets the debug layer (aka Inspector) associated with the scene
  100030. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100031. */
  100032. debugLayer: DebugLayer;
  100033. }
  100034. /**
  100035. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100036. * what is happening in your scene
  100037. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100038. */
  100039. export class DebugLayer {
  100040. /**
  100041. * Define the url to get the inspector script from.
  100042. * By default it uses the babylonjs CDN.
  100043. * @ignoreNaming
  100044. */
  100045. static InspectorURL: string;
  100046. private _scene;
  100047. private BJSINSPECTOR;
  100048. /**
  100049. * Observable triggered when a property is changed through the inspector.
  100050. */
  100051. onPropertyChangedObservable: Observable<{
  100052. object: any;
  100053. property: string;
  100054. value: any;
  100055. initialValue: any;
  100056. }>;
  100057. /**
  100058. * Instantiates a new debug layer.
  100059. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100060. * what is happening in your scene
  100061. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100062. * @param scene Defines the scene to inspect
  100063. */
  100064. constructor(scene: Scene);
  100065. /** Creates the inspector window. */
  100066. private _createInspector;
  100067. /**
  100068. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100069. * @param entity defines the entity to select
  100070. * @param lineContainerTitle defines the specific block to highlight
  100071. */
  100072. select(entity: any, lineContainerTitle?: string): void;
  100073. /** Get the inspector from bundle or global */
  100074. private _getGlobalInspector;
  100075. /**
  100076. * Get if the inspector is visible or not.
  100077. * @returns true if visible otherwise, false
  100078. */
  100079. isVisible(): boolean;
  100080. /**
  100081. * Hide the inspector and close its window.
  100082. */
  100083. hide(): void;
  100084. /**
  100085. * Launch the debugLayer.
  100086. * @param config Define the configuration of the inspector
  100087. * @return a promise fulfilled when the debug layer is visible
  100088. */
  100089. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100090. }
  100091. }
  100092. declare module BABYLON {
  100093. /**
  100094. * Class containing static functions to help procedurally build meshes
  100095. */
  100096. export class BoxBuilder {
  100097. /**
  100098. * Creates a box mesh
  100099. * * The parameter `size` sets the size (float) of each box side (default 1)
  100100. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100101. * * 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)
  100102. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100106. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100107. * @param name defines the name of the mesh
  100108. * @param options defines the options used to create the mesh
  100109. * @param scene defines the hosting scene
  100110. * @returns the box mesh
  100111. */
  100112. static CreateBox(name: string, options: {
  100113. size?: number;
  100114. width?: number;
  100115. height?: number;
  100116. depth?: number;
  100117. faceUV?: Vector4[];
  100118. faceColors?: Color4[];
  100119. sideOrientation?: number;
  100120. frontUVs?: Vector4;
  100121. backUVs?: Vector4;
  100122. updatable?: boolean;
  100123. }, scene?: Nullable<Scene>): Mesh;
  100124. }
  100125. }
  100126. declare module BABYLON {
  100127. /**
  100128. * Class containing static functions to help procedurally build meshes
  100129. */
  100130. export class SphereBuilder {
  100131. /**
  100132. * Creates a sphere mesh
  100133. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100134. * * 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`)
  100135. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100136. * * 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
  100137. * * 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)
  100138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100141. * @param name defines the name of the mesh
  100142. * @param options defines the options used to create the mesh
  100143. * @param scene defines the hosting scene
  100144. * @returns the sphere mesh
  100145. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100146. */
  100147. static CreateSphere(name: string, options: {
  100148. segments?: number;
  100149. diameter?: number;
  100150. diameterX?: number;
  100151. diameterY?: number;
  100152. diameterZ?: number;
  100153. arc?: number;
  100154. slice?: number;
  100155. sideOrientation?: number;
  100156. frontUVs?: Vector4;
  100157. backUVs?: Vector4;
  100158. updatable?: boolean;
  100159. }, scene: any): Mesh;
  100160. }
  100161. }
  100162. declare module BABYLON.Debug {
  100163. /**
  100164. * Used to show the physics impostor around the specific mesh
  100165. */
  100166. export class PhysicsViewer {
  100167. /** @hidden */
  100168. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  100169. /** @hidden */
  100170. protected _meshes: Array<Nullable<AbstractMesh>>;
  100171. /** @hidden */
  100172. protected _scene: Nullable<Scene>;
  100173. /** @hidden */
  100174. protected _numMeshes: number;
  100175. /** @hidden */
  100176. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  100177. private _renderFunction;
  100178. private _utilityLayer;
  100179. private _debugBoxMesh;
  100180. private _debugSphereMesh;
  100181. private _debugCylinderMesh;
  100182. private _debugMaterial;
  100183. private _debugMeshMeshes;
  100184. /**
  100185. * Creates a new PhysicsViewer
  100186. * @param scene defines the hosting scene
  100187. */
  100188. constructor(scene: Scene);
  100189. /** @hidden */
  100190. protected _updateDebugMeshes(): void;
  100191. /**
  100192. * Renders a specified physic impostor
  100193. * @param impostor defines the impostor to render
  100194. * @param targetMesh defines the mesh represented by the impostor
  100195. * @returns the new debug mesh used to render the impostor
  100196. */
  100197. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  100198. /**
  100199. * Hides a specified physic impostor
  100200. * @param impostor defines the impostor to hide
  100201. */
  100202. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  100203. private _getDebugMaterial;
  100204. private _getDebugBoxMesh;
  100205. private _getDebugSphereMesh;
  100206. private _getDebugCylinderMesh;
  100207. private _getDebugMeshMesh;
  100208. private _getDebugMesh;
  100209. /** Releases all resources */
  100210. dispose(): void;
  100211. }
  100212. }
  100213. declare module BABYLON {
  100214. /**
  100215. * Class containing static functions to help procedurally build meshes
  100216. */
  100217. export class LinesBuilder {
  100218. /**
  100219. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  100220. * * 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
  100221. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  100222. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  100223. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  100224. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  100225. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  100226. * * 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
  100227. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  100228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100229. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  100230. * @param name defines the name of the new line system
  100231. * @param options defines the options used to create the line system
  100232. * @param scene defines the hosting scene
  100233. * @returns a new line system mesh
  100234. */
  100235. static CreateLineSystem(name: string, options: {
  100236. lines: Vector3[][];
  100237. updatable?: boolean;
  100238. instance?: Nullable<LinesMesh>;
  100239. colors?: Nullable<Color4[][]>;
  100240. useVertexAlpha?: boolean;
  100241. }, scene: Nullable<Scene>): LinesMesh;
  100242. /**
  100243. * Creates a line mesh
  100244. * 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
  100245. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100246. * * The parameter `points` is an array successive Vector3
  100247. * * 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
  100248. * * The optional parameter `colors` is an array of successive Color4, one per line point
  100249. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  100250. * * When updating an instance, remember that only point positions can change, not the number of points
  100251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  100253. * @param name defines the name of the new line system
  100254. * @param options defines the options used to create the line system
  100255. * @param scene defines the hosting scene
  100256. * @returns a new line mesh
  100257. */
  100258. static CreateLines(name: string, options: {
  100259. points: Vector3[];
  100260. updatable?: boolean;
  100261. instance?: Nullable<LinesMesh>;
  100262. colors?: Color4[];
  100263. useVertexAlpha?: boolean;
  100264. }, scene?: Nullable<Scene>): LinesMesh;
  100265. /**
  100266. * Creates a dashed line mesh
  100267. * * 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
  100268. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100269. * * The parameter `points` is an array successive Vector3
  100270. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  100271. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  100272. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  100273. * * 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
  100274. * * When updating an instance, remember that only point positions can change, not the number of points
  100275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100276. * @param name defines the name of the mesh
  100277. * @param options defines the options used to create the mesh
  100278. * @param scene defines the hosting scene
  100279. * @returns the dashed line mesh
  100280. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  100281. */
  100282. static CreateDashedLines(name: string, options: {
  100283. points: Vector3[];
  100284. dashSize?: number;
  100285. gapSize?: number;
  100286. dashNb?: number;
  100287. updatable?: boolean;
  100288. instance?: LinesMesh;
  100289. }, scene?: Nullable<Scene>): LinesMesh;
  100290. }
  100291. }
  100292. declare module BABYLON {
  100293. /**
  100294. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100295. * in order to better appreciate the issue one might have.
  100296. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100297. */
  100298. export class RayHelper {
  100299. /**
  100300. * Defines the ray we are currently tryin to visualize.
  100301. */
  100302. ray: Nullable<Ray>;
  100303. private _renderPoints;
  100304. private _renderLine;
  100305. private _renderFunction;
  100306. private _scene;
  100307. private _updateToMeshFunction;
  100308. private _attachedToMesh;
  100309. private _meshSpaceDirection;
  100310. private _meshSpaceOrigin;
  100311. /**
  100312. * Helper function to create a colored helper in a scene in one line.
  100313. * @param ray Defines the ray we are currently tryin to visualize
  100314. * @param scene Defines the scene the ray is used in
  100315. * @param color Defines the color we want to see the ray in
  100316. * @returns The newly created ray helper.
  100317. */
  100318. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  100319. /**
  100320. * Instantiate a new ray helper.
  100321. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100322. * in order to better appreciate the issue one might have.
  100323. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100324. * @param ray Defines the ray we are currently tryin to visualize
  100325. */
  100326. constructor(ray: Ray);
  100327. /**
  100328. * Shows the ray we are willing to debug.
  100329. * @param scene Defines the scene the ray needs to be rendered in
  100330. * @param color Defines the color the ray needs to be rendered in
  100331. */
  100332. show(scene: Scene, color?: Color3): void;
  100333. /**
  100334. * Hides the ray we are debugging.
  100335. */
  100336. hide(): void;
  100337. private _render;
  100338. /**
  100339. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  100340. * @param mesh Defines the mesh we want the helper attached to
  100341. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  100342. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  100343. * @param length Defines the length of the ray
  100344. */
  100345. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  100346. /**
  100347. * Detach the ray helper from the mesh it has previously been attached to.
  100348. */
  100349. detachFromMesh(): void;
  100350. private _updateToMesh;
  100351. /**
  100352. * Dispose the helper and release its associated resources.
  100353. */
  100354. dispose(): void;
  100355. }
  100356. }
  100357. declare module BABYLON.Debug {
  100358. /**
  100359. * Class used to render a debug view of a given skeleton
  100360. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  100361. */
  100362. export class SkeletonViewer {
  100363. /** defines the skeleton to render */
  100364. skeleton: Skeleton;
  100365. /** defines the mesh attached to the skeleton */
  100366. mesh: AbstractMesh;
  100367. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100368. autoUpdateBonesMatrices: boolean;
  100369. /** defines the rendering group id to use with the viewer */
  100370. renderingGroupId: number;
  100371. /** Gets or sets the color used to render the skeleton */
  100372. color: Color3;
  100373. private _scene;
  100374. private _debugLines;
  100375. private _debugMesh;
  100376. private _isEnabled;
  100377. private _renderFunction;
  100378. private _utilityLayer;
  100379. /**
  100380. * Returns the mesh used to render the bones
  100381. */
  100382. readonly debugMesh: Nullable<LinesMesh>;
  100383. /**
  100384. * Creates a new SkeletonViewer
  100385. * @param skeleton defines the skeleton to render
  100386. * @param mesh defines the mesh attached to the skeleton
  100387. * @param scene defines the hosting scene
  100388. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  100389. * @param renderingGroupId defines the rendering group id to use with the viewer
  100390. */
  100391. constructor(
  100392. /** defines the skeleton to render */
  100393. skeleton: Skeleton,
  100394. /** defines the mesh attached to the skeleton */
  100395. mesh: AbstractMesh, scene: Scene,
  100396. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100397. autoUpdateBonesMatrices?: boolean,
  100398. /** defines the rendering group id to use with the viewer */
  100399. renderingGroupId?: number);
  100400. /** Gets or sets a boolean indicating if the viewer is enabled */
  100401. isEnabled: boolean;
  100402. private _getBonePosition;
  100403. private _getLinesForBonesWithLength;
  100404. private _getLinesForBonesNoLength;
  100405. /** Update the viewer to sync with current skeleton state */
  100406. update(): void;
  100407. /** Release associated resources */
  100408. dispose(): void;
  100409. }
  100410. }
  100411. declare module BABYLON {
  100412. /**
  100413. * Options to create the null engine
  100414. */
  100415. export class NullEngineOptions {
  100416. /**
  100417. * Render width (Default: 512)
  100418. */
  100419. renderWidth: number;
  100420. /**
  100421. * Render height (Default: 256)
  100422. */
  100423. renderHeight: number;
  100424. /**
  100425. * Texture size (Default: 512)
  100426. */
  100427. textureSize: number;
  100428. /**
  100429. * If delta time between frames should be constant
  100430. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100431. */
  100432. deterministicLockstep: boolean;
  100433. /**
  100434. * Maximum about of steps between frames (Default: 4)
  100435. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100436. */
  100437. lockstepMaxSteps: number;
  100438. }
  100439. /**
  100440. * The null engine class provides support for headless version of babylon.js.
  100441. * This can be used in server side scenario or for testing purposes
  100442. */
  100443. export class NullEngine extends Engine {
  100444. private _options;
  100445. /**
  100446. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100447. */
  100448. isDeterministicLockStep(): boolean;
  100449. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  100450. getLockstepMaxSteps(): number;
  100451. /**
  100452. * Sets hardware scaling, used to save performance if needed
  100453. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100454. */
  100455. getHardwareScalingLevel(): number;
  100456. constructor(options?: NullEngineOptions);
  100457. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100458. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  100459. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100460. getRenderWidth(useScreen?: boolean): number;
  100461. getRenderHeight(useScreen?: boolean): number;
  100462. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  100463. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  100464. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  100465. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  100466. bindSamplers(effect: Effect): void;
  100467. enableEffect(effect: Effect): void;
  100468. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100469. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  100470. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  100471. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  100472. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  100473. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  100474. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  100475. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  100476. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  100477. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  100478. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  100479. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  100480. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  100481. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  100482. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  100483. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100484. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100485. setFloat(uniform: WebGLUniformLocation, value: number): void;
  100486. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  100487. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  100488. setBool(uniform: WebGLUniformLocation, bool: number): void;
  100489. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  100490. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  100491. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  100492. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100493. bindBuffers(vertexBuffers: {
  100494. [key: string]: VertexBuffer;
  100495. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  100496. wipeCaches(bruteForce?: boolean): void;
  100497. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100498. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100499. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100500. /** @hidden */
  100501. _createTexture(): WebGLTexture;
  100502. /** @hidden */
  100503. _releaseTexture(texture: InternalTexture): void;
  100504. 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;
  100505. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  100506. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100507. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  100508. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100509. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100510. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  100511. areAllEffectsReady(): boolean;
  100512. /**
  100513. * @hidden
  100514. * Get the current error code of the webGL context
  100515. * @returns the error code
  100516. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100517. */
  100518. getError(): number;
  100519. /** @hidden */
  100520. _getUnpackAlignement(): number;
  100521. /** @hidden */
  100522. _unpackFlipY(value: boolean): void;
  100523. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  100524. /**
  100525. * Updates a dynamic vertex buffer.
  100526. * @param vertexBuffer the vertex buffer to update
  100527. * @param data the data used to update the vertex buffer
  100528. * @param byteOffset the byte offset of the data (optional)
  100529. * @param byteLength the byte length of the data (optional)
  100530. */
  100531. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  100532. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  100533. /** @hidden */
  100534. _bindTexture(channel: number, texture: InternalTexture): void;
  100535. /** @hidden */
  100536. _releaseBuffer(buffer: WebGLBuffer): boolean;
  100537. releaseEffects(): void;
  100538. displayLoadingUI(): void;
  100539. hideLoadingUI(): void;
  100540. /** @hidden */
  100541. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100542. /** @hidden */
  100543. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100544. /** @hidden */
  100545. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100546. /** @hidden */
  100547. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  100548. }
  100549. }
  100550. declare module BABYLON {
  100551. /** @hidden */
  100552. export class _OcclusionDataStorage {
  100553. /** @hidden */
  100554. occlusionInternalRetryCounter: number;
  100555. /** @hidden */
  100556. isOcclusionQueryInProgress: boolean;
  100557. /** @hidden */
  100558. isOccluded: boolean;
  100559. /** @hidden */
  100560. occlusionRetryCount: number;
  100561. /** @hidden */
  100562. occlusionType: number;
  100563. /** @hidden */
  100564. occlusionQueryAlgorithmType: number;
  100565. }
  100566. interface Engine {
  100567. /**
  100568. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  100569. * @return the new query
  100570. */
  100571. createQuery(): WebGLQuery;
  100572. /**
  100573. * Delete and release a webGL query
  100574. * @param query defines the query to delete
  100575. * @return the current engine
  100576. */
  100577. deleteQuery(query: WebGLQuery): Engine;
  100578. /**
  100579. * Check if a given query has resolved and got its value
  100580. * @param query defines the query to check
  100581. * @returns true if the query got its value
  100582. */
  100583. isQueryResultAvailable(query: WebGLQuery): boolean;
  100584. /**
  100585. * Gets the value of a given query
  100586. * @param query defines the query to check
  100587. * @returns the value of the query
  100588. */
  100589. getQueryResult(query: WebGLQuery): number;
  100590. /**
  100591. * Initiates an occlusion query
  100592. * @param algorithmType defines the algorithm to use
  100593. * @param query defines the query to use
  100594. * @returns the current engine
  100595. * @see http://doc.babylonjs.com/features/occlusionquery
  100596. */
  100597. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  100598. /**
  100599. * Ends an occlusion query
  100600. * @see http://doc.babylonjs.com/features/occlusionquery
  100601. * @param algorithmType defines the algorithm to use
  100602. * @returns the current engine
  100603. */
  100604. endOcclusionQuery(algorithmType: number): Engine;
  100605. /**
  100606. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  100607. * Please note that only one query can be issued at a time
  100608. * @returns a time token used to track the time span
  100609. */
  100610. startTimeQuery(): Nullable<_TimeToken>;
  100611. /**
  100612. * Ends a time query
  100613. * @param token defines the token used to measure the time span
  100614. * @returns the time spent (in ns)
  100615. */
  100616. endTimeQuery(token: _TimeToken): int;
  100617. /** @hidden */
  100618. _currentNonTimestampToken: Nullable<_TimeToken>;
  100619. /** @hidden */
  100620. _createTimeQuery(): WebGLQuery;
  100621. /** @hidden */
  100622. _deleteTimeQuery(query: WebGLQuery): void;
  100623. /** @hidden */
  100624. _getGlAlgorithmType(algorithmType: number): number;
  100625. /** @hidden */
  100626. _getTimeQueryResult(query: WebGLQuery): any;
  100627. /** @hidden */
  100628. _getTimeQueryAvailability(query: WebGLQuery): any;
  100629. }
  100630. interface AbstractMesh {
  100631. /**
  100632. * Backing filed
  100633. * @hidden
  100634. */
  100635. __occlusionDataStorage: _OcclusionDataStorage;
  100636. /**
  100637. * Access property
  100638. * @hidden
  100639. */
  100640. _occlusionDataStorage: _OcclusionDataStorage;
  100641. /**
  100642. * 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.
  100643. * The default value is -1 which means don't break the query and wait till the result
  100644. * @see http://doc.babylonjs.com/features/occlusionquery
  100645. */
  100646. occlusionRetryCount: number;
  100647. /**
  100648. * 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:
  100649. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  100650. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  100651. * * 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.
  100652. * @see http://doc.babylonjs.com/features/occlusionquery
  100653. */
  100654. occlusionType: number;
  100655. /**
  100656. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  100657. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  100658. * * 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.
  100659. * @see http://doc.babylonjs.com/features/occlusionquery
  100660. */
  100661. occlusionQueryAlgorithmType: number;
  100662. /**
  100663. * 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
  100664. * @see http://doc.babylonjs.com/features/occlusionquery
  100665. */
  100666. isOccluded: boolean;
  100667. /**
  100668. * Flag to check the progress status of the query
  100669. * @see http://doc.babylonjs.com/features/occlusionquery
  100670. */
  100671. isOcclusionQueryInProgress: boolean;
  100672. }
  100673. }
  100674. declare module BABYLON {
  100675. /** @hidden */
  100676. export var _forceTransformFeedbackToBundle: boolean;
  100677. interface Engine {
  100678. /**
  100679. * Creates a webGL transform feedback object
  100680. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  100681. * @returns the webGL transform feedback object
  100682. */
  100683. createTransformFeedback(): WebGLTransformFeedback;
  100684. /**
  100685. * Delete a webGL transform feedback object
  100686. * @param value defines the webGL transform feedback object to delete
  100687. */
  100688. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  100689. /**
  100690. * Bind a webGL transform feedback object to the webgl context
  100691. * @param value defines the webGL transform feedback object to bind
  100692. */
  100693. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  100694. /**
  100695. * Begins a transform feedback operation
  100696. * @param usePoints defines if points or triangles must be used
  100697. */
  100698. beginTransformFeedback(usePoints: boolean): void;
  100699. /**
  100700. * Ends a transform feedback operation
  100701. */
  100702. endTransformFeedback(): void;
  100703. /**
  100704. * Specify the varyings to use with transform feedback
  100705. * @param program defines the associated webGL program
  100706. * @param value defines the list of strings representing the varying names
  100707. */
  100708. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  100709. /**
  100710. * Bind a webGL buffer for a transform feedback operation
  100711. * @param value defines the webGL buffer to bind
  100712. */
  100713. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  100714. }
  100715. }
  100716. declare module BABYLON {
  100717. /**
  100718. * Gather the list of clipboard event types as constants.
  100719. */
  100720. export class ClipboardEventTypes {
  100721. /**
  100722. * The clipboard event is fired when a copy command is active (pressed).
  100723. */
  100724. static readonly COPY: number;
  100725. /**
  100726. * The clipboard event is fired when a cut command is active (pressed).
  100727. */
  100728. static readonly CUT: number;
  100729. /**
  100730. * The clipboard event is fired when a paste command is active (pressed).
  100731. */
  100732. static readonly PASTE: number;
  100733. }
  100734. /**
  100735. * This class is used to store clipboard related info for the onClipboardObservable event.
  100736. */
  100737. export class ClipboardInfo {
  100738. /**
  100739. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100740. */
  100741. type: number;
  100742. /**
  100743. * Defines the related dom event
  100744. */
  100745. event: ClipboardEvent;
  100746. /**
  100747. *Creates an instance of ClipboardInfo.
  100748. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  100749. * @param event Defines the related dom event
  100750. */
  100751. constructor(
  100752. /**
  100753. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100754. */
  100755. type: number,
  100756. /**
  100757. * Defines the related dom event
  100758. */
  100759. event: ClipboardEvent);
  100760. /**
  100761. * Get the clipboard event's type from the keycode.
  100762. * @param keyCode Defines the keyCode for the current keyboard event.
  100763. * @return {number}
  100764. */
  100765. static GetTypeFromCharacter(keyCode: number): number;
  100766. }
  100767. }
  100768. declare module BABYLON {
  100769. /**
  100770. * Class used to represent data loading progression
  100771. */
  100772. export class SceneLoaderProgressEvent {
  100773. /** defines if data length to load can be evaluated */
  100774. readonly lengthComputable: boolean;
  100775. /** defines the loaded data length */
  100776. readonly loaded: number;
  100777. /** defines the data length to load */
  100778. readonly total: number;
  100779. /**
  100780. * Create a new progress event
  100781. * @param lengthComputable defines if data length to load can be evaluated
  100782. * @param loaded defines the loaded data length
  100783. * @param total defines the data length to load
  100784. */
  100785. constructor(
  100786. /** defines if data length to load can be evaluated */
  100787. lengthComputable: boolean,
  100788. /** defines the loaded data length */
  100789. loaded: number,
  100790. /** defines the data length to load */
  100791. total: number);
  100792. /**
  100793. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  100794. * @param event defines the source event
  100795. * @returns a new SceneLoaderProgressEvent
  100796. */
  100797. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  100798. }
  100799. /**
  100800. * Interface used by SceneLoader plugins to define supported file extensions
  100801. */
  100802. export interface ISceneLoaderPluginExtensions {
  100803. /**
  100804. * Defines the list of supported extensions
  100805. */
  100806. [extension: string]: {
  100807. isBinary: boolean;
  100808. };
  100809. }
  100810. /**
  100811. * Interface used by SceneLoader plugin factory
  100812. */
  100813. export interface ISceneLoaderPluginFactory {
  100814. /**
  100815. * Defines the name of the factory
  100816. */
  100817. name: string;
  100818. /**
  100819. * Function called to create a new plugin
  100820. * @return the new plugin
  100821. */
  100822. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  100823. /**
  100824. * Boolean indicating if the plugin can direct load specific data
  100825. */
  100826. canDirectLoad?: (data: string) => boolean;
  100827. }
  100828. /**
  100829. * Interface used to define a SceneLoader plugin
  100830. */
  100831. export interface ISceneLoaderPlugin {
  100832. /**
  100833. * The friendly name of this plugin.
  100834. */
  100835. name: string;
  100836. /**
  100837. * The file extensions supported by this plugin.
  100838. */
  100839. extensions: string | ISceneLoaderPluginExtensions;
  100840. /**
  100841. * Import meshes into a scene.
  100842. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100843. * @param scene The scene to import into
  100844. * @param data The data to import
  100845. * @param rootUrl The root url for scene and resources
  100846. * @param meshes The meshes array to import into
  100847. * @param particleSystems The particle systems array to import into
  100848. * @param skeletons The skeletons array to import into
  100849. * @param onError The callback when import fails
  100850. * @returns True if successful or false otherwise
  100851. */
  100852. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  100853. /**
  100854. * Load into a scene.
  100855. * @param scene The scene to load into
  100856. * @param data The data to import
  100857. * @param rootUrl The root url for scene and resources
  100858. * @param onError The callback when import fails
  100859. * @returns true if successful or false otherwise
  100860. */
  100861. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  100862. /**
  100863. * The callback that returns true if the data can be directly loaded.
  100864. */
  100865. canDirectLoad?: (data: string) => boolean;
  100866. /**
  100867. * The callback that allows custom handling of the root url based on the response url.
  100868. */
  100869. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100870. /**
  100871. * Load into an asset container.
  100872. * @param scene The scene to load into
  100873. * @param data The data to import
  100874. * @param rootUrl The root url for scene and resources
  100875. * @param onError The callback when import fails
  100876. * @returns The loaded asset container
  100877. */
  100878. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  100879. }
  100880. /**
  100881. * Interface used to define an async SceneLoader plugin
  100882. */
  100883. export interface ISceneLoaderPluginAsync {
  100884. /**
  100885. * The friendly name of this plugin.
  100886. */
  100887. name: string;
  100888. /**
  100889. * The file extensions supported by this plugin.
  100890. */
  100891. extensions: string | ISceneLoaderPluginExtensions;
  100892. /**
  100893. * Import meshes into a scene.
  100894. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100895. * @param scene The scene to import into
  100896. * @param data The data to import
  100897. * @param rootUrl The root url for scene and resources
  100898. * @param onProgress The callback when the load progresses
  100899. * @param fileName Defines the name of the file to load
  100900. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  100901. */
  100902. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  100903. meshes: AbstractMesh[];
  100904. particleSystems: IParticleSystem[];
  100905. skeletons: Skeleton[];
  100906. animationGroups: AnimationGroup[];
  100907. }>;
  100908. /**
  100909. * Load into a scene.
  100910. * @param scene The scene to load into
  100911. * @param data The data to import
  100912. * @param rootUrl The root url for scene and resources
  100913. * @param onProgress The callback when the load progresses
  100914. * @param fileName Defines the name of the file to load
  100915. * @returns Nothing
  100916. */
  100917. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  100918. /**
  100919. * The callback that returns true if the data can be directly loaded.
  100920. */
  100921. canDirectLoad?: (data: string) => boolean;
  100922. /**
  100923. * The callback that allows custom handling of the root url based on the response url.
  100924. */
  100925. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100926. /**
  100927. * Load into an asset container.
  100928. * @param scene The scene to load into
  100929. * @param data The data to import
  100930. * @param rootUrl The root url for scene and resources
  100931. * @param onProgress The callback when the load progresses
  100932. * @param fileName Defines the name of the file to load
  100933. * @returns The loaded asset container
  100934. */
  100935. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  100936. }
  100937. /**
  100938. * Class used to load scene from various file formats using registered plugins
  100939. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  100940. */
  100941. export class SceneLoader {
  100942. /**
  100943. * No logging while loading
  100944. */
  100945. static readonly NO_LOGGING: number;
  100946. /**
  100947. * Minimal logging while loading
  100948. */
  100949. static readonly MINIMAL_LOGGING: number;
  100950. /**
  100951. * Summary logging while loading
  100952. */
  100953. static readonly SUMMARY_LOGGING: number;
  100954. /**
  100955. * Detailled logging while loading
  100956. */
  100957. static readonly DETAILED_LOGGING: number;
  100958. /**
  100959. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  100960. */
  100961. static ForceFullSceneLoadingForIncremental: boolean;
  100962. /**
  100963. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  100964. */
  100965. static ShowLoadingScreen: boolean;
  100966. /**
  100967. * Defines the current logging level (while loading the scene)
  100968. * @ignorenaming
  100969. */
  100970. static loggingLevel: number;
  100971. /**
  100972. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  100973. */
  100974. static CleanBoneMatrixWeights: boolean;
  100975. /**
  100976. * Event raised when a plugin is used to load a scene
  100977. */
  100978. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  100979. private static _registeredPlugins;
  100980. private static _getDefaultPlugin;
  100981. private static _getPluginForExtension;
  100982. private static _getPluginForDirectLoad;
  100983. private static _getPluginForFilename;
  100984. private static _getDirectLoad;
  100985. private static _loadData;
  100986. private static _getFileInfo;
  100987. /**
  100988. * Gets a plugin that can load the given extension
  100989. * @param extension defines the extension to load
  100990. * @returns a plugin or null if none works
  100991. */
  100992. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  100993. /**
  100994. * Gets a boolean indicating that the given extension can be loaded
  100995. * @param extension defines the extension to load
  100996. * @returns true if the extension is supported
  100997. */
  100998. static IsPluginForExtensionAvailable(extension: string): boolean;
  100999. /**
  101000. * Adds a new plugin to the list of registered plugins
  101001. * @param plugin defines the plugin to add
  101002. */
  101003. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101004. /**
  101005. * Import meshes into a scene
  101006. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101007. * @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)
  101008. * @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)
  101009. * @param scene the instance of BABYLON.Scene to append to
  101010. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101011. * @param onProgress a callback with a progress event for each file being loaded
  101012. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101013. * @param pluginExtension the extension used to determine the plugin
  101014. * @returns The loaded plugin
  101015. */
  101016. 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>;
  101017. /**
  101018. * Import meshes into a scene
  101019. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101020. * @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)
  101021. * @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)
  101022. * @param scene the instance of BABYLON.Scene to append to
  101023. * @param onProgress a callback with a progress event for each file being loaded
  101024. * @param pluginExtension the extension used to determine the plugin
  101025. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  101026. */
  101027. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  101028. meshes: AbstractMesh[];
  101029. particleSystems: IParticleSystem[];
  101030. skeletons: Skeleton[];
  101031. animationGroups: AnimationGroup[];
  101032. }>;
  101033. /**
  101034. * Load a scene
  101035. * @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)
  101036. * @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)
  101037. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101038. * @param onSuccess a callback with the scene when import succeeds
  101039. * @param onProgress a callback with a progress event for each file being loaded
  101040. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101041. * @param pluginExtension the extension used to determine the plugin
  101042. * @returns The loaded plugin
  101043. */
  101044. 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>;
  101045. /**
  101046. * Load a scene
  101047. * @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)
  101048. * @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)
  101049. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101050. * @param onProgress a callback with a progress event for each file being loaded
  101051. * @param pluginExtension the extension used to determine the plugin
  101052. * @returns The loaded scene
  101053. */
  101054. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101055. /**
  101056. * Append a scene
  101057. * @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)
  101058. * @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)
  101059. * @param scene is the instance of BABYLON.Scene to append to
  101060. * @param onSuccess a callback with the scene when import succeeds
  101061. * @param onProgress a callback with a progress event for each file being loaded
  101062. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101063. * @param pluginExtension the extension used to determine the plugin
  101064. * @returns The loaded plugin
  101065. */
  101066. 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>;
  101067. /**
  101068. * Append a scene
  101069. * @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)
  101070. * @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)
  101071. * @param scene is the instance of BABYLON.Scene to append to
  101072. * @param onProgress a callback with a progress event for each file being loaded
  101073. * @param pluginExtension the extension used to determine the plugin
  101074. * @returns The given scene
  101075. */
  101076. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101077. /**
  101078. * Load a scene into an asset container
  101079. * @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)
  101080. * @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)
  101081. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  101082. * @param onSuccess a callback with the scene when import succeeds
  101083. * @param onProgress a callback with a progress event for each file being loaded
  101084. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101085. * @param pluginExtension the extension used to determine the plugin
  101086. * @returns The loaded plugin
  101087. */
  101088. 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>;
  101089. /**
  101090. * Load a scene into an asset container
  101091. * @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)
  101092. * @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)
  101093. * @param scene is the instance of Scene to append to
  101094. * @param onProgress a callback with a progress event for each file being loaded
  101095. * @param pluginExtension the extension used to determine the plugin
  101096. * @returns The loaded asset container
  101097. */
  101098. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  101099. }
  101100. }
  101101. declare module BABYLON {
  101102. /**
  101103. * Google Daydream controller
  101104. */
  101105. export class DaydreamController extends WebVRController {
  101106. /**
  101107. * Base Url for the controller model.
  101108. */
  101109. static MODEL_BASE_URL: string;
  101110. /**
  101111. * File name for the controller model.
  101112. */
  101113. static MODEL_FILENAME: string;
  101114. /**
  101115. * Gamepad Id prefix used to identify Daydream Controller.
  101116. */
  101117. static readonly GAMEPAD_ID_PREFIX: string;
  101118. /**
  101119. * Creates a new DaydreamController from a gamepad
  101120. * @param vrGamepad the gamepad that the controller should be created from
  101121. */
  101122. constructor(vrGamepad: any);
  101123. /**
  101124. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101125. * @param scene scene in which to add meshes
  101126. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101127. */
  101128. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101129. /**
  101130. * Called once for each button that changed state since the last frame
  101131. * @param buttonIdx Which button index changed
  101132. * @param state New state of the button
  101133. * @param changes Which properties on the state changed since last frame
  101134. */
  101135. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101136. }
  101137. }
  101138. declare module BABYLON {
  101139. /**
  101140. * Gear VR Controller
  101141. */
  101142. export class GearVRController extends WebVRController {
  101143. /**
  101144. * Base Url for the controller model.
  101145. */
  101146. static MODEL_BASE_URL: string;
  101147. /**
  101148. * File name for the controller model.
  101149. */
  101150. static MODEL_FILENAME: string;
  101151. /**
  101152. * Gamepad Id prefix used to identify this controller.
  101153. */
  101154. static readonly GAMEPAD_ID_PREFIX: string;
  101155. private readonly _buttonIndexToObservableNameMap;
  101156. /**
  101157. * Creates a new GearVRController from a gamepad
  101158. * @param vrGamepad the gamepad that the controller should be created from
  101159. */
  101160. constructor(vrGamepad: any);
  101161. /**
  101162. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101163. * @param scene scene in which to add meshes
  101164. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101165. */
  101166. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101167. /**
  101168. * Called once for each button that changed state since the last frame
  101169. * @param buttonIdx Which button index changed
  101170. * @param state New state of the button
  101171. * @param changes Which properties on the state changed since last frame
  101172. */
  101173. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101174. }
  101175. }
  101176. declare module BABYLON {
  101177. /**
  101178. * Generic Controller
  101179. */
  101180. export class GenericController extends WebVRController {
  101181. /**
  101182. * Base Url for the controller model.
  101183. */
  101184. static readonly MODEL_BASE_URL: string;
  101185. /**
  101186. * File name for the controller model.
  101187. */
  101188. static readonly MODEL_FILENAME: string;
  101189. /**
  101190. * Creates a new GenericController from a gamepad
  101191. * @param vrGamepad the gamepad that the controller should be created from
  101192. */
  101193. constructor(vrGamepad: any);
  101194. /**
  101195. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101196. * @param scene scene in which to add meshes
  101197. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101198. */
  101199. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101200. /**
  101201. * Called once for each button that changed state since the last frame
  101202. * @param buttonIdx Which button index changed
  101203. * @param state New state of the button
  101204. * @param changes Which properties on the state changed since last frame
  101205. */
  101206. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101207. }
  101208. }
  101209. declare module BABYLON {
  101210. /**
  101211. * Oculus Touch Controller
  101212. */
  101213. export class OculusTouchController extends WebVRController {
  101214. /**
  101215. * Base Url for the controller model.
  101216. */
  101217. static MODEL_BASE_URL: string;
  101218. /**
  101219. * File name for the left controller model.
  101220. */
  101221. static MODEL_LEFT_FILENAME: string;
  101222. /**
  101223. * File name for the right controller model.
  101224. */
  101225. static MODEL_RIGHT_FILENAME: string;
  101226. /**
  101227. * Fired when the secondary trigger on this controller is modified
  101228. */
  101229. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  101230. /**
  101231. * Fired when the thumb rest on this controller is modified
  101232. */
  101233. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  101234. /**
  101235. * Creates a new OculusTouchController from a gamepad
  101236. * @param vrGamepad the gamepad that the controller should be created from
  101237. */
  101238. constructor(vrGamepad: any);
  101239. /**
  101240. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101241. * @param scene scene in which to add meshes
  101242. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101243. */
  101244. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101245. /**
  101246. * Fired when the A button on this controller is modified
  101247. */
  101248. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101249. /**
  101250. * Fired when the B button on this controller is modified
  101251. */
  101252. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101253. /**
  101254. * Fired when the X button on this controller is modified
  101255. */
  101256. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101257. /**
  101258. * Fired when the Y button on this controller is modified
  101259. */
  101260. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101261. /**
  101262. * Called once for each button that changed state since the last frame
  101263. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  101264. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  101265. * 2) secondary trigger (same)
  101266. * 3) A (right) X (left), touch, pressed = value
  101267. * 4) B / Y
  101268. * 5) thumb rest
  101269. * @param buttonIdx Which button index changed
  101270. * @param state New state of the button
  101271. * @param changes Which properties on the state changed since last frame
  101272. */
  101273. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101274. }
  101275. }
  101276. declare module BABYLON {
  101277. /**
  101278. * Vive Controller
  101279. */
  101280. export class ViveController extends WebVRController {
  101281. /**
  101282. * Base Url for the controller model.
  101283. */
  101284. static MODEL_BASE_URL: string;
  101285. /**
  101286. * File name for the controller model.
  101287. */
  101288. static MODEL_FILENAME: string;
  101289. /**
  101290. * Creates a new ViveController from a gamepad
  101291. * @param vrGamepad the gamepad that the controller should be created from
  101292. */
  101293. constructor(vrGamepad: any);
  101294. /**
  101295. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101296. * @param scene scene in which to add meshes
  101297. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101298. */
  101299. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101300. /**
  101301. * Fired when the left button on this controller is modified
  101302. */
  101303. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101304. /**
  101305. * Fired when the right button on this controller is modified
  101306. */
  101307. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101308. /**
  101309. * Fired when the menu button on this controller is modified
  101310. */
  101311. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101312. /**
  101313. * Called once for each button that changed state since the last frame
  101314. * Vive mapping:
  101315. * 0: touchpad
  101316. * 1: trigger
  101317. * 2: left AND right buttons
  101318. * 3: menu button
  101319. * @param buttonIdx Which button index changed
  101320. * @param state New state of the button
  101321. * @param changes Which properties on the state changed since last frame
  101322. */
  101323. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101324. }
  101325. }
  101326. declare module BABYLON {
  101327. /**
  101328. * Defines the WindowsMotionController object that the state of the windows motion controller
  101329. */
  101330. export class WindowsMotionController extends WebVRController {
  101331. /**
  101332. * The base url used to load the left and right controller models
  101333. */
  101334. static MODEL_BASE_URL: string;
  101335. /**
  101336. * The name of the left controller model file
  101337. */
  101338. static MODEL_LEFT_FILENAME: string;
  101339. /**
  101340. * The name of the right controller model file
  101341. */
  101342. static MODEL_RIGHT_FILENAME: string;
  101343. /**
  101344. * The controller name prefix for this controller type
  101345. */
  101346. static readonly GAMEPAD_ID_PREFIX: string;
  101347. /**
  101348. * The controller id pattern for this controller type
  101349. */
  101350. private static readonly GAMEPAD_ID_PATTERN;
  101351. private _loadedMeshInfo;
  101352. private readonly _mapping;
  101353. /**
  101354. * Fired when the trackpad on this controller is clicked
  101355. */
  101356. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  101357. /**
  101358. * Fired when the trackpad on this controller is modified
  101359. */
  101360. onTrackpadValuesChangedObservable: Observable<StickValues>;
  101361. /**
  101362. * The current x and y values of this controller's trackpad
  101363. */
  101364. trackpad: StickValues;
  101365. /**
  101366. * Creates a new WindowsMotionController from a gamepad
  101367. * @param vrGamepad the gamepad that the controller should be created from
  101368. */
  101369. constructor(vrGamepad: any);
  101370. /**
  101371. * Fired when the trigger on this controller is modified
  101372. */
  101373. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101374. /**
  101375. * Fired when the menu button on this controller is modified
  101376. */
  101377. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101378. /**
  101379. * Fired when the grip button on this controller is modified
  101380. */
  101381. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101382. /**
  101383. * Fired when the thumbstick button on this controller is modified
  101384. */
  101385. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101386. /**
  101387. * Fired when the touchpad button on this controller is modified
  101388. */
  101389. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101390. /**
  101391. * Fired when the touchpad values on this controller are modified
  101392. */
  101393. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  101394. private _updateTrackpad;
  101395. /**
  101396. * Called once per frame by the engine.
  101397. */
  101398. update(): void;
  101399. /**
  101400. * Called once for each button that changed state since the last frame
  101401. * @param buttonIdx Which button index changed
  101402. * @param state New state of the button
  101403. * @param changes Which properties on the state changed since last frame
  101404. */
  101405. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101406. /**
  101407. * Moves the buttons on the controller mesh based on their current state
  101408. * @param buttonName the name of the button to move
  101409. * @param buttonValue the value of the button which determines the buttons new position
  101410. */
  101411. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  101412. /**
  101413. * Moves the axis on the controller mesh based on its current state
  101414. * @param axis the index of the axis
  101415. * @param axisValue the value of the axis which determines the meshes new position
  101416. * @hidden
  101417. */
  101418. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  101419. /**
  101420. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101421. * @param scene scene in which to add meshes
  101422. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101423. */
  101424. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  101425. /**
  101426. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  101427. * can be transformed by button presses and axes values, based on this._mapping.
  101428. *
  101429. * @param scene scene in which the meshes exist
  101430. * @param meshes list of meshes that make up the controller model to process
  101431. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  101432. */
  101433. private processModel;
  101434. private createMeshInfo;
  101435. /**
  101436. * Gets the ray of the controller in the direction the controller is pointing
  101437. * @param length the length the resulting ray should be
  101438. * @returns a ray in the direction the controller is pointing
  101439. */
  101440. getForwardRay(length?: number): Ray;
  101441. /**
  101442. * Disposes of the controller
  101443. */
  101444. dispose(): void;
  101445. }
  101446. }
  101447. declare module BABYLON {
  101448. /**
  101449. * Single axis scale gizmo
  101450. */
  101451. export class AxisScaleGizmo extends Gizmo {
  101452. private _coloredMaterial;
  101453. /**
  101454. * Drag behavior responsible for the gizmos dragging interactions
  101455. */
  101456. dragBehavior: PointerDragBehavior;
  101457. private _pointerObserver;
  101458. /**
  101459. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101460. */
  101461. snapDistance: number;
  101462. /**
  101463. * Event that fires each time the gizmo snaps to a new location.
  101464. * * snapDistance is the the change in distance
  101465. */
  101466. onSnapObservable: Observable<{
  101467. snapDistance: number;
  101468. }>;
  101469. /**
  101470. * If the scaling operation should be done on all axis (default: false)
  101471. */
  101472. uniformScaling: boolean;
  101473. /**
  101474. * Creates an AxisScaleGizmo
  101475. * @param gizmoLayer The utility layer the gizmo will be added to
  101476. * @param dragAxis The axis which the gizmo will be able to scale on
  101477. * @param color The color of the gizmo
  101478. */
  101479. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101480. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101481. /**
  101482. * Disposes of the gizmo
  101483. */
  101484. dispose(): void;
  101485. /**
  101486. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  101487. * @param mesh The mesh to replace the default mesh of the gizmo
  101488. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  101489. */
  101490. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  101491. }
  101492. }
  101493. declare module BABYLON {
  101494. /**
  101495. * Bounding box gizmo
  101496. */
  101497. export class BoundingBoxGizmo extends Gizmo {
  101498. private _lineBoundingBox;
  101499. private _rotateSpheresParent;
  101500. private _scaleBoxesParent;
  101501. private _boundingDimensions;
  101502. private _renderObserver;
  101503. private _pointerObserver;
  101504. private _scaleDragSpeed;
  101505. private _tmpQuaternion;
  101506. private _tmpVector;
  101507. private _tmpRotationMatrix;
  101508. /**
  101509. * 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)
  101510. */
  101511. ignoreChildren: boolean;
  101512. /**
  101513. * 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)
  101514. */
  101515. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  101516. /**
  101517. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  101518. */
  101519. rotationSphereSize: number;
  101520. /**
  101521. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  101522. */
  101523. scaleBoxSize: number;
  101524. /**
  101525. * 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)
  101526. */
  101527. fixedDragMeshScreenSize: boolean;
  101528. /**
  101529. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  101530. */
  101531. fixedDragMeshScreenSizeDistanceFactor: number;
  101532. /**
  101533. * Fired when a rotation sphere or scale box is dragged
  101534. */
  101535. onDragStartObservable: Observable<{}>;
  101536. /**
  101537. * Fired when a scale box is dragged
  101538. */
  101539. onScaleBoxDragObservable: Observable<{}>;
  101540. /**
  101541. * Fired when a scale box drag is ended
  101542. */
  101543. onScaleBoxDragEndObservable: Observable<{}>;
  101544. /**
  101545. * Fired when a rotation sphere is dragged
  101546. */
  101547. onRotationSphereDragObservable: Observable<{}>;
  101548. /**
  101549. * Fired when a rotation sphere drag is ended
  101550. */
  101551. onRotationSphereDragEndObservable: Observable<{}>;
  101552. /**
  101553. * 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)
  101554. */
  101555. scalePivot: Nullable<Vector3>;
  101556. private _anchorMesh;
  101557. private _existingMeshScale;
  101558. private _dragMesh;
  101559. private pointerDragBehavior;
  101560. private coloredMaterial;
  101561. private hoverColoredMaterial;
  101562. /**
  101563. * Sets the color of the bounding box gizmo
  101564. * @param color the color to set
  101565. */
  101566. setColor(color: Color3): void;
  101567. /**
  101568. * Creates an BoundingBoxGizmo
  101569. * @param gizmoLayer The utility layer the gizmo will be added to
  101570. * @param color The color of the gizmo
  101571. */
  101572. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101573. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101574. private _selectNode;
  101575. /**
  101576. * Updates the bounding box information for the Gizmo
  101577. */
  101578. updateBoundingBox(): void;
  101579. private _updateRotationSpheres;
  101580. private _updateScaleBoxes;
  101581. /**
  101582. * Enables rotation on the specified axis and disables rotation on the others
  101583. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  101584. */
  101585. setEnabledRotationAxis(axis: string): void;
  101586. /**
  101587. * Enables/disables scaling
  101588. * @param enable if scaling should be enabled
  101589. */
  101590. setEnabledScaling(enable: boolean): void;
  101591. private _updateDummy;
  101592. /**
  101593. * Enables a pointer drag behavior on the bounding box of the gizmo
  101594. */
  101595. enableDragBehavior(): void;
  101596. /**
  101597. * Disposes of the gizmo
  101598. */
  101599. dispose(): void;
  101600. /**
  101601. * 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)
  101602. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  101603. * @returns the bounding box mesh with the passed in mesh as a child
  101604. */
  101605. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  101606. /**
  101607. * CustomMeshes are not supported by this gizmo
  101608. * @param mesh The mesh to replace the default mesh of the gizmo
  101609. */
  101610. setCustomMesh(mesh: Mesh): void;
  101611. }
  101612. }
  101613. declare module BABYLON {
  101614. /**
  101615. * Single plane rotation gizmo
  101616. */
  101617. export class PlaneRotationGizmo extends Gizmo {
  101618. /**
  101619. * Drag behavior responsible for the gizmos dragging interactions
  101620. */
  101621. dragBehavior: PointerDragBehavior;
  101622. private _pointerObserver;
  101623. /**
  101624. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  101625. */
  101626. snapDistance: number;
  101627. /**
  101628. * Event that fires each time the gizmo snaps to a new location.
  101629. * * snapDistance is the the change in distance
  101630. */
  101631. onSnapObservable: Observable<{
  101632. snapDistance: number;
  101633. }>;
  101634. /**
  101635. * Creates a PlaneRotationGizmo
  101636. * @param gizmoLayer The utility layer the gizmo will be added to
  101637. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  101638. * @param color The color of the gizmo
  101639. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101640. */
  101641. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101642. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101643. /**
  101644. * Disposes of the gizmo
  101645. */
  101646. dispose(): void;
  101647. }
  101648. }
  101649. declare module BABYLON {
  101650. /**
  101651. * Gizmo that enables rotating a mesh along 3 axis
  101652. */
  101653. export class RotationGizmo extends Gizmo {
  101654. /**
  101655. * Internal gizmo used for interactions on the x axis
  101656. */
  101657. xGizmo: PlaneRotationGizmo;
  101658. /**
  101659. * Internal gizmo used for interactions on the y axis
  101660. */
  101661. yGizmo: PlaneRotationGizmo;
  101662. /**
  101663. * Internal gizmo used for interactions on the z axis
  101664. */
  101665. zGizmo: PlaneRotationGizmo;
  101666. /** Fires an event when any of it's sub gizmos are dragged */
  101667. onDragStartObservable: Observable<{}>;
  101668. /** Fires an event when any of it's sub gizmos are released from dragging */
  101669. onDragEndObservable: Observable<{}>;
  101670. attachedMesh: Nullable<AbstractMesh>;
  101671. /**
  101672. * Creates a RotationGizmo
  101673. * @param gizmoLayer The utility layer the gizmo will be added to
  101674. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101675. */
  101676. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101677. updateGizmoRotationToMatchAttachedMesh: boolean;
  101678. /**
  101679. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101680. */
  101681. snapDistance: number;
  101682. /**
  101683. * Ratio for the scale of the gizmo (Default: 1)
  101684. */
  101685. scaleRatio: number;
  101686. /**
  101687. * Disposes of the gizmo
  101688. */
  101689. dispose(): void;
  101690. /**
  101691. * CustomMeshes are not supported by this gizmo
  101692. * @param mesh The mesh to replace the default mesh of the gizmo
  101693. */
  101694. setCustomMesh(mesh: Mesh): void;
  101695. }
  101696. }
  101697. declare module BABYLON {
  101698. /**
  101699. * Gizmo that enables dragging a mesh along 3 axis
  101700. */
  101701. export class PositionGizmo extends Gizmo {
  101702. /**
  101703. * Internal gizmo used for interactions on the x axis
  101704. */
  101705. xGizmo: AxisDragGizmo;
  101706. /**
  101707. * Internal gizmo used for interactions on the y axis
  101708. */
  101709. yGizmo: AxisDragGizmo;
  101710. /**
  101711. * Internal gizmo used for interactions on the z axis
  101712. */
  101713. zGizmo: AxisDragGizmo;
  101714. /** Fires an event when any of it's sub gizmos are dragged */
  101715. onDragStartObservable: Observable<{}>;
  101716. /** Fires an event when any of it's sub gizmos are released from dragging */
  101717. onDragEndObservable: Observable<{}>;
  101718. attachedMesh: Nullable<AbstractMesh>;
  101719. /**
  101720. * Creates a PositionGizmo
  101721. * @param gizmoLayer The utility layer the gizmo will be added to
  101722. */
  101723. constructor(gizmoLayer?: UtilityLayerRenderer);
  101724. updateGizmoRotationToMatchAttachedMesh: boolean;
  101725. /**
  101726. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101727. */
  101728. snapDistance: number;
  101729. /**
  101730. * Ratio for the scale of the gizmo (Default: 1)
  101731. */
  101732. scaleRatio: number;
  101733. /**
  101734. * Disposes of the gizmo
  101735. */
  101736. dispose(): void;
  101737. /**
  101738. * CustomMeshes are not supported by this gizmo
  101739. * @param mesh The mesh to replace the default mesh of the gizmo
  101740. */
  101741. setCustomMesh(mesh: Mesh): void;
  101742. }
  101743. }
  101744. declare module BABYLON {
  101745. /**
  101746. * Class containing static functions to help procedurally build meshes
  101747. */
  101748. export class PolyhedronBuilder {
  101749. /**
  101750. * Creates a polyhedron mesh
  101751. * * 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
  101752. * * The parameter `size` (positive float, default 1) sets the polygon size
  101753. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101754. * * 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`
  101755. * * 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
  101756. * * 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)`)
  101757. * * 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
  101758. * * 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
  101759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101762. * @param name defines the name of the mesh
  101763. * @param options defines the options used to create the mesh
  101764. * @param scene defines the hosting scene
  101765. * @returns the polyhedron mesh
  101766. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  101767. */
  101768. static CreatePolyhedron(name: string, options: {
  101769. type?: number;
  101770. size?: number;
  101771. sizeX?: number;
  101772. sizeY?: number;
  101773. sizeZ?: number;
  101774. custom?: any;
  101775. faceUV?: Vector4[];
  101776. faceColors?: Color4[];
  101777. flat?: boolean;
  101778. updatable?: boolean;
  101779. sideOrientation?: number;
  101780. frontUVs?: Vector4;
  101781. backUVs?: Vector4;
  101782. }, scene?: Nullable<Scene>): Mesh;
  101783. }
  101784. }
  101785. declare module BABYLON {
  101786. /**
  101787. * Gizmo that enables scaling a mesh along 3 axis
  101788. */
  101789. export class ScaleGizmo extends Gizmo {
  101790. /**
  101791. * Internal gizmo used for interactions on the x axis
  101792. */
  101793. xGizmo: AxisScaleGizmo;
  101794. /**
  101795. * Internal gizmo used for interactions on the y axis
  101796. */
  101797. yGizmo: AxisScaleGizmo;
  101798. /**
  101799. * Internal gizmo used for interactions on the z axis
  101800. */
  101801. zGizmo: AxisScaleGizmo;
  101802. /**
  101803. * Internal gizmo used to scale all axis equally
  101804. */
  101805. uniformScaleGizmo: AxisScaleGizmo;
  101806. /** Fires an event when any of it's sub gizmos are dragged */
  101807. onDragStartObservable: Observable<{}>;
  101808. /** Fires an event when any of it's sub gizmos are released from dragging */
  101809. onDragEndObservable: Observable<{}>;
  101810. attachedMesh: Nullable<AbstractMesh>;
  101811. /**
  101812. * Creates a ScaleGizmo
  101813. * @param gizmoLayer The utility layer the gizmo will be added to
  101814. */
  101815. constructor(gizmoLayer?: UtilityLayerRenderer);
  101816. updateGizmoRotationToMatchAttachedMesh: boolean;
  101817. /**
  101818. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101819. */
  101820. snapDistance: number;
  101821. /**
  101822. * Ratio for the scale of the gizmo (Default: 1)
  101823. */
  101824. scaleRatio: number;
  101825. /**
  101826. * Disposes of the gizmo
  101827. */
  101828. dispose(): void;
  101829. }
  101830. }
  101831. declare module BABYLON {
  101832. /**
  101833. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  101834. */
  101835. export class GizmoManager implements IDisposable {
  101836. private scene;
  101837. /**
  101838. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  101839. */
  101840. gizmos: {
  101841. positionGizmo: Nullable<PositionGizmo>;
  101842. rotationGizmo: Nullable<RotationGizmo>;
  101843. scaleGizmo: Nullable<ScaleGizmo>;
  101844. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  101845. };
  101846. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  101847. clearGizmoOnEmptyPointerEvent: boolean;
  101848. /** Fires an event when the manager is attached to a mesh */
  101849. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  101850. private _gizmosEnabled;
  101851. private _pointerObserver;
  101852. private _attachedMesh;
  101853. private _boundingBoxColor;
  101854. private _defaultUtilityLayer;
  101855. private _defaultKeepDepthUtilityLayer;
  101856. /**
  101857. * When bounding box gizmo is enabled, this can be used to track drag/end events
  101858. */
  101859. boundingBoxDragBehavior: SixDofDragBehavior;
  101860. /**
  101861. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  101862. */
  101863. attachableMeshes: Nullable<Array<AbstractMesh>>;
  101864. /**
  101865. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  101866. */
  101867. usePointerToAttachGizmos: boolean;
  101868. /**
  101869. * Instatiates a gizmo manager
  101870. * @param scene the scene to overlay the gizmos on top of
  101871. */
  101872. constructor(scene: Scene);
  101873. /**
  101874. * Attaches a set of gizmos to the specified mesh
  101875. * @param mesh The mesh the gizmo's should be attached to
  101876. */
  101877. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  101878. /**
  101879. * If the position gizmo is enabled
  101880. */
  101881. positionGizmoEnabled: boolean;
  101882. /**
  101883. * If the rotation gizmo is enabled
  101884. */
  101885. rotationGizmoEnabled: boolean;
  101886. /**
  101887. * If the scale gizmo is enabled
  101888. */
  101889. scaleGizmoEnabled: boolean;
  101890. /**
  101891. * If the boundingBox gizmo is enabled
  101892. */
  101893. boundingBoxGizmoEnabled: boolean;
  101894. /**
  101895. * Disposes of the gizmo manager
  101896. */
  101897. dispose(): void;
  101898. }
  101899. }
  101900. declare module BABYLON {
  101901. /**
  101902. * A directional light is defined by a direction (what a surprise!).
  101903. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  101904. * 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.
  101905. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101906. */
  101907. export class DirectionalLight extends ShadowLight {
  101908. private _shadowFrustumSize;
  101909. /**
  101910. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101911. */
  101912. /**
  101913. * Specifies a fix frustum size for the shadow generation.
  101914. */
  101915. shadowFrustumSize: number;
  101916. private _shadowOrthoScale;
  101917. /**
  101918. * Gets the shadow projection scale against the optimal computed one.
  101919. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101920. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101921. */
  101922. /**
  101923. * Sets the shadow projection scale against the optimal computed one.
  101924. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101925. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101926. */
  101927. shadowOrthoScale: number;
  101928. /**
  101929. * Automatically compute the projection matrix to best fit (including all the casters)
  101930. * on each frame.
  101931. */
  101932. autoUpdateExtends: boolean;
  101933. private _orthoLeft;
  101934. private _orthoRight;
  101935. private _orthoTop;
  101936. private _orthoBottom;
  101937. /**
  101938. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  101939. * The directional light is emitted from everywhere in the given direction.
  101940. * It can cast shadows.
  101941. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101942. * @param name The friendly name of the light
  101943. * @param direction The direction of the light
  101944. * @param scene The scene the light belongs to
  101945. */
  101946. constructor(name: string, direction: Vector3, scene: Scene);
  101947. /**
  101948. * Returns the string "DirectionalLight".
  101949. * @return The class name
  101950. */
  101951. getClassName(): string;
  101952. /**
  101953. * Returns the integer 1.
  101954. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101955. */
  101956. getTypeID(): number;
  101957. /**
  101958. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  101959. * Returns the DirectionalLight Shadow projection matrix.
  101960. */
  101961. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101962. /**
  101963. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  101964. * Returns the DirectionalLight Shadow projection matrix.
  101965. */
  101966. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  101967. /**
  101968. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  101969. * Returns the DirectionalLight Shadow projection matrix.
  101970. */
  101971. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101972. protected _buildUniformLayout(): void;
  101973. /**
  101974. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  101975. * @param effect The effect to update
  101976. * @param lightIndex The index of the light in the effect to update
  101977. * @returns The directional light
  101978. */
  101979. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  101980. /**
  101981. * Gets the minZ used for shadow according to both the scene and the light.
  101982. *
  101983. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101984. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101985. * @param activeCamera The camera we are returning the min for
  101986. * @returns the depth min z
  101987. */
  101988. getDepthMinZ(activeCamera: Camera): number;
  101989. /**
  101990. * Gets the maxZ used for shadow according to both the scene and the light.
  101991. *
  101992. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101993. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101994. * @param activeCamera The camera we are returning the max for
  101995. * @returns the depth max z
  101996. */
  101997. getDepthMaxZ(activeCamera: Camera): number;
  101998. /**
  101999. * Prepares the list of defines specific to the light type.
  102000. * @param defines the list of defines
  102001. * @param lightIndex defines the index of the light for the effect
  102002. */
  102003. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102004. }
  102005. }
  102006. declare module BABYLON {
  102007. /**
  102008. * Class containing static functions to help procedurally build meshes
  102009. */
  102010. export class HemisphereBuilder {
  102011. /**
  102012. * Creates a hemisphere mesh
  102013. * @param name defines the name of the mesh
  102014. * @param options defines the options used to create the mesh
  102015. * @param scene defines the hosting scene
  102016. * @returns the hemisphere mesh
  102017. */
  102018. static CreateHemisphere(name: string, options: {
  102019. segments?: number;
  102020. diameter?: number;
  102021. sideOrientation?: number;
  102022. }, scene: any): Mesh;
  102023. }
  102024. }
  102025. declare module BABYLON {
  102026. /**
  102027. * A spot light is defined by a position, a direction, an angle, and an exponent.
  102028. * These values define a cone of light starting from the position, emitting toward the direction.
  102029. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  102030. * and the exponent defines the speed of the decay of the light with distance (reach).
  102031. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102032. */
  102033. export class SpotLight extends ShadowLight {
  102034. private _angle;
  102035. private _innerAngle;
  102036. private _cosHalfAngle;
  102037. private _lightAngleScale;
  102038. private _lightAngleOffset;
  102039. /**
  102040. * Gets the cone angle of the spot light in Radians.
  102041. */
  102042. /**
  102043. * Sets the cone angle of the spot light in Radians.
  102044. */
  102045. angle: number;
  102046. /**
  102047. * Only used in gltf falloff mode, this defines the angle where
  102048. * the directional falloff will start before cutting at angle which could be seen
  102049. * as outer angle.
  102050. */
  102051. /**
  102052. * Only used in gltf falloff mode, this defines the angle where
  102053. * the directional falloff will start before cutting at angle which could be seen
  102054. * as outer angle.
  102055. */
  102056. innerAngle: number;
  102057. private _shadowAngleScale;
  102058. /**
  102059. * Allows scaling the angle of the light for shadow generation only.
  102060. */
  102061. /**
  102062. * Allows scaling the angle of the light for shadow generation only.
  102063. */
  102064. shadowAngleScale: number;
  102065. /**
  102066. * The light decay speed with the distance from the emission spot.
  102067. */
  102068. exponent: number;
  102069. private _projectionTextureMatrix;
  102070. /**
  102071. * Allows reading the projecton texture
  102072. */
  102073. readonly projectionTextureMatrix: Matrix;
  102074. protected _projectionTextureLightNear: number;
  102075. /**
  102076. * Gets the near clip of the Spotlight for texture projection.
  102077. */
  102078. /**
  102079. * Sets the near clip of the Spotlight for texture projection.
  102080. */
  102081. projectionTextureLightNear: number;
  102082. protected _projectionTextureLightFar: number;
  102083. /**
  102084. * Gets the far clip of the Spotlight for texture projection.
  102085. */
  102086. /**
  102087. * Sets the far clip of the Spotlight for texture projection.
  102088. */
  102089. projectionTextureLightFar: number;
  102090. protected _projectionTextureUpDirection: Vector3;
  102091. /**
  102092. * Gets the Up vector of the Spotlight for texture projection.
  102093. */
  102094. /**
  102095. * Sets the Up vector of the Spotlight for texture projection.
  102096. */
  102097. projectionTextureUpDirection: Vector3;
  102098. private _projectionTexture;
  102099. /**
  102100. * Gets the projection texture of the light.
  102101. */
  102102. /**
  102103. * Sets the projection texture of the light.
  102104. */
  102105. projectionTexture: Nullable<BaseTexture>;
  102106. private _projectionTextureViewLightDirty;
  102107. private _projectionTextureProjectionLightDirty;
  102108. private _projectionTextureDirty;
  102109. private _projectionTextureViewTargetVector;
  102110. private _projectionTextureViewLightMatrix;
  102111. private _projectionTextureProjectionLightMatrix;
  102112. private _projectionTextureScalingMatrix;
  102113. /**
  102114. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  102115. * It can cast shadows.
  102116. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102117. * @param name The light friendly name
  102118. * @param position The position of the spot light in the scene
  102119. * @param direction The direction of the light in the scene
  102120. * @param angle The cone angle of the light in Radians
  102121. * @param exponent The light decay speed with the distance from the emission spot
  102122. * @param scene The scene the lights belongs to
  102123. */
  102124. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  102125. /**
  102126. * Returns the string "SpotLight".
  102127. * @returns the class name
  102128. */
  102129. getClassName(): string;
  102130. /**
  102131. * Returns the integer 2.
  102132. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102133. */
  102134. getTypeID(): number;
  102135. /**
  102136. * Overrides the direction setter to recompute the projection texture view light Matrix.
  102137. */
  102138. protected _setDirection(value: Vector3): void;
  102139. /**
  102140. * Overrides the position setter to recompute the projection texture view light Matrix.
  102141. */
  102142. protected _setPosition(value: Vector3): void;
  102143. /**
  102144. * 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.
  102145. * Returns the SpotLight.
  102146. */
  102147. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102148. protected _computeProjectionTextureViewLightMatrix(): void;
  102149. protected _computeProjectionTextureProjectionLightMatrix(): void;
  102150. /**
  102151. * Main function for light texture projection matrix computing.
  102152. */
  102153. protected _computeProjectionTextureMatrix(): void;
  102154. protected _buildUniformLayout(): void;
  102155. private _computeAngleValues;
  102156. /**
  102157. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  102158. * @param effect The effect to update
  102159. * @param lightIndex The index of the light in the effect to update
  102160. * @returns The spot light
  102161. */
  102162. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  102163. /**
  102164. * Disposes the light and the associated resources.
  102165. */
  102166. dispose(): void;
  102167. /**
  102168. * Prepares the list of defines specific to the light type.
  102169. * @param defines the list of defines
  102170. * @param lightIndex defines the index of the light for the effect
  102171. */
  102172. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102173. }
  102174. }
  102175. declare module BABYLON {
  102176. /**
  102177. * Gizmo that enables viewing a light
  102178. */
  102179. export class LightGizmo extends Gizmo {
  102180. private _lightMesh;
  102181. private _material;
  102182. /**
  102183. * Creates a LightGizmo
  102184. * @param gizmoLayer The utility layer the gizmo will be added to
  102185. */
  102186. constructor(gizmoLayer?: UtilityLayerRenderer);
  102187. private _light;
  102188. /**
  102189. * The light that the gizmo is attached to
  102190. */
  102191. light: Nullable<Light>;
  102192. /**
  102193. * @hidden
  102194. * Updates the gizmo to match the attached mesh's position/rotation
  102195. */
  102196. protected _update(): void;
  102197. private static _Scale;
  102198. /**
  102199. * Creates the lines for a light mesh
  102200. */
  102201. private static _createLightLines;
  102202. private static _CreateHemisphericLightMesh;
  102203. private static _CreatePointLightMesh;
  102204. private static _CreateSpotLightMesh;
  102205. private static _CreateDirectionalLightMesh;
  102206. }
  102207. }
  102208. declare module BABYLON {
  102209. /** @hidden */
  102210. export var backgroundFragmentDeclaration: {
  102211. name: string;
  102212. shader: string;
  102213. };
  102214. }
  102215. declare module BABYLON {
  102216. /** @hidden */
  102217. export var backgroundUboDeclaration: {
  102218. name: string;
  102219. shader: string;
  102220. };
  102221. }
  102222. declare module BABYLON {
  102223. /** @hidden */
  102224. export var backgroundPixelShader: {
  102225. name: string;
  102226. shader: string;
  102227. };
  102228. }
  102229. declare module BABYLON {
  102230. /** @hidden */
  102231. export var backgroundVertexDeclaration: {
  102232. name: string;
  102233. shader: string;
  102234. };
  102235. }
  102236. declare module BABYLON {
  102237. /** @hidden */
  102238. export var backgroundVertexShader: {
  102239. name: string;
  102240. shader: string;
  102241. };
  102242. }
  102243. declare module BABYLON {
  102244. /**
  102245. * Background material used to create an efficient environement around your scene.
  102246. */
  102247. export class BackgroundMaterial extends PushMaterial {
  102248. /**
  102249. * Standard reflectance value at parallel view angle.
  102250. */
  102251. static StandardReflectance0: number;
  102252. /**
  102253. * Standard reflectance value at grazing angle.
  102254. */
  102255. static StandardReflectance90: number;
  102256. protected _primaryColor: Color3;
  102257. /**
  102258. * Key light Color (multiply against the environement texture)
  102259. */
  102260. primaryColor: Color3;
  102261. protected __perceptualColor: Nullable<Color3>;
  102262. /**
  102263. * Experimental Internal Use Only.
  102264. *
  102265. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  102266. * This acts as a helper to set the primary color to a more "human friendly" value.
  102267. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  102268. * output color as close as possible from the chosen value.
  102269. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  102270. * part of lighting setup.)
  102271. */
  102272. _perceptualColor: Nullable<Color3>;
  102273. protected _primaryColorShadowLevel: float;
  102274. /**
  102275. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  102276. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  102277. */
  102278. primaryColorShadowLevel: float;
  102279. protected _primaryColorHighlightLevel: float;
  102280. /**
  102281. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  102282. * The primary color is used at the level chosen to define what the white area would look.
  102283. */
  102284. primaryColorHighlightLevel: float;
  102285. protected _reflectionTexture: Nullable<BaseTexture>;
  102286. /**
  102287. * Reflection Texture used in the material.
  102288. * Should be author in a specific way for the best result (refer to the documentation).
  102289. */
  102290. reflectionTexture: Nullable<BaseTexture>;
  102291. protected _reflectionBlur: float;
  102292. /**
  102293. * Reflection Texture level of blur.
  102294. *
  102295. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  102296. * texture twice.
  102297. */
  102298. reflectionBlur: float;
  102299. protected _diffuseTexture: Nullable<BaseTexture>;
  102300. /**
  102301. * Diffuse Texture used in the material.
  102302. * Should be author in a specific way for the best result (refer to the documentation).
  102303. */
  102304. diffuseTexture: Nullable<BaseTexture>;
  102305. protected _shadowLights: Nullable<IShadowLight[]>;
  102306. /**
  102307. * Specify the list of lights casting shadow on the material.
  102308. * All scene shadow lights will be included if null.
  102309. */
  102310. shadowLights: Nullable<IShadowLight[]>;
  102311. protected _shadowLevel: float;
  102312. /**
  102313. * Helps adjusting the shadow to a softer level if required.
  102314. * 0 means black shadows and 1 means no shadows.
  102315. */
  102316. shadowLevel: float;
  102317. protected _sceneCenter: Vector3;
  102318. /**
  102319. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  102320. * It is usually zero but might be interesting to modify according to your setup.
  102321. */
  102322. sceneCenter: Vector3;
  102323. protected _opacityFresnel: boolean;
  102324. /**
  102325. * This helps specifying that the material is falling off to the sky box at grazing angle.
  102326. * This helps ensuring a nice transition when the camera goes under the ground.
  102327. */
  102328. opacityFresnel: boolean;
  102329. protected _reflectionFresnel: boolean;
  102330. /**
  102331. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  102332. * This helps adding a mirror texture on the ground.
  102333. */
  102334. reflectionFresnel: boolean;
  102335. protected _reflectionFalloffDistance: number;
  102336. /**
  102337. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  102338. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  102339. */
  102340. reflectionFalloffDistance: number;
  102341. protected _reflectionAmount: number;
  102342. /**
  102343. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  102344. */
  102345. reflectionAmount: number;
  102346. protected _reflectionReflectance0: number;
  102347. /**
  102348. * This specifies the weight of the reflection at grazing angle.
  102349. */
  102350. reflectionReflectance0: number;
  102351. protected _reflectionReflectance90: number;
  102352. /**
  102353. * This specifies the weight of the reflection at a perpendicular point of view.
  102354. */
  102355. reflectionReflectance90: number;
  102356. /**
  102357. * Sets the reflection reflectance fresnel values according to the default standard
  102358. * empirically know to work well :-)
  102359. */
  102360. reflectionStandardFresnelWeight: number;
  102361. protected _useRGBColor: boolean;
  102362. /**
  102363. * Helps to directly use the maps channels instead of their level.
  102364. */
  102365. useRGBColor: boolean;
  102366. protected _enableNoise: boolean;
  102367. /**
  102368. * This helps reducing the banding effect that could occur on the background.
  102369. */
  102370. enableNoise: boolean;
  102371. /**
  102372. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102373. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  102374. * Recommended to be keep at 1.0 except for special cases.
  102375. */
  102376. fovMultiplier: number;
  102377. private _fovMultiplier;
  102378. /**
  102379. * Enable the FOV adjustment feature controlled by fovMultiplier.
  102380. */
  102381. useEquirectangularFOV: boolean;
  102382. private _maxSimultaneousLights;
  102383. /**
  102384. * Number of Simultaneous lights allowed on the material.
  102385. */
  102386. maxSimultaneousLights: int;
  102387. /**
  102388. * Default configuration related to image processing available in the Background Material.
  102389. */
  102390. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102391. /**
  102392. * Keep track of the image processing observer to allow dispose and replace.
  102393. */
  102394. private _imageProcessingObserver;
  102395. /**
  102396. * Attaches a new image processing configuration to the PBR Material.
  102397. * @param configuration (if null the scene configuration will be use)
  102398. */
  102399. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102400. /**
  102401. * Gets the image processing configuration used either in this material.
  102402. */
  102403. /**
  102404. * Sets the Default image processing configuration used either in the this material.
  102405. *
  102406. * If sets to null, the scene one is in use.
  102407. */
  102408. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  102409. /**
  102410. * Gets wether the color curves effect is enabled.
  102411. */
  102412. /**
  102413. * Sets wether the color curves effect is enabled.
  102414. */
  102415. cameraColorCurvesEnabled: boolean;
  102416. /**
  102417. * Gets wether the color grading effect is enabled.
  102418. */
  102419. /**
  102420. * Gets wether the color grading effect is enabled.
  102421. */
  102422. cameraColorGradingEnabled: boolean;
  102423. /**
  102424. * Gets wether tonemapping is enabled or not.
  102425. */
  102426. /**
  102427. * Sets wether tonemapping is enabled or not
  102428. */
  102429. cameraToneMappingEnabled: boolean;
  102430. /**
  102431. * The camera exposure used on this material.
  102432. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102433. * This corresponds to a photographic exposure.
  102434. */
  102435. /**
  102436. * The camera exposure used on this material.
  102437. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102438. * This corresponds to a photographic exposure.
  102439. */
  102440. cameraExposure: float;
  102441. /**
  102442. * Gets The camera contrast used on this material.
  102443. */
  102444. /**
  102445. * Sets The camera contrast used on this material.
  102446. */
  102447. cameraContrast: float;
  102448. /**
  102449. * Gets the Color Grading 2D Lookup Texture.
  102450. */
  102451. /**
  102452. * Sets the Color Grading 2D Lookup Texture.
  102453. */
  102454. cameraColorGradingTexture: Nullable<BaseTexture>;
  102455. /**
  102456. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102457. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102458. * 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;
  102459. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102460. */
  102461. /**
  102462. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102463. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102464. * 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;
  102465. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102466. */
  102467. cameraColorCurves: Nullable<ColorCurves>;
  102468. /**
  102469. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  102470. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  102471. */
  102472. switchToBGR: boolean;
  102473. private _renderTargets;
  102474. private _reflectionControls;
  102475. private _white;
  102476. private _primaryShadowColor;
  102477. private _primaryHighlightColor;
  102478. /**
  102479. * Instantiates a Background Material in the given scene
  102480. * @param name The friendly name of the material
  102481. * @param scene The scene to add the material to
  102482. */
  102483. constructor(name: string, scene: Scene);
  102484. /**
  102485. * Gets a boolean indicating that current material needs to register RTT
  102486. */
  102487. readonly hasRenderTargetTextures: boolean;
  102488. /**
  102489. * The entire material has been created in order to prevent overdraw.
  102490. * @returns false
  102491. */
  102492. needAlphaTesting(): boolean;
  102493. /**
  102494. * The entire material has been created in order to prevent overdraw.
  102495. * @returns true if blending is enable
  102496. */
  102497. needAlphaBlending(): boolean;
  102498. /**
  102499. * Checks wether the material is ready to be rendered for a given mesh.
  102500. * @param mesh The mesh to render
  102501. * @param subMesh The submesh to check against
  102502. * @param useInstances Specify wether or not the material is used with instances
  102503. * @returns true if all the dependencies are ready (Textures, Effects...)
  102504. */
  102505. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102506. /**
  102507. * Compute the primary color according to the chosen perceptual color.
  102508. */
  102509. private _computePrimaryColorFromPerceptualColor;
  102510. /**
  102511. * Compute the highlights and shadow colors according to their chosen levels.
  102512. */
  102513. private _computePrimaryColors;
  102514. /**
  102515. * Build the uniform buffer used in the material.
  102516. */
  102517. buildUniformLayout(): void;
  102518. /**
  102519. * Unbind the material.
  102520. */
  102521. unbind(): void;
  102522. /**
  102523. * Bind only the world matrix to the material.
  102524. * @param world The world matrix to bind.
  102525. */
  102526. bindOnlyWorldMatrix(world: Matrix): void;
  102527. /**
  102528. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  102529. * @param world The world matrix to bind.
  102530. * @param subMesh The submesh to bind for.
  102531. */
  102532. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102533. /**
  102534. * Dispose the material.
  102535. * @param forceDisposeEffect Force disposal of the associated effect.
  102536. * @param forceDisposeTextures Force disposal of the associated textures.
  102537. */
  102538. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102539. /**
  102540. * Clones the material.
  102541. * @param name The cloned name.
  102542. * @returns The cloned material.
  102543. */
  102544. clone(name: string): BackgroundMaterial;
  102545. /**
  102546. * Serializes the current material to its JSON representation.
  102547. * @returns The JSON representation.
  102548. */
  102549. serialize(): any;
  102550. /**
  102551. * Gets the class name of the material
  102552. * @returns "BackgroundMaterial"
  102553. */
  102554. getClassName(): string;
  102555. /**
  102556. * Parse a JSON input to create back a background material.
  102557. * @param source The JSON data to parse
  102558. * @param scene The scene to create the parsed material in
  102559. * @param rootUrl The root url of the assets the material depends upon
  102560. * @returns the instantiated BackgroundMaterial.
  102561. */
  102562. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  102563. }
  102564. }
  102565. declare module BABYLON {
  102566. /**
  102567. * Represents the different options available during the creation of
  102568. * a Environment helper.
  102569. *
  102570. * This can control the default ground, skybox and image processing setup of your scene.
  102571. */
  102572. export interface IEnvironmentHelperOptions {
  102573. /**
  102574. * Specifies wether or not to create a ground.
  102575. * True by default.
  102576. */
  102577. createGround: boolean;
  102578. /**
  102579. * Specifies the ground size.
  102580. * 15 by default.
  102581. */
  102582. groundSize: number;
  102583. /**
  102584. * The texture used on the ground for the main color.
  102585. * Comes from the BabylonJS CDN by default.
  102586. *
  102587. * Remarks: Can be either a texture or a url.
  102588. */
  102589. groundTexture: string | BaseTexture;
  102590. /**
  102591. * The color mixed in the ground texture by default.
  102592. * BabylonJS clearColor by default.
  102593. */
  102594. groundColor: Color3;
  102595. /**
  102596. * Specifies the ground opacity.
  102597. * 1 by default.
  102598. */
  102599. groundOpacity: number;
  102600. /**
  102601. * Enables the ground to receive shadows.
  102602. * True by default.
  102603. */
  102604. enableGroundShadow: boolean;
  102605. /**
  102606. * Helps preventing the shadow to be fully black on the ground.
  102607. * 0.5 by default.
  102608. */
  102609. groundShadowLevel: number;
  102610. /**
  102611. * Creates a mirror texture attach to the ground.
  102612. * false by default.
  102613. */
  102614. enableGroundMirror: boolean;
  102615. /**
  102616. * Specifies the ground mirror size ratio.
  102617. * 0.3 by default as the default kernel is 64.
  102618. */
  102619. groundMirrorSizeRatio: number;
  102620. /**
  102621. * Specifies the ground mirror blur kernel size.
  102622. * 64 by default.
  102623. */
  102624. groundMirrorBlurKernel: number;
  102625. /**
  102626. * Specifies the ground mirror visibility amount.
  102627. * 1 by default
  102628. */
  102629. groundMirrorAmount: number;
  102630. /**
  102631. * Specifies the ground mirror reflectance weight.
  102632. * This uses the standard weight of the background material to setup the fresnel effect
  102633. * of the mirror.
  102634. * 1 by default.
  102635. */
  102636. groundMirrorFresnelWeight: number;
  102637. /**
  102638. * Specifies the ground mirror Falloff distance.
  102639. * This can helps reducing the size of the reflection.
  102640. * 0 by Default.
  102641. */
  102642. groundMirrorFallOffDistance: number;
  102643. /**
  102644. * Specifies the ground mirror texture type.
  102645. * Unsigned Int by Default.
  102646. */
  102647. groundMirrorTextureType: number;
  102648. /**
  102649. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  102650. * the shown objects.
  102651. */
  102652. groundYBias: number;
  102653. /**
  102654. * Specifies wether or not to create a skybox.
  102655. * True by default.
  102656. */
  102657. createSkybox: boolean;
  102658. /**
  102659. * Specifies the skybox size.
  102660. * 20 by default.
  102661. */
  102662. skyboxSize: number;
  102663. /**
  102664. * The texture used on the skybox for the main color.
  102665. * Comes from the BabylonJS CDN by default.
  102666. *
  102667. * Remarks: Can be either a texture or a url.
  102668. */
  102669. skyboxTexture: string | BaseTexture;
  102670. /**
  102671. * The color mixed in the skybox texture by default.
  102672. * BabylonJS clearColor by default.
  102673. */
  102674. skyboxColor: Color3;
  102675. /**
  102676. * The background rotation around the Y axis of the scene.
  102677. * This helps aligning the key lights of your scene with the background.
  102678. * 0 by default.
  102679. */
  102680. backgroundYRotation: number;
  102681. /**
  102682. * Compute automatically the size of the elements to best fit with the scene.
  102683. */
  102684. sizeAuto: boolean;
  102685. /**
  102686. * Default position of the rootMesh if autoSize is not true.
  102687. */
  102688. rootPosition: Vector3;
  102689. /**
  102690. * Sets up the image processing in the scene.
  102691. * true by default.
  102692. */
  102693. setupImageProcessing: boolean;
  102694. /**
  102695. * The texture used as your environment texture in the scene.
  102696. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  102697. *
  102698. * Remarks: Can be either a texture or a url.
  102699. */
  102700. environmentTexture: string | BaseTexture;
  102701. /**
  102702. * The value of the exposure to apply to the scene.
  102703. * 0.6 by default if setupImageProcessing is true.
  102704. */
  102705. cameraExposure: number;
  102706. /**
  102707. * The value of the contrast to apply to the scene.
  102708. * 1.6 by default if setupImageProcessing is true.
  102709. */
  102710. cameraContrast: number;
  102711. /**
  102712. * Specifies wether or not tonemapping should be enabled in the scene.
  102713. * true by default if setupImageProcessing is true.
  102714. */
  102715. toneMappingEnabled: boolean;
  102716. }
  102717. /**
  102718. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  102719. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  102720. * It also helps with the default setup of your imageProcessing configuration.
  102721. */
  102722. export class EnvironmentHelper {
  102723. /**
  102724. * Default ground texture URL.
  102725. */
  102726. private static _groundTextureCDNUrl;
  102727. /**
  102728. * Default skybox texture URL.
  102729. */
  102730. private static _skyboxTextureCDNUrl;
  102731. /**
  102732. * Default environment texture URL.
  102733. */
  102734. private static _environmentTextureCDNUrl;
  102735. /**
  102736. * Creates the default options for the helper.
  102737. */
  102738. private static _getDefaultOptions;
  102739. private _rootMesh;
  102740. /**
  102741. * Gets the root mesh created by the helper.
  102742. */
  102743. readonly rootMesh: Mesh;
  102744. private _skybox;
  102745. /**
  102746. * Gets the skybox created by the helper.
  102747. */
  102748. readonly skybox: Nullable<Mesh>;
  102749. private _skyboxTexture;
  102750. /**
  102751. * Gets the skybox texture created by the helper.
  102752. */
  102753. readonly skyboxTexture: Nullable<BaseTexture>;
  102754. private _skyboxMaterial;
  102755. /**
  102756. * Gets the skybox material created by the helper.
  102757. */
  102758. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  102759. private _ground;
  102760. /**
  102761. * Gets the ground mesh created by the helper.
  102762. */
  102763. readonly ground: Nullable<Mesh>;
  102764. private _groundTexture;
  102765. /**
  102766. * Gets the ground texture created by the helper.
  102767. */
  102768. readonly groundTexture: Nullable<BaseTexture>;
  102769. private _groundMirror;
  102770. /**
  102771. * Gets the ground mirror created by the helper.
  102772. */
  102773. readonly groundMirror: Nullable<MirrorTexture>;
  102774. /**
  102775. * Gets the ground mirror render list to helps pushing the meshes
  102776. * you wish in the ground reflection.
  102777. */
  102778. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  102779. private _groundMaterial;
  102780. /**
  102781. * Gets the ground material created by the helper.
  102782. */
  102783. readonly groundMaterial: Nullable<BackgroundMaterial>;
  102784. /**
  102785. * Stores the creation options.
  102786. */
  102787. private readonly _scene;
  102788. private _options;
  102789. /**
  102790. * This observable will be notified with any error during the creation of the environment,
  102791. * mainly texture creation errors.
  102792. */
  102793. onErrorObservable: Observable<{
  102794. message?: string;
  102795. exception?: any;
  102796. }>;
  102797. /**
  102798. * constructor
  102799. * @param options Defines the options we want to customize the helper
  102800. * @param scene The scene to add the material to
  102801. */
  102802. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  102803. /**
  102804. * Updates the background according to the new options
  102805. * @param options
  102806. */
  102807. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  102808. /**
  102809. * Sets the primary color of all the available elements.
  102810. * @param color the main color to affect to the ground and the background
  102811. */
  102812. setMainColor(color: Color3): void;
  102813. /**
  102814. * Setup the image processing according to the specified options.
  102815. */
  102816. private _setupImageProcessing;
  102817. /**
  102818. * Setup the environment texture according to the specified options.
  102819. */
  102820. private _setupEnvironmentTexture;
  102821. /**
  102822. * Setup the background according to the specified options.
  102823. */
  102824. private _setupBackground;
  102825. /**
  102826. * Get the scene sizes according to the setup.
  102827. */
  102828. private _getSceneSize;
  102829. /**
  102830. * Setup the ground according to the specified options.
  102831. */
  102832. private _setupGround;
  102833. /**
  102834. * Setup the ground material according to the specified options.
  102835. */
  102836. private _setupGroundMaterial;
  102837. /**
  102838. * Setup the ground diffuse texture according to the specified options.
  102839. */
  102840. private _setupGroundDiffuseTexture;
  102841. /**
  102842. * Setup the ground mirror texture according to the specified options.
  102843. */
  102844. private _setupGroundMirrorTexture;
  102845. /**
  102846. * Setup the ground to receive the mirror texture.
  102847. */
  102848. private _setupMirrorInGroundMaterial;
  102849. /**
  102850. * Setup the skybox according to the specified options.
  102851. */
  102852. private _setupSkybox;
  102853. /**
  102854. * Setup the skybox material according to the specified options.
  102855. */
  102856. private _setupSkyboxMaterial;
  102857. /**
  102858. * Setup the skybox reflection texture according to the specified options.
  102859. */
  102860. private _setupSkyboxReflectionTexture;
  102861. private _errorHandler;
  102862. /**
  102863. * Dispose all the elements created by the Helper.
  102864. */
  102865. dispose(): void;
  102866. }
  102867. }
  102868. declare module BABYLON {
  102869. /**
  102870. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  102871. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  102872. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  102873. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102874. */
  102875. export class PhotoDome extends TransformNode {
  102876. private _useDirectMapping;
  102877. /**
  102878. * The texture being displayed on the sphere
  102879. */
  102880. protected _photoTexture: Texture;
  102881. /**
  102882. * Gets or sets the texture being displayed on the sphere
  102883. */
  102884. photoTexture: Texture;
  102885. /**
  102886. * Observable raised when an error occured while loading the 360 image
  102887. */
  102888. onLoadErrorObservable: Observable<string>;
  102889. /**
  102890. * The skybox material
  102891. */
  102892. protected _material: BackgroundMaterial;
  102893. /**
  102894. * The surface used for the skybox
  102895. */
  102896. protected _mesh: Mesh;
  102897. /**
  102898. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102899. * Also see the options.resolution property.
  102900. */
  102901. fovMultiplier: number;
  102902. /**
  102903. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  102904. * @param name Element's name, child elements will append suffixes for their own names.
  102905. * @param urlsOfPhoto defines the url of the photo to display
  102906. * @param options defines an object containing optional or exposed sub element properties
  102907. * @param onError defines a callback called when an error occured while loading the texture
  102908. */
  102909. constructor(name: string, urlOfPhoto: string, options: {
  102910. resolution?: number;
  102911. size?: number;
  102912. useDirectMapping?: boolean;
  102913. faceForward?: boolean;
  102914. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  102915. /**
  102916. * Releases resources associated with this node.
  102917. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102918. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102919. */
  102920. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102921. }
  102922. }
  102923. declare module BABYLON {
  102924. /** @hidden */
  102925. export var rgbdDecodePixelShader: {
  102926. name: string;
  102927. shader: string;
  102928. };
  102929. }
  102930. declare module BABYLON {
  102931. /**
  102932. * Class used to host texture specific utilities
  102933. */
  102934. export class BRDFTextureTools {
  102935. /**
  102936. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  102937. * @param texture the texture to expand.
  102938. */
  102939. private static _ExpandDefaultBRDFTexture;
  102940. /**
  102941. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  102942. * @param scene defines the hosting scene
  102943. * @returns the environment BRDF texture
  102944. */
  102945. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  102946. private static _environmentBRDFBase64Texture;
  102947. }
  102948. }
  102949. declare module BABYLON {
  102950. /**
  102951. * @hidden
  102952. */
  102953. export interface IMaterialClearCoatDefines {
  102954. CLEARCOAT: boolean;
  102955. CLEARCOAT_DEFAULTIOR: boolean;
  102956. CLEARCOAT_TEXTURE: boolean;
  102957. CLEARCOAT_TEXTUREDIRECTUV: number;
  102958. CLEARCOAT_BUMP: boolean;
  102959. CLEARCOAT_BUMPDIRECTUV: number;
  102960. CLEARCOAT_TINT: boolean;
  102961. CLEARCOAT_TINT_TEXTURE: boolean;
  102962. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  102963. /** @hidden */
  102964. _areTexturesDirty: boolean;
  102965. }
  102966. /**
  102967. * Define the code related to the clear coat parameters of the pbr material.
  102968. */
  102969. export class PBRClearCoatConfiguration {
  102970. /**
  102971. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  102972. * The default fits with a polyurethane material.
  102973. */
  102974. private static readonly _DefaultIndiceOfRefraction;
  102975. private _isEnabled;
  102976. /**
  102977. * Defines if the clear coat is enabled in the material.
  102978. */
  102979. isEnabled: boolean;
  102980. /**
  102981. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  102982. */
  102983. intensity: number;
  102984. /**
  102985. * Defines the clear coat layer roughness.
  102986. */
  102987. roughness: number;
  102988. private _indiceOfRefraction;
  102989. /**
  102990. * Defines the indice of refraction of the clear coat.
  102991. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  102992. * The default fits with a polyurethane material.
  102993. * Changing the default value is more performance intensive.
  102994. */
  102995. indiceOfRefraction: number;
  102996. private _texture;
  102997. /**
  102998. * Stores the clear coat values in a texture.
  102999. */
  103000. texture: Nullable<BaseTexture>;
  103001. private _bumpTexture;
  103002. /**
  103003. * Define the clear coat specific bump texture.
  103004. */
  103005. bumpTexture: Nullable<BaseTexture>;
  103006. private _isTintEnabled;
  103007. /**
  103008. * Defines if the clear coat tint is enabled in the material.
  103009. */
  103010. isTintEnabled: boolean;
  103011. /**
  103012. * Defines the clear coat tint of the material.
  103013. * This is only use if tint is enabled
  103014. */
  103015. tintColor: Color3;
  103016. /**
  103017. * Defines the distance at which the tint color should be found in the
  103018. * clear coat media.
  103019. * This is only use if tint is enabled
  103020. */
  103021. tintColorAtDistance: number;
  103022. /**
  103023. * Defines the clear coat layer thickness.
  103024. * This is only use if tint is enabled
  103025. */
  103026. tintThickness: number;
  103027. private _tintTexture;
  103028. /**
  103029. * Stores the clear tint values in a texture.
  103030. * rgb is tint
  103031. * a is a thickness factor
  103032. */
  103033. tintTexture: Nullable<BaseTexture>;
  103034. /** @hidden */
  103035. private _internalMarkAllSubMeshesAsTexturesDirty;
  103036. /** @hidden */
  103037. _markAllSubMeshesAsTexturesDirty(): void;
  103038. /**
  103039. * Instantiate a new istance of clear coat configuration.
  103040. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103041. */
  103042. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103043. /**
  103044. * Gets wehter the submesh is ready to be used or not.
  103045. * @param defines the list of "defines" to update.
  103046. * @param scene defines the scene the material belongs to.
  103047. * @param engine defines the engine the material belongs to.
  103048. * @param disableBumpMap defines wether the material disables bump or not.
  103049. * @returns - boolean indicating that the submesh is ready or not.
  103050. */
  103051. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  103052. /**
  103053. * Checks to see if a texture is used in the material.
  103054. * @param defines the list of "defines" to update.
  103055. * @param scene defines the scene to the material belongs to.
  103056. */
  103057. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  103058. /**
  103059. * Binds the material data.
  103060. * @param uniformBuffer defines the Uniform buffer to fill in.
  103061. * @param scene defines the scene the material belongs to.
  103062. * @param engine defines the engine the material belongs to.
  103063. * @param disableBumpMap defines wether the material disables bump or not.
  103064. * @param isFrozen defines wether the material is frozen or not.
  103065. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  103066. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  103067. */
  103068. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  103069. /**
  103070. * Checks to see if a texture is used in the material.
  103071. * @param texture - Base texture to use.
  103072. * @returns - Boolean specifying if a texture is used in the material.
  103073. */
  103074. hasTexture(texture: BaseTexture): boolean;
  103075. /**
  103076. * Returns an array of the actively used textures.
  103077. * @param activeTextures Array of BaseTextures
  103078. */
  103079. getActiveTextures(activeTextures: BaseTexture[]): void;
  103080. /**
  103081. * Returns the animatable textures.
  103082. * @param animatables Array of animatable textures.
  103083. */
  103084. getAnimatables(animatables: IAnimatable[]): void;
  103085. /**
  103086. * Disposes the resources of the material.
  103087. * @param forceDisposeTextures - Forces the disposal of all textures.
  103088. */
  103089. dispose(forceDisposeTextures?: boolean): void;
  103090. /**
  103091. * Get the current class name of the texture useful for serialization or dynamic coding.
  103092. * @returns "PBRClearCoatConfiguration"
  103093. */
  103094. getClassName(): string;
  103095. /**
  103096. * Add fallbacks to the effect fallbacks list.
  103097. * @param defines defines the Base texture to use.
  103098. * @param fallbacks defines the current fallback list.
  103099. * @param currentRank defines the current fallback rank.
  103100. * @returns the new fallback rank.
  103101. */
  103102. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103103. /**
  103104. * Add the required uniforms to the current list.
  103105. * @param uniforms defines the current uniform list.
  103106. */
  103107. static AddUniforms(uniforms: string[]): void;
  103108. /**
  103109. * Add the required samplers to the current list.
  103110. * @param samplers defines the current sampler list.
  103111. */
  103112. static AddSamplers(samplers: string[]): void;
  103113. /**
  103114. * Add the required uniforms to the current buffer.
  103115. * @param uniformBuffer defines the current uniform buffer.
  103116. */
  103117. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103118. /**
  103119. * Makes a duplicate of the current configuration into another one.
  103120. * @param clearCoatConfiguration define the config where to copy the info
  103121. */
  103122. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  103123. /**
  103124. * Serializes this clear coat configuration.
  103125. * @returns - An object with the serialized config.
  103126. */
  103127. serialize(): any;
  103128. /**
  103129. * Parses a Clear Coat Configuration from a serialized object.
  103130. * @param source - Serialized object.
  103131. */
  103132. parse(source: any): void;
  103133. }
  103134. }
  103135. declare module BABYLON {
  103136. /**
  103137. * @hidden
  103138. */
  103139. export interface IMaterialAnisotropicDefines {
  103140. ANISOTROPIC: boolean;
  103141. ANISOTROPIC_TEXTURE: boolean;
  103142. ANISOTROPIC_TEXTUREDIRECTUV: number;
  103143. MAINUV1: boolean;
  103144. _areTexturesDirty: boolean;
  103145. _needUVs: boolean;
  103146. }
  103147. /**
  103148. * Define the code related to the anisotropic parameters of the pbr material.
  103149. */
  103150. export class PBRAnisotropicConfiguration {
  103151. private _isEnabled;
  103152. /**
  103153. * Defines if the anisotropy is enabled in the material.
  103154. */
  103155. isEnabled: boolean;
  103156. /**
  103157. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  103158. */
  103159. intensity: number;
  103160. /**
  103161. * Defines if the effect is along the tangents, bitangents or in between.
  103162. * By default, the effect is "strectching" the highlights along the tangents.
  103163. */
  103164. direction: Vector2;
  103165. private _texture;
  103166. /**
  103167. * Stores the anisotropy values in a texture.
  103168. * rg is direction (like normal from -1 to 1)
  103169. * b is a intensity
  103170. */
  103171. texture: Nullable<BaseTexture>;
  103172. /** @hidden */
  103173. private _internalMarkAllSubMeshesAsTexturesDirty;
  103174. /** @hidden */
  103175. _markAllSubMeshesAsTexturesDirty(): void;
  103176. /**
  103177. * Instantiate a new istance of anisotropy configuration.
  103178. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103179. */
  103180. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103181. /**
  103182. * Specifies that the submesh is ready to be used.
  103183. * @param defines the list of "defines" to update.
  103184. * @param scene defines the scene the material belongs to.
  103185. * @returns - boolean indicating that the submesh is ready or not.
  103186. */
  103187. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  103188. /**
  103189. * Checks to see if a texture is used in the material.
  103190. * @param defines the list of "defines" to update.
  103191. * @param mesh the mesh we are preparing the defines for.
  103192. * @param scene defines the scene the material belongs to.
  103193. */
  103194. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  103195. /**
  103196. * Binds the material data.
  103197. * @param uniformBuffer defines the Uniform buffer to fill in.
  103198. * @param scene defines the scene the material belongs to.
  103199. * @param isFrozen defines wether the material is frozen or not.
  103200. */
  103201. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103202. /**
  103203. * Checks to see if a texture is used in the material.
  103204. * @param texture - Base texture to use.
  103205. * @returns - Boolean specifying if a texture is used in the material.
  103206. */
  103207. hasTexture(texture: BaseTexture): boolean;
  103208. /**
  103209. * Returns an array of the actively used textures.
  103210. * @param activeTextures Array of BaseTextures
  103211. */
  103212. getActiveTextures(activeTextures: BaseTexture[]): void;
  103213. /**
  103214. * Returns the animatable textures.
  103215. * @param animatables Array of animatable textures.
  103216. */
  103217. getAnimatables(animatables: IAnimatable[]): void;
  103218. /**
  103219. * Disposes the resources of the material.
  103220. * @param forceDisposeTextures - Forces the disposal of all textures.
  103221. */
  103222. dispose(forceDisposeTextures?: boolean): void;
  103223. /**
  103224. * Get the current class name of the texture useful for serialization or dynamic coding.
  103225. * @returns "PBRAnisotropicConfiguration"
  103226. */
  103227. getClassName(): string;
  103228. /**
  103229. * Add fallbacks to the effect fallbacks list.
  103230. * @param defines defines the Base texture to use.
  103231. * @param fallbacks defines the current fallback list.
  103232. * @param currentRank defines the current fallback rank.
  103233. * @returns the new fallback rank.
  103234. */
  103235. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103236. /**
  103237. * Add the required uniforms to the current list.
  103238. * @param uniforms defines the current uniform list.
  103239. */
  103240. static AddUniforms(uniforms: string[]): void;
  103241. /**
  103242. * Add the required uniforms to the current buffer.
  103243. * @param uniformBuffer defines the current uniform buffer.
  103244. */
  103245. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103246. /**
  103247. * Add the required samplers to the current list.
  103248. * @param samplers defines the current sampler list.
  103249. */
  103250. static AddSamplers(samplers: string[]): void;
  103251. /**
  103252. * Makes a duplicate of the current configuration into another one.
  103253. * @param anisotropicConfiguration define the config where to copy the info
  103254. */
  103255. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  103256. /**
  103257. * Serializes this anisotropy configuration.
  103258. * @returns - An object with the serialized config.
  103259. */
  103260. serialize(): any;
  103261. /**
  103262. * Parses a anisotropy Configuration from a serialized object.
  103263. * @param source - Serialized object.
  103264. */
  103265. parse(source: any): void;
  103266. }
  103267. }
  103268. declare module BABYLON {
  103269. /**
  103270. * @hidden
  103271. */
  103272. export interface IMaterialBRDFDefines {
  103273. BRDF_V_HEIGHT_CORRELATED: boolean;
  103274. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103275. /** @hidden */
  103276. _areMiscDirty: boolean;
  103277. }
  103278. /**
  103279. * Define the code related to the BRDF parameters of the pbr material.
  103280. */
  103281. export class PBRBRDFConfiguration {
  103282. /**
  103283. * Default value used for the energy conservation.
  103284. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103285. */
  103286. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  103287. /**
  103288. * Default value used for the Smith Visibility Height Correlated mode.
  103289. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103290. */
  103291. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  103292. private _useEnergyConservation;
  103293. /**
  103294. * Defines if the material uses energy conservation.
  103295. */
  103296. useEnergyConservation: boolean;
  103297. private _useSmithVisibilityHeightCorrelated;
  103298. /**
  103299. * LEGACY Mode set to false
  103300. * Defines if the material uses height smith correlated visibility term.
  103301. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  103302. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103303. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  103304. * Not relying on height correlated will also disable energy conservation.
  103305. */
  103306. useSmithVisibilityHeightCorrelated: boolean;
  103307. /** @hidden */
  103308. private _internalMarkAllSubMeshesAsMiscDirty;
  103309. /** @hidden */
  103310. _markAllSubMeshesAsMiscDirty(): void;
  103311. /**
  103312. * Instantiate a new istance of clear coat configuration.
  103313. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  103314. */
  103315. constructor(markAllSubMeshesAsMiscDirty: () => void);
  103316. /**
  103317. * Checks to see if a texture is used in the material.
  103318. * @param defines the list of "defines" to update.
  103319. */
  103320. prepareDefines(defines: IMaterialBRDFDefines): void;
  103321. /**
  103322. * Get the current class name of the texture useful for serialization or dynamic coding.
  103323. * @returns "PBRClearCoatConfiguration"
  103324. */
  103325. getClassName(): string;
  103326. /**
  103327. * Makes a duplicate of the current configuration into another one.
  103328. * @param brdfConfiguration define the config where to copy the info
  103329. */
  103330. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  103331. /**
  103332. * Serializes this BRDF configuration.
  103333. * @returns - An object with the serialized config.
  103334. */
  103335. serialize(): any;
  103336. /**
  103337. * Parses a BRDF Configuration from a serialized object.
  103338. * @param source - Serialized object.
  103339. */
  103340. parse(source: any): void;
  103341. }
  103342. }
  103343. declare module BABYLON {
  103344. /**
  103345. * @hidden
  103346. */
  103347. export interface IMaterialSheenDefines {
  103348. SHEEN: boolean;
  103349. SHEEN_TEXTURE: boolean;
  103350. SHEEN_TEXTUREDIRECTUV: number;
  103351. SHEEN_LINKWITHALBEDO: boolean;
  103352. /** @hidden */
  103353. _areTexturesDirty: boolean;
  103354. }
  103355. /**
  103356. * Define the code related to the Sheen parameters of the pbr material.
  103357. */
  103358. export class PBRSheenConfiguration {
  103359. private _isEnabled;
  103360. /**
  103361. * Defines if the material uses sheen.
  103362. */
  103363. isEnabled: boolean;
  103364. private _linkSheenWithAlbedo;
  103365. /**
  103366. * Defines if the sheen is linked to the sheen color.
  103367. */
  103368. linkSheenWithAlbedo: boolean;
  103369. /**
  103370. * Defines the sheen intensity.
  103371. */
  103372. intensity: number;
  103373. /**
  103374. * Defines the sheen color.
  103375. */
  103376. color: Color3;
  103377. private _texture;
  103378. /**
  103379. * Stores the sheen tint values in a texture.
  103380. * rgb is tint
  103381. * a is a intensity
  103382. */
  103383. texture: Nullable<BaseTexture>;
  103384. /** @hidden */
  103385. private _internalMarkAllSubMeshesAsTexturesDirty;
  103386. /** @hidden */
  103387. _markAllSubMeshesAsTexturesDirty(): void;
  103388. /**
  103389. * Instantiate a new istance of clear coat configuration.
  103390. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103391. */
  103392. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103393. /**
  103394. * Specifies that the submesh is ready to be used.
  103395. * @param defines the list of "defines" to update.
  103396. * @param scene defines the scene the material belongs to.
  103397. * @returns - boolean indicating that the submesh is ready or not.
  103398. */
  103399. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  103400. /**
  103401. * Checks to see if a texture is used in the material.
  103402. * @param defines the list of "defines" to update.
  103403. * @param scene defines the scene the material belongs to.
  103404. */
  103405. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  103406. /**
  103407. * Binds the material data.
  103408. * @param uniformBuffer defines the Uniform buffer to fill in.
  103409. * @param scene defines the scene the material belongs to.
  103410. * @param isFrozen defines wether the material is frozen or not.
  103411. */
  103412. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103413. /**
  103414. * Checks to see if a texture is used in the material.
  103415. * @param texture - Base texture to use.
  103416. * @returns - Boolean specifying if a texture is used in the material.
  103417. */
  103418. hasTexture(texture: BaseTexture): boolean;
  103419. /**
  103420. * Returns an array of the actively used textures.
  103421. * @param activeTextures Array of BaseTextures
  103422. */
  103423. getActiveTextures(activeTextures: BaseTexture[]): void;
  103424. /**
  103425. * Returns the animatable textures.
  103426. * @param animatables Array of animatable textures.
  103427. */
  103428. getAnimatables(animatables: IAnimatable[]): void;
  103429. /**
  103430. * Disposes the resources of the material.
  103431. * @param forceDisposeTextures - Forces the disposal of all textures.
  103432. */
  103433. dispose(forceDisposeTextures?: boolean): void;
  103434. /**
  103435. * Get the current class name of the texture useful for serialization or dynamic coding.
  103436. * @returns "PBRSheenConfiguration"
  103437. */
  103438. getClassName(): string;
  103439. /**
  103440. * Add fallbacks to the effect fallbacks list.
  103441. * @param defines defines the Base texture to use.
  103442. * @param fallbacks defines the current fallback list.
  103443. * @param currentRank defines the current fallback rank.
  103444. * @returns the new fallback rank.
  103445. */
  103446. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103447. /**
  103448. * Add the required uniforms to the current list.
  103449. * @param uniforms defines the current uniform list.
  103450. */
  103451. static AddUniforms(uniforms: string[]): void;
  103452. /**
  103453. * Add the required uniforms to the current buffer.
  103454. * @param uniformBuffer defines the current uniform buffer.
  103455. */
  103456. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103457. /**
  103458. * Add the required samplers to the current list.
  103459. * @param samplers defines the current sampler list.
  103460. */
  103461. static AddSamplers(samplers: string[]): void;
  103462. /**
  103463. * Makes a duplicate of the current configuration into another one.
  103464. * @param sheenConfiguration define the config where to copy the info
  103465. */
  103466. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  103467. /**
  103468. * Serializes this BRDF configuration.
  103469. * @returns - An object with the serialized config.
  103470. */
  103471. serialize(): any;
  103472. /**
  103473. * Parses a Sheen Configuration from a serialized object.
  103474. * @param source - Serialized object.
  103475. */
  103476. parse(source: any): void;
  103477. }
  103478. }
  103479. declare module BABYLON {
  103480. /**
  103481. * @hidden
  103482. */
  103483. export interface IMaterialSubSurfaceDefines {
  103484. SUBSURFACE: boolean;
  103485. SS_REFRACTION: boolean;
  103486. SS_TRANSLUCENCY: boolean;
  103487. SS_SCATERRING: boolean;
  103488. SS_THICKNESSANDMASK_TEXTURE: boolean;
  103489. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  103490. SS_REFRACTIONMAP_3D: boolean;
  103491. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  103492. SS_LODINREFRACTIONALPHA: boolean;
  103493. SS_GAMMAREFRACTION: boolean;
  103494. SS_RGBDREFRACTION: boolean;
  103495. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  103496. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  103497. /** @hidden */
  103498. _areTexturesDirty: boolean;
  103499. }
  103500. /**
  103501. * Define the code related to the sub surface parameters of the pbr material.
  103502. */
  103503. export class PBRSubSurfaceConfiguration {
  103504. private _isRefractionEnabled;
  103505. /**
  103506. * Defines if the refraction is enabled in the material.
  103507. */
  103508. isRefractionEnabled: boolean;
  103509. private _isTranslucencyEnabled;
  103510. /**
  103511. * Defines if the translucency is enabled in the material.
  103512. */
  103513. isTranslucencyEnabled: boolean;
  103514. private _isScatteringEnabled;
  103515. /**
  103516. * Defines the refraction intensity of the material.
  103517. * The refraction when enabled replaces the Diffuse part of the material.
  103518. * The intensity helps transitionning between diffuse and refraction.
  103519. */
  103520. refractionIntensity: number;
  103521. /**
  103522. * Defines the translucency intensity of the material.
  103523. * When translucency has been enabled, this defines how much of the "translucency"
  103524. * is addded to the diffuse part of the material.
  103525. */
  103526. translucencyIntensity: number;
  103527. /**
  103528. * Defines the scattering intensity of the material.
  103529. * When scattering has been enabled, this defines how much of the "scattered light"
  103530. * is addded to the diffuse part of the material.
  103531. */
  103532. scatteringIntensity: number;
  103533. private _thicknessTexture;
  103534. /**
  103535. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  103536. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  103537. * 0 would mean minimumThickness
  103538. * 1 would mean maximumThickness
  103539. * The other channels might be use as a mask to vary the different effects intensity.
  103540. */
  103541. thicknessTexture: Nullable<BaseTexture>;
  103542. private _refractionTexture;
  103543. /**
  103544. * Defines the texture to use for refraction.
  103545. */
  103546. refractionTexture: Nullable<BaseTexture>;
  103547. private _indexOfRefraction;
  103548. /**
  103549. * Defines the indice of refraction used in the material.
  103550. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  103551. */
  103552. indexOfRefraction: number;
  103553. private _invertRefractionY;
  103554. /**
  103555. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103556. */
  103557. invertRefractionY: boolean;
  103558. private _linkRefractionWithTransparency;
  103559. /**
  103560. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103561. * Materials half opaque for instance using refraction could benefit from this control.
  103562. */
  103563. linkRefractionWithTransparency: boolean;
  103564. /**
  103565. * Defines the minimum thickness stored in the thickness map.
  103566. * If no thickness map is defined, this value will be used to simulate thickness.
  103567. */
  103568. minimumThickness: number;
  103569. /**
  103570. * Defines the maximum thickness stored in the thickness map.
  103571. */
  103572. maximumThickness: number;
  103573. /**
  103574. * Defines the volume tint of the material.
  103575. * This is used for both translucency and scattering.
  103576. */
  103577. tintColor: Color3;
  103578. /**
  103579. * Defines the distance at which the tint color should be found in the media.
  103580. * This is used for refraction only.
  103581. */
  103582. tintColorAtDistance: number;
  103583. /**
  103584. * Defines how far each channel transmit through the media.
  103585. * It is defined as a color to simplify it selection.
  103586. */
  103587. diffusionDistance: Color3;
  103588. private _useMaskFromThicknessTexture;
  103589. /**
  103590. * Stores the intensity of the different subsurface effects in the thickness texture.
  103591. * * the green channel is the translucency intensity.
  103592. * * the blue channel is the scattering intensity.
  103593. * * the alpha channel is the refraction intensity.
  103594. */
  103595. useMaskFromThicknessTexture: boolean;
  103596. /** @hidden */
  103597. private _internalMarkAllSubMeshesAsTexturesDirty;
  103598. /** @hidden */
  103599. _markAllSubMeshesAsTexturesDirty(): void;
  103600. /**
  103601. * Instantiate a new istance of sub surface configuration.
  103602. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103603. */
  103604. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103605. /**
  103606. * Gets wehter the submesh is ready to be used or not.
  103607. * @param defines the list of "defines" to update.
  103608. * @param scene defines the scene the material belongs to.
  103609. * @returns - boolean indicating that the submesh is ready or not.
  103610. */
  103611. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  103612. /**
  103613. * Checks to see if a texture is used in the material.
  103614. * @param defines the list of "defines" to update.
  103615. * @param scene defines the scene to the material belongs to.
  103616. */
  103617. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  103618. /**
  103619. * Binds the material data.
  103620. * @param uniformBuffer defines the Uniform buffer to fill in.
  103621. * @param scene defines the scene the material belongs to.
  103622. * @param engine defines the engine the material belongs to.
  103623. * @param isFrozen defines wether the material is frozen or not.
  103624. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  103625. */
  103626. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  103627. /**
  103628. * Unbinds the material from the mesh.
  103629. * @param activeEffect defines the effect that should be unbound from.
  103630. * @returns true if unbound, otherwise false
  103631. */
  103632. unbind(activeEffect: Effect): boolean;
  103633. /**
  103634. * Returns the texture used for refraction or null if none is used.
  103635. * @param scene defines the scene the material belongs to.
  103636. * @returns - Refraction texture if present. If no refraction texture and refraction
  103637. * is linked with transparency, returns environment texture. Otherwise, returns null.
  103638. */
  103639. private _getRefractionTexture;
  103640. /**
  103641. * Returns true if alpha blending should be disabled.
  103642. */
  103643. readonly disableAlphaBlending: boolean;
  103644. /**
  103645. * Fills the list of render target textures.
  103646. * @param renderTargets the list of render targets to update
  103647. */
  103648. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  103649. /**
  103650. * Checks to see if a texture is used in the material.
  103651. * @param texture - Base texture to use.
  103652. * @returns - Boolean specifying if a texture is used in the material.
  103653. */
  103654. hasTexture(texture: BaseTexture): boolean;
  103655. /**
  103656. * Gets a boolean indicating that current material needs to register RTT
  103657. * @returns true if this uses a render target otherwise false.
  103658. */
  103659. hasRenderTargetTextures(): boolean;
  103660. /**
  103661. * Returns an array of the actively used textures.
  103662. * @param activeTextures Array of BaseTextures
  103663. */
  103664. getActiveTextures(activeTextures: BaseTexture[]): void;
  103665. /**
  103666. * Returns the animatable textures.
  103667. * @param animatables Array of animatable textures.
  103668. */
  103669. getAnimatables(animatables: IAnimatable[]): void;
  103670. /**
  103671. * Disposes the resources of the material.
  103672. * @param forceDisposeTextures - Forces the disposal of all textures.
  103673. */
  103674. dispose(forceDisposeTextures?: boolean): void;
  103675. /**
  103676. * Get the current class name of the texture useful for serialization or dynamic coding.
  103677. * @returns "PBRSubSurfaceConfiguration"
  103678. */
  103679. getClassName(): string;
  103680. /**
  103681. * Add fallbacks to the effect fallbacks list.
  103682. * @param defines defines the Base texture to use.
  103683. * @param fallbacks defines the current fallback list.
  103684. * @param currentRank defines the current fallback rank.
  103685. * @returns the new fallback rank.
  103686. */
  103687. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103688. /**
  103689. * Add the required uniforms to the current list.
  103690. * @param uniforms defines the current uniform list.
  103691. */
  103692. static AddUniforms(uniforms: string[]): void;
  103693. /**
  103694. * Add the required samplers to the current list.
  103695. * @param samplers defines the current sampler list.
  103696. */
  103697. static AddSamplers(samplers: string[]): void;
  103698. /**
  103699. * Add the required uniforms to the current buffer.
  103700. * @param uniformBuffer defines the current uniform buffer.
  103701. */
  103702. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103703. /**
  103704. * Makes a duplicate of the current configuration into another one.
  103705. * @param configuration define the config where to copy the info
  103706. */
  103707. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  103708. /**
  103709. * Serializes this Sub Surface configuration.
  103710. * @returns - An object with the serialized config.
  103711. */
  103712. serialize(): any;
  103713. /**
  103714. * Parses a Sub Surface Configuration from a serialized object.
  103715. * @param source - Serialized object.
  103716. */
  103717. parse(source: any): void;
  103718. }
  103719. }
  103720. declare module BABYLON {
  103721. /** @hidden */
  103722. export var pbrFragmentDeclaration: {
  103723. name: string;
  103724. shader: string;
  103725. };
  103726. }
  103727. declare module BABYLON {
  103728. /** @hidden */
  103729. export var pbrUboDeclaration: {
  103730. name: string;
  103731. shader: string;
  103732. };
  103733. }
  103734. declare module BABYLON {
  103735. /** @hidden */
  103736. export var pbrFragmentExtraDeclaration: {
  103737. name: string;
  103738. shader: string;
  103739. };
  103740. }
  103741. declare module BABYLON {
  103742. /** @hidden */
  103743. export var pbrFragmentSamplersDeclaration: {
  103744. name: string;
  103745. shader: string;
  103746. };
  103747. }
  103748. declare module BABYLON {
  103749. /** @hidden */
  103750. export var pbrHelperFunctions: {
  103751. name: string;
  103752. shader: string;
  103753. };
  103754. }
  103755. declare module BABYLON {
  103756. /** @hidden */
  103757. export var harmonicsFunctions: {
  103758. name: string;
  103759. shader: string;
  103760. };
  103761. }
  103762. declare module BABYLON {
  103763. /** @hidden */
  103764. export var pbrDirectLightingSetupFunctions: {
  103765. name: string;
  103766. shader: string;
  103767. };
  103768. }
  103769. declare module BABYLON {
  103770. /** @hidden */
  103771. export var pbrDirectLightingFalloffFunctions: {
  103772. name: string;
  103773. shader: string;
  103774. };
  103775. }
  103776. declare module BABYLON {
  103777. /** @hidden */
  103778. export var pbrBRDFFunctions: {
  103779. name: string;
  103780. shader: string;
  103781. };
  103782. }
  103783. declare module BABYLON {
  103784. /** @hidden */
  103785. export var pbrDirectLightingFunctions: {
  103786. name: string;
  103787. shader: string;
  103788. };
  103789. }
  103790. declare module BABYLON {
  103791. /** @hidden */
  103792. export var pbrIBLFunctions: {
  103793. name: string;
  103794. shader: string;
  103795. };
  103796. }
  103797. declare module BABYLON {
  103798. /** @hidden */
  103799. export var pbrDebug: {
  103800. name: string;
  103801. shader: string;
  103802. };
  103803. }
  103804. declare module BABYLON {
  103805. /** @hidden */
  103806. export var pbrPixelShader: {
  103807. name: string;
  103808. shader: string;
  103809. };
  103810. }
  103811. declare module BABYLON {
  103812. /** @hidden */
  103813. export var pbrVertexDeclaration: {
  103814. name: string;
  103815. shader: string;
  103816. };
  103817. }
  103818. declare module BABYLON {
  103819. /** @hidden */
  103820. export var pbrVertexShader: {
  103821. name: string;
  103822. shader: string;
  103823. };
  103824. }
  103825. declare module BABYLON {
  103826. /**
  103827. * Manages the defines for the PBR Material.
  103828. * @hidden
  103829. */
  103830. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  103831. PBR: boolean;
  103832. MAINUV1: boolean;
  103833. MAINUV2: boolean;
  103834. UV1: boolean;
  103835. UV2: boolean;
  103836. ALBEDO: boolean;
  103837. ALBEDODIRECTUV: number;
  103838. VERTEXCOLOR: boolean;
  103839. AMBIENT: boolean;
  103840. AMBIENTDIRECTUV: number;
  103841. AMBIENTINGRAYSCALE: boolean;
  103842. OPACITY: boolean;
  103843. VERTEXALPHA: boolean;
  103844. OPACITYDIRECTUV: number;
  103845. OPACITYRGB: boolean;
  103846. ALPHATEST: boolean;
  103847. DEPTHPREPASS: boolean;
  103848. ALPHABLEND: boolean;
  103849. ALPHAFROMALBEDO: boolean;
  103850. ALPHATESTVALUE: string;
  103851. SPECULAROVERALPHA: boolean;
  103852. RADIANCEOVERALPHA: boolean;
  103853. ALPHAFRESNEL: boolean;
  103854. LINEARALPHAFRESNEL: boolean;
  103855. PREMULTIPLYALPHA: boolean;
  103856. EMISSIVE: boolean;
  103857. EMISSIVEDIRECTUV: number;
  103858. REFLECTIVITY: boolean;
  103859. REFLECTIVITYDIRECTUV: number;
  103860. SPECULARTERM: boolean;
  103861. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  103862. MICROSURFACEAUTOMATIC: boolean;
  103863. LODBASEDMICROSFURACE: boolean;
  103864. MICROSURFACEMAP: boolean;
  103865. MICROSURFACEMAPDIRECTUV: number;
  103866. METALLICWORKFLOW: boolean;
  103867. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  103868. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  103869. METALLNESSSTOREINMETALMAPBLUE: boolean;
  103870. AOSTOREINMETALMAPRED: boolean;
  103871. ENVIRONMENTBRDF: boolean;
  103872. ENVIRONMENTBRDF_RGBD: boolean;
  103873. NORMAL: boolean;
  103874. TANGENT: boolean;
  103875. BUMP: boolean;
  103876. BUMPDIRECTUV: number;
  103877. OBJECTSPACE_NORMALMAP: boolean;
  103878. PARALLAX: boolean;
  103879. PARALLAXOCCLUSION: boolean;
  103880. NORMALXYSCALE: boolean;
  103881. LIGHTMAP: boolean;
  103882. LIGHTMAPDIRECTUV: number;
  103883. USELIGHTMAPASSHADOWMAP: boolean;
  103884. GAMMALIGHTMAP: boolean;
  103885. REFLECTION: boolean;
  103886. REFLECTIONMAP_3D: boolean;
  103887. REFLECTIONMAP_SPHERICAL: boolean;
  103888. REFLECTIONMAP_PLANAR: boolean;
  103889. REFLECTIONMAP_CUBIC: boolean;
  103890. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103891. REFLECTIONMAP_PROJECTION: boolean;
  103892. REFLECTIONMAP_SKYBOX: boolean;
  103893. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  103894. REFLECTIONMAP_EXPLICIT: boolean;
  103895. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103896. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103897. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103898. INVERTCUBICMAP: boolean;
  103899. USESPHERICALFROMREFLECTIONMAP: boolean;
  103900. USESPHERICALINVERTEX: boolean;
  103901. REFLECTIONMAP_OPPOSITEZ: boolean;
  103902. LODINREFLECTIONALPHA: boolean;
  103903. GAMMAREFLECTION: boolean;
  103904. RGBDREFLECTION: boolean;
  103905. RADIANCEOCCLUSION: boolean;
  103906. HORIZONOCCLUSION: boolean;
  103907. INSTANCES: boolean;
  103908. NUM_BONE_INFLUENCERS: number;
  103909. BonesPerMesh: number;
  103910. BONETEXTURE: boolean;
  103911. NONUNIFORMSCALING: boolean;
  103912. MORPHTARGETS: boolean;
  103913. MORPHTARGETS_NORMAL: boolean;
  103914. MORPHTARGETS_TANGENT: boolean;
  103915. NUM_MORPH_INFLUENCERS: number;
  103916. IMAGEPROCESSING: boolean;
  103917. VIGNETTE: boolean;
  103918. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103919. VIGNETTEBLENDMODEOPAQUE: boolean;
  103920. TONEMAPPING: boolean;
  103921. TONEMAPPING_ACES: boolean;
  103922. CONTRAST: boolean;
  103923. COLORCURVES: boolean;
  103924. COLORGRADING: boolean;
  103925. COLORGRADING3D: boolean;
  103926. SAMPLER3DGREENDEPTH: boolean;
  103927. SAMPLER3DBGRMAP: boolean;
  103928. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103929. EXPOSURE: boolean;
  103930. MULTIVIEW: boolean;
  103931. USEPHYSICALLIGHTFALLOFF: boolean;
  103932. USEGLTFLIGHTFALLOFF: boolean;
  103933. TWOSIDEDLIGHTING: boolean;
  103934. SHADOWFLOAT: boolean;
  103935. CLIPPLANE: boolean;
  103936. CLIPPLANE2: boolean;
  103937. CLIPPLANE3: boolean;
  103938. CLIPPLANE4: boolean;
  103939. POINTSIZE: boolean;
  103940. FOG: boolean;
  103941. LOGARITHMICDEPTH: boolean;
  103942. FORCENORMALFORWARD: boolean;
  103943. SPECULARAA: boolean;
  103944. CLEARCOAT: boolean;
  103945. CLEARCOAT_DEFAULTIOR: boolean;
  103946. CLEARCOAT_TEXTURE: boolean;
  103947. CLEARCOAT_TEXTUREDIRECTUV: number;
  103948. CLEARCOAT_BUMP: boolean;
  103949. CLEARCOAT_BUMPDIRECTUV: number;
  103950. CLEARCOAT_TINT: boolean;
  103951. CLEARCOAT_TINT_TEXTURE: boolean;
  103952. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103953. ANISOTROPIC: boolean;
  103954. ANISOTROPIC_TEXTURE: boolean;
  103955. ANISOTROPIC_TEXTUREDIRECTUV: number;
  103956. BRDF_V_HEIGHT_CORRELATED: boolean;
  103957. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103958. SHEEN: boolean;
  103959. SHEEN_TEXTURE: boolean;
  103960. SHEEN_TEXTUREDIRECTUV: number;
  103961. SHEEN_LINKWITHALBEDO: boolean;
  103962. SUBSURFACE: boolean;
  103963. SS_REFRACTION: boolean;
  103964. SS_TRANSLUCENCY: boolean;
  103965. SS_SCATERRING: boolean;
  103966. SS_THICKNESSANDMASK_TEXTURE: boolean;
  103967. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  103968. SS_REFRACTIONMAP_3D: boolean;
  103969. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  103970. SS_LODINREFRACTIONALPHA: boolean;
  103971. SS_GAMMAREFRACTION: boolean;
  103972. SS_RGBDREFRACTION: boolean;
  103973. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  103974. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  103975. UNLIT: boolean;
  103976. DEBUGMODE: number;
  103977. /**
  103978. * Initializes the PBR Material defines.
  103979. */
  103980. constructor();
  103981. /**
  103982. * Resets the PBR Material defines.
  103983. */
  103984. reset(): void;
  103985. }
  103986. /**
  103987. * The Physically based material base class of BJS.
  103988. *
  103989. * This offers the main features of a standard PBR material.
  103990. * For more information, please refer to the documentation :
  103991. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  103992. */
  103993. export abstract class PBRBaseMaterial extends PushMaterial {
  103994. /**
  103995. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103996. */
  103997. static readonly PBRMATERIAL_OPAQUE: number;
  103998. /**
  103999. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104000. */
  104001. static readonly PBRMATERIAL_ALPHATEST: number;
  104002. /**
  104003. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104004. */
  104005. static readonly PBRMATERIAL_ALPHABLEND: number;
  104006. /**
  104007. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104008. * They are also discarded below the alpha cutoff threshold to improve performances.
  104009. */
  104010. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104011. /**
  104012. * Defines the default value of how much AO map is occluding the analytical lights
  104013. * (point spot...).
  104014. */
  104015. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104016. /**
  104017. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  104018. */
  104019. static readonly LIGHTFALLOFF_PHYSICAL: number;
  104020. /**
  104021. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  104022. * to enhance interoperability with other engines.
  104023. */
  104024. static readonly LIGHTFALLOFF_GLTF: number;
  104025. /**
  104026. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  104027. * to enhance interoperability with other materials.
  104028. */
  104029. static readonly LIGHTFALLOFF_STANDARD: number;
  104030. /**
  104031. * Intensity of the direct lights e.g. the four lights available in your scene.
  104032. * This impacts both the direct diffuse and specular highlights.
  104033. */
  104034. protected _directIntensity: number;
  104035. /**
  104036. * Intensity of the emissive part of the material.
  104037. * This helps controlling the emissive effect without modifying the emissive color.
  104038. */
  104039. protected _emissiveIntensity: number;
  104040. /**
  104041. * Intensity of the environment e.g. how much the environment will light the object
  104042. * either through harmonics for rough material or through the refelction for shiny ones.
  104043. */
  104044. protected _environmentIntensity: number;
  104045. /**
  104046. * This is a special control allowing the reduction of the specular highlights coming from the
  104047. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104048. */
  104049. protected _specularIntensity: number;
  104050. /**
  104051. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  104052. */
  104053. private _lightingInfos;
  104054. /**
  104055. * Debug Control allowing disabling the bump map on this material.
  104056. */
  104057. protected _disableBumpMap: boolean;
  104058. /**
  104059. * AKA Diffuse Texture in standard nomenclature.
  104060. */
  104061. protected _albedoTexture: BaseTexture;
  104062. /**
  104063. * AKA Occlusion Texture in other nomenclature.
  104064. */
  104065. protected _ambientTexture: BaseTexture;
  104066. /**
  104067. * AKA Occlusion Texture Intensity in other nomenclature.
  104068. */
  104069. protected _ambientTextureStrength: number;
  104070. /**
  104071. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104072. * 1 means it completely occludes it
  104073. * 0 mean it has no impact
  104074. */
  104075. protected _ambientTextureImpactOnAnalyticalLights: number;
  104076. /**
  104077. * Stores the alpha values in a texture.
  104078. */
  104079. protected _opacityTexture: BaseTexture;
  104080. /**
  104081. * Stores the reflection values in a texture.
  104082. */
  104083. protected _reflectionTexture: BaseTexture;
  104084. /**
  104085. * Stores the emissive values in a texture.
  104086. */
  104087. protected _emissiveTexture: BaseTexture;
  104088. /**
  104089. * AKA Specular texture in other nomenclature.
  104090. */
  104091. protected _reflectivityTexture: BaseTexture;
  104092. /**
  104093. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104094. */
  104095. protected _metallicTexture: BaseTexture;
  104096. /**
  104097. * Specifies the metallic scalar of the metallic/roughness workflow.
  104098. * Can also be used to scale the metalness values of the metallic texture.
  104099. */
  104100. protected _metallic: Nullable<number>;
  104101. /**
  104102. * Specifies the roughness scalar of the metallic/roughness workflow.
  104103. * Can also be used to scale the roughness values of the metallic texture.
  104104. */
  104105. protected _roughness: Nullable<number>;
  104106. /**
  104107. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104108. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104109. */
  104110. protected _microSurfaceTexture: BaseTexture;
  104111. /**
  104112. * Stores surface normal data used to displace a mesh in a texture.
  104113. */
  104114. protected _bumpTexture: BaseTexture;
  104115. /**
  104116. * Stores the pre-calculated light information of a mesh in a texture.
  104117. */
  104118. protected _lightmapTexture: BaseTexture;
  104119. /**
  104120. * The color of a material in ambient lighting.
  104121. */
  104122. protected _ambientColor: Color3;
  104123. /**
  104124. * AKA Diffuse Color in other nomenclature.
  104125. */
  104126. protected _albedoColor: Color3;
  104127. /**
  104128. * AKA Specular Color in other nomenclature.
  104129. */
  104130. protected _reflectivityColor: Color3;
  104131. /**
  104132. * The color applied when light is reflected from a material.
  104133. */
  104134. protected _reflectionColor: Color3;
  104135. /**
  104136. * The color applied when light is emitted from a material.
  104137. */
  104138. protected _emissiveColor: Color3;
  104139. /**
  104140. * AKA Glossiness in other nomenclature.
  104141. */
  104142. protected _microSurface: number;
  104143. /**
  104144. * Specifies that the material will use the light map as a show map.
  104145. */
  104146. protected _useLightmapAsShadowmap: boolean;
  104147. /**
  104148. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104149. * makes the reflect vector face the model (under horizon).
  104150. */
  104151. protected _useHorizonOcclusion: boolean;
  104152. /**
  104153. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104154. * too much the area relying on ambient texture to define their ambient occlusion.
  104155. */
  104156. protected _useRadianceOcclusion: boolean;
  104157. /**
  104158. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104159. */
  104160. protected _useAlphaFromAlbedoTexture: boolean;
  104161. /**
  104162. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  104163. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104164. */
  104165. protected _useSpecularOverAlpha: boolean;
  104166. /**
  104167. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104168. */
  104169. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104170. /**
  104171. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104172. */
  104173. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  104174. /**
  104175. * Specifies if the metallic texture contains the roughness information in its green channel.
  104176. */
  104177. protected _useRoughnessFromMetallicTextureGreen: boolean;
  104178. /**
  104179. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104180. */
  104181. protected _useMetallnessFromMetallicTextureBlue: boolean;
  104182. /**
  104183. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104184. */
  104185. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  104186. /**
  104187. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104188. */
  104189. protected _useAmbientInGrayScale: boolean;
  104190. /**
  104191. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104192. * The material will try to infer what glossiness each pixel should be.
  104193. */
  104194. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  104195. /**
  104196. * Defines the falloff type used in this material.
  104197. * It by default is Physical.
  104198. */
  104199. protected _lightFalloff: number;
  104200. /**
  104201. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104202. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104203. */
  104204. protected _useRadianceOverAlpha: boolean;
  104205. /**
  104206. * Allows using an object space normal map (instead of tangent space).
  104207. */
  104208. protected _useObjectSpaceNormalMap: boolean;
  104209. /**
  104210. * Allows using the bump map in parallax mode.
  104211. */
  104212. protected _useParallax: boolean;
  104213. /**
  104214. * Allows using the bump map in parallax occlusion mode.
  104215. */
  104216. protected _useParallaxOcclusion: boolean;
  104217. /**
  104218. * Controls the scale bias of the parallax mode.
  104219. */
  104220. protected _parallaxScaleBias: number;
  104221. /**
  104222. * If sets to true, disables all the lights affecting the material.
  104223. */
  104224. protected _disableLighting: boolean;
  104225. /**
  104226. * Number of Simultaneous lights allowed on the material.
  104227. */
  104228. protected _maxSimultaneousLights: number;
  104229. /**
  104230. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104231. */
  104232. protected _invertNormalMapX: boolean;
  104233. /**
  104234. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104235. */
  104236. protected _invertNormalMapY: boolean;
  104237. /**
  104238. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104239. */
  104240. protected _twoSidedLighting: boolean;
  104241. /**
  104242. * Defines the alpha limits in alpha test mode.
  104243. */
  104244. protected _alphaCutOff: number;
  104245. /**
  104246. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104247. */
  104248. protected _forceAlphaTest: boolean;
  104249. /**
  104250. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104251. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104252. */
  104253. protected _useAlphaFresnel: boolean;
  104254. /**
  104255. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104256. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104257. */
  104258. protected _useLinearAlphaFresnel: boolean;
  104259. /**
  104260. * The transparency mode of the material.
  104261. */
  104262. protected _transparencyMode: Nullable<number>;
  104263. /**
  104264. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  104265. * from cos thetav and roughness:
  104266. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  104267. */
  104268. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  104269. /**
  104270. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104271. */
  104272. protected _forceIrradianceInFragment: boolean;
  104273. /**
  104274. * Force normal to face away from face.
  104275. */
  104276. protected _forceNormalForward: boolean;
  104277. /**
  104278. * Enables specular anti aliasing in the PBR shader.
  104279. * It will both interacts on the Geometry for analytical and IBL lighting.
  104280. * It also prefilter the roughness map based on the bump values.
  104281. */
  104282. protected _enableSpecularAntiAliasing: boolean;
  104283. /**
  104284. * Default configuration related to image processing available in the PBR Material.
  104285. */
  104286. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104287. /**
  104288. * Keep track of the image processing observer to allow dispose and replace.
  104289. */
  104290. private _imageProcessingObserver;
  104291. /**
  104292. * Attaches a new image processing configuration to the PBR Material.
  104293. * @param configuration
  104294. */
  104295. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104296. /**
  104297. * Stores the available render targets.
  104298. */
  104299. private _renderTargets;
  104300. /**
  104301. * Sets the global ambient color for the material used in lighting calculations.
  104302. */
  104303. private _globalAmbientColor;
  104304. /**
  104305. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  104306. */
  104307. private _useLogarithmicDepth;
  104308. /**
  104309. * If set to true, no lighting calculations will be applied.
  104310. */
  104311. private _unlit;
  104312. private _debugMode;
  104313. /**
  104314. * @hidden
  104315. * This is reserved for the inspector.
  104316. * Defines the material debug mode.
  104317. * It helps seeing only some components of the material while troubleshooting.
  104318. */
  104319. debugMode: number;
  104320. /**
  104321. * @hidden
  104322. * This is reserved for the inspector.
  104323. * Specify from where on screen the debug mode should start.
  104324. * The value goes from -1 (full screen) to 1 (not visible)
  104325. * It helps with side by side comparison against the final render
  104326. * This defaults to -1
  104327. */
  104328. private debugLimit;
  104329. /**
  104330. * @hidden
  104331. * This is reserved for the inspector.
  104332. * As the default viewing range might not be enough (if the ambient is really small for instance)
  104333. * You can use the factor to better multiply the final value.
  104334. */
  104335. private debugFactor;
  104336. /**
  104337. * Defines the clear coat layer parameters for the material.
  104338. */
  104339. readonly clearCoat: PBRClearCoatConfiguration;
  104340. /**
  104341. * Defines the anisotropic parameters for the material.
  104342. */
  104343. readonly anisotropy: PBRAnisotropicConfiguration;
  104344. /**
  104345. * Defines the BRDF parameters for the material.
  104346. */
  104347. readonly brdf: PBRBRDFConfiguration;
  104348. /**
  104349. * Defines the Sheen parameters for the material.
  104350. */
  104351. readonly sheen: PBRSheenConfiguration;
  104352. /**
  104353. * Defines the SubSurface parameters for the material.
  104354. */
  104355. readonly subSurface: PBRSubSurfaceConfiguration;
  104356. /**
  104357. * Custom callback helping to override the default shader used in the material.
  104358. */
  104359. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  104360. /**
  104361. * Instantiates a new PBRMaterial instance.
  104362. *
  104363. * @param name The material name
  104364. * @param scene The scene the material will be use in.
  104365. */
  104366. constructor(name: string, scene: Scene);
  104367. /**
  104368. * Gets a boolean indicating that current material needs to register RTT
  104369. */
  104370. readonly hasRenderTargetTextures: boolean;
  104371. /**
  104372. * Gets the name of the material class.
  104373. */
  104374. getClassName(): string;
  104375. /**
  104376. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104377. */
  104378. /**
  104379. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104380. */
  104381. useLogarithmicDepth: boolean;
  104382. /**
  104383. * Gets the current transparency mode.
  104384. */
  104385. /**
  104386. * Sets the transparency mode of the material.
  104387. *
  104388. * | Value | Type | Description |
  104389. * | ----- | ----------------------------------- | ----------- |
  104390. * | 0 | OPAQUE | |
  104391. * | 1 | ALPHATEST | |
  104392. * | 2 | ALPHABLEND | |
  104393. * | 3 | ALPHATESTANDBLEND | |
  104394. *
  104395. */
  104396. transparencyMode: Nullable<number>;
  104397. /**
  104398. * Returns true if alpha blending should be disabled.
  104399. */
  104400. private readonly _disableAlphaBlending;
  104401. /**
  104402. * Specifies whether or not this material should be rendered in alpha blend mode.
  104403. */
  104404. needAlphaBlending(): boolean;
  104405. /**
  104406. * Specifies if the mesh will require alpha blending.
  104407. * @param mesh - BJS mesh.
  104408. */
  104409. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  104410. /**
  104411. * Specifies whether or not this material should be rendered in alpha test mode.
  104412. */
  104413. needAlphaTesting(): boolean;
  104414. /**
  104415. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  104416. */
  104417. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  104418. /**
  104419. * Gets the texture used for the alpha test.
  104420. */
  104421. getAlphaTestTexture(): BaseTexture;
  104422. /**
  104423. * Specifies that the submesh is ready to be used.
  104424. * @param mesh - BJS mesh.
  104425. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  104426. * @param useInstances - Specifies that instances should be used.
  104427. * @returns - boolean indicating that the submesh is ready or not.
  104428. */
  104429. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104430. /**
  104431. * Specifies if the material uses metallic roughness workflow.
  104432. * @returns boolean specifiying if the material uses metallic roughness workflow.
  104433. */
  104434. isMetallicWorkflow(): boolean;
  104435. private _prepareEffect;
  104436. private _prepareDefines;
  104437. /**
  104438. * Force shader compilation
  104439. */
  104440. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  104441. clipPlane: boolean;
  104442. }>): void;
  104443. /**
  104444. * Initializes the uniform buffer layout for the shader.
  104445. */
  104446. buildUniformLayout(): void;
  104447. /**
  104448. * Unbinds the material from the mesh
  104449. */
  104450. unbind(): void;
  104451. /**
  104452. * Binds the submesh data.
  104453. * @param world - The world matrix.
  104454. * @param mesh - The BJS mesh.
  104455. * @param subMesh - A submesh of the BJS mesh.
  104456. */
  104457. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104458. /**
  104459. * Returns the animatable textures.
  104460. * @returns - Array of animatable textures.
  104461. */
  104462. getAnimatables(): IAnimatable[];
  104463. /**
  104464. * Returns the texture used for reflections.
  104465. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  104466. */
  104467. private _getReflectionTexture;
  104468. /**
  104469. * Returns an array of the actively used textures.
  104470. * @returns - Array of BaseTextures
  104471. */
  104472. getActiveTextures(): BaseTexture[];
  104473. /**
  104474. * Checks to see if a texture is used in the material.
  104475. * @param texture - Base texture to use.
  104476. * @returns - Boolean specifying if a texture is used in the material.
  104477. */
  104478. hasTexture(texture: BaseTexture): boolean;
  104479. /**
  104480. * Disposes the resources of the material.
  104481. * @param forceDisposeEffect - Forces the disposal of effects.
  104482. * @param forceDisposeTextures - Forces the disposal of all textures.
  104483. */
  104484. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104485. }
  104486. }
  104487. declare module BABYLON {
  104488. /**
  104489. * The Physically based material of BJS.
  104490. *
  104491. * This offers the main features of a standard PBR material.
  104492. * For more information, please refer to the documentation :
  104493. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104494. */
  104495. export class PBRMaterial extends PBRBaseMaterial {
  104496. /**
  104497. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104498. */
  104499. static readonly PBRMATERIAL_OPAQUE: number;
  104500. /**
  104501. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104502. */
  104503. static readonly PBRMATERIAL_ALPHATEST: number;
  104504. /**
  104505. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104506. */
  104507. static readonly PBRMATERIAL_ALPHABLEND: number;
  104508. /**
  104509. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104510. * They are also discarded below the alpha cutoff threshold to improve performances.
  104511. */
  104512. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104513. /**
  104514. * Defines the default value of how much AO map is occluding the analytical lights
  104515. * (point spot...).
  104516. */
  104517. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104518. /**
  104519. * Intensity of the direct lights e.g. the four lights available in your scene.
  104520. * This impacts both the direct diffuse and specular highlights.
  104521. */
  104522. directIntensity: number;
  104523. /**
  104524. * Intensity of the emissive part of the material.
  104525. * This helps controlling the emissive effect without modifying the emissive color.
  104526. */
  104527. emissiveIntensity: number;
  104528. /**
  104529. * Intensity of the environment e.g. how much the environment will light the object
  104530. * either through harmonics for rough material or through the refelction for shiny ones.
  104531. */
  104532. environmentIntensity: number;
  104533. /**
  104534. * This is a special control allowing the reduction of the specular highlights coming from the
  104535. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104536. */
  104537. specularIntensity: number;
  104538. /**
  104539. * Debug Control allowing disabling the bump map on this material.
  104540. */
  104541. disableBumpMap: boolean;
  104542. /**
  104543. * AKA Diffuse Texture in standard nomenclature.
  104544. */
  104545. albedoTexture: BaseTexture;
  104546. /**
  104547. * AKA Occlusion Texture in other nomenclature.
  104548. */
  104549. ambientTexture: BaseTexture;
  104550. /**
  104551. * AKA Occlusion Texture Intensity in other nomenclature.
  104552. */
  104553. ambientTextureStrength: number;
  104554. /**
  104555. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104556. * 1 means it completely occludes it
  104557. * 0 mean it has no impact
  104558. */
  104559. ambientTextureImpactOnAnalyticalLights: number;
  104560. /**
  104561. * Stores the alpha values in a texture.
  104562. */
  104563. opacityTexture: BaseTexture;
  104564. /**
  104565. * Stores the reflection values in a texture.
  104566. */
  104567. reflectionTexture: Nullable<BaseTexture>;
  104568. /**
  104569. * Stores the emissive values in a texture.
  104570. */
  104571. emissiveTexture: BaseTexture;
  104572. /**
  104573. * AKA Specular texture in other nomenclature.
  104574. */
  104575. reflectivityTexture: BaseTexture;
  104576. /**
  104577. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104578. */
  104579. metallicTexture: BaseTexture;
  104580. /**
  104581. * Specifies the metallic scalar of the metallic/roughness workflow.
  104582. * Can also be used to scale the metalness values of the metallic texture.
  104583. */
  104584. metallic: Nullable<number>;
  104585. /**
  104586. * Specifies the roughness scalar of the metallic/roughness workflow.
  104587. * Can also be used to scale the roughness values of the metallic texture.
  104588. */
  104589. roughness: Nullable<number>;
  104590. /**
  104591. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104592. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104593. */
  104594. microSurfaceTexture: BaseTexture;
  104595. /**
  104596. * Stores surface normal data used to displace a mesh in a texture.
  104597. */
  104598. bumpTexture: BaseTexture;
  104599. /**
  104600. * Stores the pre-calculated light information of a mesh in a texture.
  104601. */
  104602. lightmapTexture: BaseTexture;
  104603. /**
  104604. * Stores the refracted light information in a texture.
  104605. */
  104606. refractionTexture: Nullable<BaseTexture>;
  104607. /**
  104608. * The color of a material in ambient lighting.
  104609. */
  104610. ambientColor: Color3;
  104611. /**
  104612. * AKA Diffuse Color in other nomenclature.
  104613. */
  104614. albedoColor: Color3;
  104615. /**
  104616. * AKA Specular Color in other nomenclature.
  104617. */
  104618. reflectivityColor: Color3;
  104619. /**
  104620. * The color reflected from the material.
  104621. */
  104622. reflectionColor: Color3;
  104623. /**
  104624. * The color emitted from the material.
  104625. */
  104626. emissiveColor: Color3;
  104627. /**
  104628. * AKA Glossiness in other nomenclature.
  104629. */
  104630. microSurface: number;
  104631. /**
  104632. * source material index of refraction (IOR)' / 'destination material IOR.
  104633. */
  104634. indexOfRefraction: number;
  104635. /**
  104636. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104637. */
  104638. invertRefractionY: boolean;
  104639. /**
  104640. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104641. * Materials half opaque for instance using refraction could benefit from this control.
  104642. */
  104643. linkRefractionWithTransparency: boolean;
  104644. /**
  104645. * If true, the light map contains occlusion information instead of lighting info.
  104646. */
  104647. useLightmapAsShadowmap: boolean;
  104648. /**
  104649. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104650. */
  104651. useAlphaFromAlbedoTexture: boolean;
  104652. /**
  104653. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104654. */
  104655. forceAlphaTest: boolean;
  104656. /**
  104657. * Defines the alpha limits in alpha test mode.
  104658. */
  104659. alphaCutOff: number;
  104660. /**
  104661. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104662. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104663. */
  104664. useSpecularOverAlpha: boolean;
  104665. /**
  104666. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104667. */
  104668. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104669. /**
  104670. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104671. */
  104672. useRoughnessFromMetallicTextureAlpha: boolean;
  104673. /**
  104674. * Specifies if the metallic texture contains the roughness information in its green channel.
  104675. */
  104676. useRoughnessFromMetallicTextureGreen: boolean;
  104677. /**
  104678. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104679. */
  104680. useMetallnessFromMetallicTextureBlue: boolean;
  104681. /**
  104682. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104683. */
  104684. useAmbientOcclusionFromMetallicTextureRed: boolean;
  104685. /**
  104686. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104687. */
  104688. useAmbientInGrayScale: boolean;
  104689. /**
  104690. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104691. * The material will try to infer what glossiness each pixel should be.
  104692. */
  104693. useAutoMicroSurfaceFromReflectivityMap: boolean;
  104694. /**
  104695. * BJS is using an harcoded light falloff based on a manually sets up range.
  104696. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104697. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104698. */
  104699. /**
  104700. * BJS is using an harcoded light falloff based on a manually sets up range.
  104701. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104702. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104703. */
  104704. usePhysicalLightFalloff: boolean;
  104705. /**
  104706. * In order to support the falloff compatibility with gltf, a special mode has been added
  104707. * to reproduce the gltf light falloff.
  104708. */
  104709. /**
  104710. * In order to support the falloff compatibility with gltf, a special mode has been added
  104711. * to reproduce the gltf light falloff.
  104712. */
  104713. useGLTFLightFalloff: boolean;
  104714. /**
  104715. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104716. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104717. */
  104718. useRadianceOverAlpha: boolean;
  104719. /**
  104720. * Allows using an object space normal map (instead of tangent space).
  104721. */
  104722. useObjectSpaceNormalMap: boolean;
  104723. /**
  104724. * Allows using the bump map in parallax mode.
  104725. */
  104726. useParallax: boolean;
  104727. /**
  104728. * Allows using the bump map in parallax occlusion mode.
  104729. */
  104730. useParallaxOcclusion: boolean;
  104731. /**
  104732. * Controls the scale bias of the parallax mode.
  104733. */
  104734. parallaxScaleBias: number;
  104735. /**
  104736. * If sets to true, disables all the lights affecting the material.
  104737. */
  104738. disableLighting: boolean;
  104739. /**
  104740. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104741. */
  104742. forceIrradianceInFragment: boolean;
  104743. /**
  104744. * Number of Simultaneous lights allowed on the material.
  104745. */
  104746. maxSimultaneousLights: number;
  104747. /**
  104748. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104749. */
  104750. invertNormalMapX: boolean;
  104751. /**
  104752. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104753. */
  104754. invertNormalMapY: boolean;
  104755. /**
  104756. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104757. */
  104758. twoSidedLighting: boolean;
  104759. /**
  104760. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104761. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104762. */
  104763. useAlphaFresnel: boolean;
  104764. /**
  104765. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104766. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104767. */
  104768. useLinearAlphaFresnel: boolean;
  104769. /**
  104770. * Let user defines the brdf lookup texture used for IBL.
  104771. * A default 8bit version is embedded but you could point at :
  104772. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  104773. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  104774. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104775. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  104776. */
  104777. environmentBRDFTexture: Nullable<BaseTexture>;
  104778. /**
  104779. * Force normal to face away from face.
  104780. */
  104781. forceNormalForward: boolean;
  104782. /**
  104783. * Enables specular anti aliasing in the PBR shader.
  104784. * It will both interacts on the Geometry for analytical and IBL lighting.
  104785. * It also prefilter the roughness map based on the bump values.
  104786. */
  104787. enableSpecularAntiAliasing: boolean;
  104788. /**
  104789. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104790. * makes the reflect vector face the model (under horizon).
  104791. */
  104792. useHorizonOcclusion: boolean;
  104793. /**
  104794. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104795. * too much the area relying on ambient texture to define their ambient occlusion.
  104796. */
  104797. useRadianceOcclusion: boolean;
  104798. /**
  104799. * If set to true, no lighting calculations will be applied.
  104800. */
  104801. unlit: boolean;
  104802. /**
  104803. * Gets the image processing configuration used either in this material.
  104804. */
  104805. /**
  104806. * Sets the Default image processing configuration used either in the this material.
  104807. *
  104808. * If sets to null, the scene one is in use.
  104809. */
  104810. imageProcessingConfiguration: ImageProcessingConfiguration;
  104811. /**
  104812. * Gets wether the color curves effect is enabled.
  104813. */
  104814. /**
  104815. * Sets wether the color curves effect is enabled.
  104816. */
  104817. cameraColorCurvesEnabled: boolean;
  104818. /**
  104819. * Gets wether the color grading effect is enabled.
  104820. */
  104821. /**
  104822. * Gets wether the color grading effect is enabled.
  104823. */
  104824. cameraColorGradingEnabled: boolean;
  104825. /**
  104826. * Gets wether tonemapping is enabled or not.
  104827. */
  104828. /**
  104829. * Sets wether tonemapping is enabled or not
  104830. */
  104831. cameraToneMappingEnabled: boolean;
  104832. /**
  104833. * The camera exposure used on this material.
  104834. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104835. * This corresponds to a photographic exposure.
  104836. */
  104837. /**
  104838. * The camera exposure used on this material.
  104839. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104840. * This corresponds to a photographic exposure.
  104841. */
  104842. cameraExposure: number;
  104843. /**
  104844. * Gets The camera contrast used on this material.
  104845. */
  104846. /**
  104847. * Sets The camera contrast used on this material.
  104848. */
  104849. cameraContrast: number;
  104850. /**
  104851. * Gets the Color Grading 2D Lookup Texture.
  104852. */
  104853. /**
  104854. * Sets the Color Grading 2D Lookup Texture.
  104855. */
  104856. cameraColorGradingTexture: Nullable<BaseTexture>;
  104857. /**
  104858. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104859. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104860. * 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;
  104861. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104862. */
  104863. /**
  104864. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104865. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104866. * 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;
  104867. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104868. */
  104869. cameraColorCurves: Nullable<ColorCurves>;
  104870. /**
  104871. * Instantiates a new PBRMaterial instance.
  104872. *
  104873. * @param name The material name
  104874. * @param scene The scene the material will be use in.
  104875. */
  104876. constructor(name: string, scene: Scene);
  104877. /**
  104878. * Returns the name of this material class.
  104879. */
  104880. getClassName(): string;
  104881. /**
  104882. * Makes a duplicate of the current material.
  104883. * @param name - name to use for the new material.
  104884. */
  104885. clone(name: string): PBRMaterial;
  104886. /**
  104887. * Serializes this PBR Material.
  104888. * @returns - An object with the serialized material.
  104889. */
  104890. serialize(): any;
  104891. /**
  104892. * Parses a PBR Material from a serialized object.
  104893. * @param source - Serialized object.
  104894. * @param scene - BJS scene instance.
  104895. * @param rootUrl - url for the scene object
  104896. * @returns - PBRMaterial
  104897. */
  104898. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  104899. }
  104900. }
  104901. declare module BABYLON {
  104902. /**
  104903. * Direct draw surface info
  104904. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  104905. */
  104906. export interface DDSInfo {
  104907. /**
  104908. * Width of the texture
  104909. */
  104910. width: number;
  104911. /**
  104912. * Width of the texture
  104913. */
  104914. height: number;
  104915. /**
  104916. * Number of Mipmaps for the texture
  104917. * @see https://en.wikipedia.org/wiki/Mipmap
  104918. */
  104919. mipmapCount: number;
  104920. /**
  104921. * If the textures format is a known fourCC format
  104922. * @see https://www.fourcc.org/
  104923. */
  104924. isFourCC: boolean;
  104925. /**
  104926. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  104927. */
  104928. isRGB: boolean;
  104929. /**
  104930. * If the texture is a lumincance format
  104931. */
  104932. isLuminance: boolean;
  104933. /**
  104934. * If this is a cube texture
  104935. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  104936. */
  104937. isCube: boolean;
  104938. /**
  104939. * If the texture is a compressed format eg. FOURCC_DXT1
  104940. */
  104941. isCompressed: boolean;
  104942. /**
  104943. * The dxgiFormat of the texture
  104944. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  104945. */
  104946. dxgiFormat: number;
  104947. /**
  104948. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  104949. */
  104950. textureType: number;
  104951. /**
  104952. * Sphericle polynomial created for the dds texture
  104953. */
  104954. sphericalPolynomial?: SphericalPolynomial;
  104955. }
  104956. /**
  104957. * Class used to provide DDS decompression tools
  104958. */
  104959. export class DDSTools {
  104960. /**
  104961. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  104962. */
  104963. static StoreLODInAlphaChannel: boolean;
  104964. /**
  104965. * Gets DDS information from an array buffer
  104966. * @param arrayBuffer defines the array buffer to read data from
  104967. * @returns the DDS information
  104968. */
  104969. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  104970. private static _FloatView;
  104971. private static _Int32View;
  104972. private static _ToHalfFloat;
  104973. private static _FromHalfFloat;
  104974. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  104975. private static _GetHalfFloatRGBAArrayBuffer;
  104976. private static _GetFloatRGBAArrayBuffer;
  104977. private static _GetFloatAsUIntRGBAArrayBuffer;
  104978. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  104979. private static _GetRGBAArrayBuffer;
  104980. private static _ExtractLongWordOrder;
  104981. private static _GetRGBArrayBuffer;
  104982. private static _GetLuminanceArrayBuffer;
  104983. /**
  104984. * Uploads DDS Levels to a Babylon Texture
  104985. * @hidden
  104986. */
  104987. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  104988. }
  104989. interface Engine {
  104990. /**
  104991. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  104992. * @param rootUrl defines the url where the file to load is located
  104993. * @param scene defines the current scene
  104994. * @param lodScale defines scale to apply to the mip map selection
  104995. * @param lodOffset defines offset to apply to the mip map selection
  104996. * @param onLoad defines an optional callback raised when the texture is loaded
  104997. * @param onError defines an optional callback raised if there is an issue to load the texture
  104998. * @param format defines the format of the data
  104999. * @param forcedExtension defines the extension to use to pick the right loader
  105000. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  105001. * @returns the cube texture as an InternalTexture
  105002. */
  105003. 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;
  105004. }
  105005. }
  105006. declare module BABYLON {
  105007. /**
  105008. * Implementation of the DDS Texture Loader.
  105009. * @hidden
  105010. */
  105011. export class _DDSTextureLoader implements IInternalTextureLoader {
  105012. /**
  105013. * Defines wether the loader supports cascade loading the different faces.
  105014. */
  105015. readonly supportCascades: boolean;
  105016. /**
  105017. * This returns if the loader support the current file information.
  105018. * @param extension defines the file extension of the file being loaded
  105019. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105020. * @param fallback defines the fallback internal texture if any
  105021. * @param isBase64 defines whether the texture is encoded as a base64
  105022. * @param isBuffer defines whether the texture data are stored as a buffer
  105023. * @returns true if the loader can load the specified file
  105024. */
  105025. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105026. /**
  105027. * Transform the url before loading if required.
  105028. * @param rootUrl the url of the texture
  105029. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105030. * @returns the transformed texture
  105031. */
  105032. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105033. /**
  105034. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105035. * @param rootUrl the url of the texture
  105036. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105037. * @returns the fallback texture
  105038. */
  105039. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105040. /**
  105041. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105042. * @param data contains the texture data
  105043. * @param texture defines the BabylonJS internal texture
  105044. * @param createPolynomials will be true if polynomials have been requested
  105045. * @param onLoad defines the callback to trigger once the texture is ready
  105046. * @param onError defines the callback to trigger in case of error
  105047. */
  105048. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105049. /**
  105050. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105051. * @param data contains the texture data
  105052. * @param texture defines the BabylonJS internal texture
  105053. * @param callback defines the method to call once ready to upload
  105054. */
  105055. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105056. }
  105057. }
  105058. declare module BABYLON {
  105059. /** @hidden */
  105060. export var rgbdEncodePixelShader: {
  105061. name: string;
  105062. shader: string;
  105063. };
  105064. }
  105065. declare module BABYLON {
  105066. /**
  105067. * Raw texture data and descriptor sufficient for WebGL texture upload
  105068. */
  105069. export interface EnvironmentTextureInfo {
  105070. /**
  105071. * Version of the environment map
  105072. */
  105073. version: number;
  105074. /**
  105075. * Width of image
  105076. */
  105077. width: number;
  105078. /**
  105079. * Irradiance information stored in the file.
  105080. */
  105081. irradiance: any;
  105082. /**
  105083. * Specular information stored in the file.
  105084. */
  105085. specular: any;
  105086. }
  105087. /**
  105088. * Sets of helpers addressing the serialization and deserialization of environment texture
  105089. * stored in a BabylonJS env file.
  105090. * Those files are usually stored as .env files.
  105091. */
  105092. export class EnvironmentTextureTools {
  105093. /**
  105094. * Magic number identifying the env file.
  105095. */
  105096. private static _MagicBytes;
  105097. /**
  105098. * Gets the environment info from an env file.
  105099. * @param data The array buffer containing the .env bytes.
  105100. * @returns the environment file info (the json header) if successfully parsed.
  105101. */
  105102. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  105103. /**
  105104. * Creates an environment texture from a loaded cube texture.
  105105. * @param texture defines the cube texture to convert in env file
  105106. * @return a promise containing the environment data if succesfull.
  105107. */
  105108. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  105109. /**
  105110. * Creates a JSON representation of the spherical data.
  105111. * @param texture defines the texture containing the polynomials
  105112. * @return the JSON representation of the spherical info
  105113. */
  105114. private static _CreateEnvTextureIrradiance;
  105115. /**
  105116. * Uploads the texture info contained in the env file to the GPU.
  105117. * @param texture defines the internal texture to upload to
  105118. * @param arrayBuffer defines the buffer cotaining the data to load
  105119. * @param info defines the texture info retrieved through the GetEnvInfo method
  105120. * @returns a promise
  105121. */
  105122. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  105123. /**
  105124. * Uploads the levels of image data to the GPU.
  105125. * @param texture defines the internal texture to upload to
  105126. * @param imageData defines the array buffer views of image data [mipmap][face]
  105127. * @returns a promise
  105128. */
  105129. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  105130. /**
  105131. * Uploads spherical polynomials information to the texture.
  105132. * @param texture defines the texture we are trying to upload the information to
  105133. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  105134. */
  105135. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  105136. /** @hidden */
  105137. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105138. }
  105139. }
  105140. declare module BABYLON {
  105141. /**
  105142. * Implementation of the ENV Texture Loader.
  105143. * @hidden
  105144. */
  105145. export class _ENVTextureLoader implements IInternalTextureLoader {
  105146. /**
  105147. * Defines wether the loader supports cascade loading the different faces.
  105148. */
  105149. readonly supportCascades: boolean;
  105150. /**
  105151. * This returns if the loader support the current file information.
  105152. * @param extension defines the file extension of the file being loaded
  105153. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105154. * @param fallback defines the fallback internal texture if any
  105155. * @param isBase64 defines whether the texture is encoded as a base64
  105156. * @param isBuffer defines whether the texture data are stored as a buffer
  105157. * @returns true if the loader can load the specified file
  105158. */
  105159. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105160. /**
  105161. * Transform the url before loading if required.
  105162. * @param rootUrl the url of the texture
  105163. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105164. * @returns the transformed texture
  105165. */
  105166. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105167. /**
  105168. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105169. * @param rootUrl the url of the texture
  105170. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105171. * @returns the fallback texture
  105172. */
  105173. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105174. /**
  105175. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105176. * @param data contains the texture data
  105177. * @param texture defines the BabylonJS internal texture
  105178. * @param createPolynomials will be true if polynomials have been requested
  105179. * @param onLoad defines the callback to trigger once the texture is ready
  105180. * @param onError defines the callback to trigger in case of error
  105181. */
  105182. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105183. /**
  105184. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105185. * @param data contains the texture data
  105186. * @param texture defines the BabylonJS internal texture
  105187. * @param callback defines the method to call once ready to upload
  105188. */
  105189. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105190. }
  105191. }
  105192. declare module BABYLON {
  105193. /**
  105194. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  105195. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  105196. */
  105197. export class KhronosTextureContainer {
  105198. /** contents of the KTX container file */
  105199. arrayBuffer: any;
  105200. private static HEADER_LEN;
  105201. private static COMPRESSED_2D;
  105202. private static COMPRESSED_3D;
  105203. private static TEX_2D;
  105204. private static TEX_3D;
  105205. /**
  105206. * Gets the openGL type
  105207. */
  105208. glType: number;
  105209. /**
  105210. * Gets the openGL type size
  105211. */
  105212. glTypeSize: number;
  105213. /**
  105214. * Gets the openGL format
  105215. */
  105216. glFormat: number;
  105217. /**
  105218. * Gets the openGL internal format
  105219. */
  105220. glInternalFormat: number;
  105221. /**
  105222. * Gets the base internal format
  105223. */
  105224. glBaseInternalFormat: number;
  105225. /**
  105226. * Gets image width in pixel
  105227. */
  105228. pixelWidth: number;
  105229. /**
  105230. * Gets image height in pixel
  105231. */
  105232. pixelHeight: number;
  105233. /**
  105234. * Gets image depth in pixels
  105235. */
  105236. pixelDepth: number;
  105237. /**
  105238. * Gets the number of array elements
  105239. */
  105240. numberOfArrayElements: number;
  105241. /**
  105242. * Gets the number of faces
  105243. */
  105244. numberOfFaces: number;
  105245. /**
  105246. * Gets the number of mipmap levels
  105247. */
  105248. numberOfMipmapLevels: number;
  105249. /**
  105250. * Gets the bytes of key value data
  105251. */
  105252. bytesOfKeyValueData: number;
  105253. /**
  105254. * Gets the load type
  105255. */
  105256. loadType: number;
  105257. /**
  105258. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  105259. */
  105260. isInvalid: boolean;
  105261. /**
  105262. * Creates a new KhronosTextureContainer
  105263. * @param arrayBuffer contents of the KTX container file
  105264. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  105265. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  105266. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  105267. */
  105268. constructor(
  105269. /** contents of the KTX container file */
  105270. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  105271. /**
  105272. * Uploads KTX content to a Babylon Texture.
  105273. * It is assumed that the texture has already been created & is currently bound
  105274. * @hidden
  105275. */
  105276. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  105277. private _upload2DCompressedLevels;
  105278. }
  105279. }
  105280. declare module BABYLON {
  105281. /**
  105282. * Implementation of the KTX Texture Loader.
  105283. * @hidden
  105284. */
  105285. export class _KTXTextureLoader implements IInternalTextureLoader {
  105286. /**
  105287. * Defines wether the loader supports cascade loading the different faces.
  105288. */
  105289. readonly supportCascades: boolean;
  105290. /**
  105291. * This returns if the loader support the current file information.
  105292. * @param extension defines the file extension of the file being loaded
  105293. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105294. * @param fallback defines the fallback internal texture if any
  105295. * @param isBase64 defines whether the texture is encoded as a base64
  105296. * @param isBuffer defines whether the texture data are stored as a buffer
  105297. * @returns true if the loader can load the specified file
  105298. */
  105299. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105300. /**
  105301. * Transform the url before loading if required.
  105302. * @param rootUrl the url of the texture
  105303. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105304. * @returns the transformed texture
  105305. */
  105306. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105307. /**
  105308. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105309. * @param rootUrl the url of the texture
  105310. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105311. * @returns the fallback texture
  105312. */
  105313. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105314. /**
  105315. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105316. * @param data contains the texture data
  105317. * @param texture defines the BabylonJS internal texture
  105318. * @param createPolynomials will be true if polynomials have been requested
  105319. * @param onLoad defines the callback to trigger once the texture is ready
  105320. * @param onError defines the callback to trigger in case of error
  105321. */
  105322. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105323. /**
  105324. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105325. * @param data contains the texture data
  105326. * @param texture defines the BabylonJS internal texture
  105327. * @param callback defines the method to call once ready to upload
  105328. */
  105329. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  105330. }
  105331. }
  105332. declare module BABYLON {
  105333. /** @hidden */
  105334. export var _forceSceneHelpersToBundle: boolean;
  105335. interface Scene {
  105336. /**
  105337. * Creates a default light for the scene.
  105338. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  105339. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  105340. */
  105341. createDefaultLight(replace?: boolean): void;
  105342. /**
  105343. * Creates a default camera for the scene.
  105344. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  105345. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105346. * @param replace has default false, when true replaces the active camera in the scene
  105347. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  105348. */
  105349. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105350. /**
  105351. * Creates a default camera and a default light.
  105352. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  105353. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105354. * @param replace has the default false, when true replaces the active camera/light in the scene
  105355. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  105356. */
  105357. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105358. /**
  105359. * Creates a new sky box
  105360. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  105361. * @param environmentTexture defines the texture to use as environment texture
  105362. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  105363. * @param scale defines the overall scale of the skybox
  105364. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  105365. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  105366. * @returns a new mesh holding the sky box
  105367. */
  105368. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  105369. /**
  105370. * Creates a new environment
  105371. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  105372. * @param options defines the options you can use to configure the environment
  105373. * @returns the new EnvironmentHelper
  105374. */
  105375. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  105376. /**
  105377. * Creates a new VREXperienceHelper
  105378. * @see http://doc.babylonjs.com/how_to/webvr_helper
  105379. * @param webVROptions defines the options used to create the new VREXperienceHelper
  105380. * @returns a new VREXperienceHelper
  105381. */
  105382. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  105383. /**
  105384. * Creates a new XREXperienceHelper
  105385. * @see http://doc.babylonjs.com/how_to/webxr
  105386. * @returns a promise for a new XREXperienceHelper
  105387. */
  105388. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  105389. }
  105390. }
  105391. declare module BABYLON {
  105392. /**
  105393. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  105394. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  105395. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  105396. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  105397. */
  105398. export class VideoDome extends TransformNode {
  105399. /**
  105400. * Define the video source as a Monoscopic panoramic 360 video.
  105401. */
  105402. static readonly MODE_MONOSCOPIC: number;
  105403. /**
  105404. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105405. */
  105406. static readonly MODE_TOPBOTTOM: number;
  105407. /**
  105408. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105409. */
  105410. static readonly MODE_SIDEBYSIDE: number;
  105411. private _useDirectMapping;
  105412. /**
  105413. * The video texture being displayed on the sphere
  105414. */
  105415. protected _videoTexture: VideoTexture;
  105416. /**
  105417. * Gets the video texture being displayed on the sphere
  105418. */
  105419. readonly videoTexture: VideoTexture;
  105420. /**
  105421. * The skybox material
  105422. */
  105423. protected _material: BackgroundMaterial;
  105424. /**
  105425. * The surface used for the skybox
  105426. */
  105427. protected _mesh: Mesh;
  105428. /**
  105429. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  105430. * Also see the options.resolution property.
  105431. */
  105432. fovMultiplier: number;
  105433. private _videoMode;
  105434. /**
  105435. * Gets or set the current video mode for the video. It can be:
  105436. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  105437. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105438. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105439. */
  105440. videoMode: number;
  105441. /**
  105442. * Oberserver used in Stereoscopic VR Mode.
  105443. */
  105444. private _onBeforeCameraRenderObserver;
  105445. /**
  105446. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  105447. * @param name Element's name, child elements will append suffixes for their own names.
  105448. * @param urlsOrVideo defines the url(s) or the video element to use
  105449. * @param options An object containing optional or exposed sub element properties
  105450. */
  105451. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  105452. resolution?: number;
  105453. clickToPlay?: boolean;
  105454. autoPlay?: boolean;
  105455. loop?: boolean;
  105456. size?: number;
  105457. poster?: string;
  105458. faceForward?: boolean;
  105459. useDirectMapping?: boolean;
  105460. }, scene: Scene);
  105461. private _changeVideoMode;
  105462. /**
  105463. * Releases resources associated with this node.
  105464. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105465. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105466. */
  105467. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105468. }
  105469. }
  105470. declare module BABYLON {
  105471. /**
  105472. * This class can be used to get instrumentation data from a Babylon engine
  105473. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105474. */
  105475. export class EngineInstrumentation implements IDisposable {
  105476. /**
  105477. * Define the instrumented engine.
  105478. */
  105479. engine: Engine;
  105480. private _captureGPUFrameTime;
  105481. private _gpuFrameTimeToken;
  105482. private _gpuFrameTime;
  105483. private _captureShaderCompilationTime;
  105484. private _shaderCompilationTime;
  105485. private _onBeginFrameObserver;
  105486. private _onEndFrameObserver;
  105487. private _onBeforeShaderCompilationObserver;
  105488. private _onAfterShaderCompilationObserver;
  105489. /**
  105490. * Gets the perf counter used for GPU frame time
  105491. */
  105492. readonly gpuFrameTimeCounter: PerfCounter;
  105493. /**
  105494. * Gets the GPU frame time capture status
  105495. */
  105496. /**
  105497. * Enable or disable the GPU frame time capture
  105498. */
  105499. captureGPUFrameTime: boolean;
  105500. /**
  105501. * Gets the perf counter used for shader compilation time
  105502. */
  105503. readonly shaderCompilationTimeCounter: PerfCounter;
  105504. /**
  105505. * Gets the shader compilation time capture status
  105506. */
  105507. /**
  105508. * Enable or disable the shader compilation time capture
  105509. */
  105510. captureShaderCompilationTime: boolean;
  105511. /**
  105512. * Instantiates a new engine instrumentation.
  105513. * This class can be used to get instrumentation data from a Babylon engine
  105514. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105515. * @param engine Defines the engine to instrument
  105516. */
  105517. constructor(
  105518. /**
  105519. * Define the instrumented engine.
  105520. */
  105521. engine: Engine);
  105522. /**
  105523. * Dispose and release associated resources.
  105524. */
  105525. dispose(): void;
  105526. }
  105527. }
  105528. declare module BABYLON {
  105529. /**
  105530. * This class can be used to get instrumentation data from a Babylon engine
  105531. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105532. */
  105533. export class SceneInstrumentation implements IDisposable {
  105534. /**
  105535. * Defines the scene to instrument
  105536. */
  105537. scene: Scene;
  105538. private _captureActiveMeshesEvaluationTime;
  105539. private _activeMeshesEvaluationTime;
  105540. private _captureRenderTargetsRenderTime;
  105541. private _renderTargetsRenderTime;
  105542. private _captureFrameTime;
  105543. private _frameTime;
  105544. private _captureRenderTime;
  105545. private _renderTime;
  105546. private _captureInterFrameTime;
  105547. private _interFrameTime;
  105548. private _captureParticlesRenderTime;
  105549. private _particlesRenderTime;
  105550. private _captureSpritesRenderTime;
  105551. private _spritesRenderTime;
  105552. private _capturePhysicsTime;
  105553. private _physicsTime;
  105554. private _captureAnimationsTime;
  105555. private _animationsTime;
  105556. private _captureCameraRenderTime;
  105557. private _cameraRenderTime;
  105558. private _onBeforeActiveMeshesEvaluationObserver;
  105559. private _onAfterActiveMeshesEvaluationObserver;
  105560. private _onBeforeRenderTargetsRenderObserver;
  105561. private _onAfterRenderTargetsRenderObserver;
  105562. private _onAfterRenderObserver;
  105563. private _onBeforeDrawPhaseObserver;
  105564. private _onAfterDrawPhaseObserver;
  105565. private _onBeforeAnimationsObserver;
  105566. private _onBeforeParticlesRenderingObserver;
  105567. private _onAfterParticlesRenderingObserver;
  105568. private _onBeforeSpritesRenderingObserver;
  105569. private _onAfterSpritesRenderingObserver;
  105570. private _onBeforePhysicsObserver;
  105571. private _onAfterPhysicsObserver;
  105572. private _onAfterAnimationsObserver;
  105573. private _onBeforeCameraRenderObserver;
  105574. private _onAfterCameraRenderObserver;
  105575. /**
  105576. * Gets the perf counter used for active meshes evaluation time
  105577. */
  105578. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  105579. /**
  105580. * Gets the active meshes evaluation time capture status
  105581. */
  105582. /**
  105583. * Enable or disable the active meshes evaluation time capture
  105584. */
  105585. captureActiveMeshesEvaluationTime: boolean;
  105586. /**
  105587. * Gets the perf counter used for render targets render time
  105588. */
  105589. readonly renderTargetsRenderTimeCounter: PerfCounter;
  105590. /**
  105591. * Gets the render targets render time capture status
  105592. */
  105593. /**
  105594. * Enable or disable the render targets render time capture
  105595. */
  105596. captureRenderTargetsRenderTime: boolean;
  105597. /**
  105598. * Gets the perf counter used for particles render time
  105599. */
  105600. readonly particlesRenderTimeCounter: PerfCounter;
  105601. /**
  105602. * Gets the particles render time capture status
  105603. */
  105604. /**
  105605. * Enable or disable the particles render time capture
  105606. */
  105607. captureParticlesRenderTime: boolean;
  105608. /**
  105609. * Gets the perf counter used for sprites render time
  105610. */
  105611. readonly spritesRenderTimeCounter: PerfCounter;
  105612. /**
  105613. * Gets the sprites render time capture status
  105614. */
  105615. /**
  105616. * Enable or disable the sprites render time capture
  105617. */
  105618. captureSpritesRenderTime: boolean;
  105619. /**
  105620. * Gets the perf counter used for physics time
  105621. */
  105622. readonly physicsTimeCounter: PerfCounter;
  105623. /**
  105624. * Gets the physics time capture status
  105625. */
  105626. /**
  105627. * Enable or disable the physics time capture
  105628. */
  105629. capturePhysicsTime: boolean;
  105630. /**
  105631. * Gets the perf counter used for animations time
  105632. */
  105633. readonly animationsTimeCounter: PerfCounter;
  105634. /**
  105635. * Gets the animations time capture status
  105636. */
  105637. /**
  105638. * Enable or disable the animations time capture
  105639. */
  105640. captureAnimationsTime: boolean;
  105641. /**
  105642. * Gets the perf counter used for frame time capture
  105643. */
  105644. readonly frameTimeCounter: PerfCounter;
  105645. /**
  105646. * Gets the frame time capture status
  105647. */
  105648. /**
  105649. * Enable or disable the frame time capture
  105650. */
  105651. captureFrameTime: boolean;
  105652. /**
  105653. * Gets the perf counter used for inter-frames time capture
  105654. */
  105655. readonly interFrameTimeCounter: PerfCounter;
  105656. /**
  105657. * Gets the inter-frames time capture status
  105658. */
  105659. /**
  105660. * Enable or disable the inter-frames time capture
  105661. */
  105662. captureInterFrameTime: boolean;
  105663. /**
  105664. * Gets the perf counter used for render time capture
  105665. */
  105666. readonly renderTimeCounter: PerfCounter;
  105667. /**
  105668. * Gets the render time capture status
  105669. */
  105670. /**
  105671. * Enable or disable the render time capture
  105672. */
  105673. captureRenderTime: boolean;
  105674. /**
  105675. * Gets the perf counter used for camera render time capture
  105676. */
  105677. readonly cameraRenderTimeCounter: PerfCounter;
  105678. /**
  105679. * Gets the camera render time capture status
  105680. */
  105681. /**
  105682. * Enable or disable the camera render time capture
  105683. */
  105684. captureCameraRenderTime: boolean;
  105685. /**
  105686. * Gets the perf counter used for draw calls
  105687. */
  105688. readonly drawCallsCounter: PerfCounter;
  105689. /**
  105690. * Instantiates a new scene instrumentation.
  105691. * This class can be used to get instrumentation data from a Babylon engine
  105692. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105693. * @param scene Defines the scene to instrument
  105694. */
  105695. constructor(
  105696. /**
  105697. * Defines the scene to instrument
  105698. */
  105699. scene: Scene);
  105700. /**
  105701. * Dispose and release associated resources.
  105702. */
  105703. dispose(): void;
  105704. }
  105705. }
  105706. declare module BABYLON {
  105707. /** @hidden */
  105708. export var glowMapGenerationPixelShader: {
  105709. name: string;
  105710. shader: string;
  105711. };
  105712. }
  105713. declare module BABYLON {
  105714. /** @hidden */
  105715. export var glowMapGenerationVertexShader: {
  105716. name: string;
  105717. shader: string;
  105718. };
  105719. }
  105720. declare module BABYLON {
  105721. /**
  105722. * Effect layer options. This helps customizing the behaviour
  105723. * of the effect layer.
  105724. */
  105725. export interface IEffectLayerOptions {
  105726. /**
  105727. * Multiplication factor apply to the canvas size to compute the render target size
  105728. * used to generated the objects (the smaller the faster).
  105729. */
  105730. mainTextureRatio: number;
  105731. /**
  105732. * Enforces a fixed size texture to ensure effect stability across devices.
  105733. */
  105734. mainTextureFixedSize?: number;
  105735. /**
  105736. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  105737. */
  105738. alphaBlendingMode: number;
  105739. /**
  105740. * The camera attached to the layer.
  105741. */
  105742. camera: Nullable<Camera>;
  105743. /**
  105744. * The rendering group to draw the layer in.
  105745. */
  105746. renderingGroupId: number;
  105747. }
  105748. /**
  105749. * The effect layer Helps adding post process effect blended with the main pass.
  105750. *
  105751. * This can be for instance use to generate glow or higlight effects on the scene.
  105752. *
  105753. * The effect layer class can not be used directly and is intented to inherited from to be
  105754. * customized per effects.
  105755. */
  105756. export abstract class EffectLayer {
  105757. private _vertexBuffers;
  105758. private _indexBuffer;
  105759. private _cachedDefines;
  105760. private _effectLayerMapGenerationEffect;
  105761. private _effectLayerOptions;
  105762. private _mergeEffect;
  105763. protected _scene: Scene;
  105764. protected _engine: Engine;
  105765. protected _maxSize: number;
  105766. protected _mainTextureDesiredSize: ISize;
  105767. protected _mainTexture: RenderTargetTexture;
  105768. protected _shouldRender: boolean;
  105769. protected _postProcesses: PostProcess[];
  105770. protected _textures: BaseTexture[];
  105771. protected _emissiveTextureAndColor: {
  105772. texture: Nullable<BaseTexture>;
  105773. color: Color4;
  105774. };
  105775. /**
  105776. * The name of the layer
  105777. */
  105778. name: string;
  105779. /**
  105780. * The clear color of the texture used to generate the glow map.
  105781. */
  105782. neutralColor: Color4;
  105783. /**
  105784. * Specifies wether the highlight layer is enabled or not.
  105785. */
  105786. isEnabled: boolean;
  105787. /**
  105788. * Gets the camera attached to the layer.
  105789. */
  105790. readonly camera: Nullable<Camera>;
  105791. /**
  105792. * Gets the rendering group id the layer should render in.
  105793. */
  105794. readonly renderingGroupId: number;
  105795. /**
  105796. * An event triggered when the effect layer has been disposed.
  105797. */
  105798. onDisposeObservable: Observable<EffectLayer>;
  105799. /**
  105800. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  105801. */
  105802. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  105803. /**
  105804. * An event triggered when the generated texture is being merged in the scene.
  105805. */
  105806. onBeforeComposeObservable: Observable<EffectLayer>;
  105807. /**
  105808. * An event triggered when the generated texture has been merged in the scene.
  105809. */
  105810. onAfterComposeObservable: Observable<EffectLayer>;
  105811. /**
  105812. * An event triggered when the efffect layer changes its size.
  105813. */
  105814. onSizeChangedObservable: Observable<EffectLayer>;
  105815. /** @hidden */
  105816. static _SceneComponentInitialization: (scene: Scene) => void;
  105817. /**
  105818. * Instantiates a new effect Layer and references it in the scene.
  105819. * @param name The name of the layer
  105820. * @param scene The scene to use the layer in
  105821. */
  105822. constructor(
  105823. /** The Friendly of the effect in the scene */
  105824. name: string, scene: Scene);
  105825. /**
  105826. * Get the effect name of the layer.
  105827. * @return The effect name
  105828. */
  105829. abstract getEffectName(): string;
  105830. /**
  105831. * Checks for the readiness of the element composing the layer.
  105832. * @param subMesh the mesh to check for
  105833. * @param useInstances specify wether or not to use instances to render the mesh
  105834. * @return true if ready otherwise, false
  105835. */
  105836. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105837. /**
  105838. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  105839. * @returns true if the effect requires stencil during the main canvas render pass.
  105840. */
  105841. abstract needStencil(): boolean;
  105842. /**
  105843. * Create the merge effect. This is the shader use to blit the information back
  105844. * to the main canvas at the end of the scene rendering.
  105845. * @returns The effect containing the shader used to merge the effect on the main canvas
  105846. */
  105847. protected abstract _createMergeEffect(): Effect;
  105848. /**
  105849. * Creates the render target textures and post processes used in the effect layer.
  105850. */
  105851. protected abstract _createTextureAndPostProcesses(): void;
  105852. /**
  105853. * Implementation specific of rendering the generating effect on the main canvas.
  105854. * @param effect The effect used to render through
  105855. */
  105856. protected abstract _internalRender(effect: Effect): void;
  105857. /**
  105858. * Sets the required values for both the emissive texture and and the main color.
  105859. */
  105860. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  105861. /**
  105862. * Free any resources and references associated to a mesh.
  105863. * Internal use
  105864. * @param mesh The mesh to free.
  105865. */
  105866. abstract _disposeMesh(mesh: Mesh): void;
  105867. /**
  105868. * Serializes this layer (Glow or Highlight for example)
  105869. * @returns a serialized layer object
  105870. */
  105871. abstract serialize?(): any;
  105872. /**
  105873. * Initializes the effect layer with the required options.
  105874. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  105875. */
  105876. protected _init(options: Partial<IEffectLayerOptions>): void;
  105877. /**
  105878. * Generates the index buffer of the full screen quad blending to the main canvas.
  105879. */
  105880. private _generateIndexBuffer;
  105881. /**
  105882. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  105883. */
  105884. private _genrateVertexBuffer;
  105885. /**
  105886. * Sets the main texture desired size which is the closest power of two
  105887. * of the engine canvas size.
  105888. */
  105889. private _setMainTextureSize;
  105890. /**
  105891. * Creates the main texture for the effect layer.
  105892. */
  105893. protected _createMainTexture(): void;
  105894. /**
  105895. * Adds specific effects defines.
  105896. * @param defines The defines to add specifics to.
  105897. */
  105898. protected _addCustomEffectDefines(defines: string[]): void;
  105899. /**
  105900. * Checks for the readiness of the element composing the layer.
  105901. * @param subMesh the mesh to check for
  105902. * @param useInstances specify wether or not to use instances to render the mesh
  105903. * @param emissiveTexture the associated emissive texture used to generate the glow
  105904. * @return true if ready otherwise, false
  105905. */
  105906. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  105907. /**
  105908. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  105909. */
  105910. render(): void;
  105911. /**
  105912. * Determine if a given mesh will be used in the current effect.
  105913. * @param mesh mesh to test
  105914. * @returns true if the mesh will be used
  105915. */
  105916. hasMesh(mesh: AbstractMesh): boolean;
  105917. /**
  105918. * Returns true if the layer contains information to display, otherwise false.
  105919. * @returns true if the glow layer should be rendered
  105920. */
  105921. shouldRender(): boolean;
  105922. /**
  105923. * Returns true if the mesh should render, otherwise false.
  105924. * @param mesh The mesh to render
  105925. * @returns true if it should render otherwise false
  105926. */
  105927. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  105928. /**
  105929. * Returns true if the mesh can be rendered, otherwise false.
  105930. * @param mesh The mesh to render
  105931. * @param material The material used on the mesh
  105932. * @returns true if it can be rendered otherwise false
  105933. */
  105934. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  105935. /**
  105936. * Returns true if the mesh should render, otherwise false.
  105937. * @param mesh The mesh to render
  105938. * @returns true if it should render otherwise false
  105939. */
  105940. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  105941. /**
  105942. * Renders the submesh passed in parameter to the generation map.
  105943. */
  105944. protected _renderSubMesh(subMesh: SubMesh): void;
  105945. /**
  105946. * Rebuild the required buffers.
  105947. * @hidden Internal use only.
  105948. */
  105949. _rebuild(): void;
  105950. /**
  105951. * Dispose only the render target textures and post process.
  105952. */
  105953. private _disposeTextureAndPostProcesses;
  105954. /**
  105955. * Dispose the highlight layer and free resources.
  105956. */
  105957. dispose(): void;
  105958. /**
  105959. * Gets the class name of the effect layer
  105960. * @returns the string with the class name of the effect layer
  105961. */
  105962. getClassName(): string;
  105963. /**
  105964. * Creates an effect layer from parsed effect layer data
  105965. * @param parsedEffectLayer defines effect layer data
  105966. * @param scene defines the current scene
  105967. * @param rootUrl defines the root URL containing the effect layer information
  105968. * @returns a parsed effect Layer
  105969. */
  105970. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  105971. }
  105972. }
  105973. declare module BABYLON {
  105974. interface AbstractScene {
  105975. /**
  105976. * The list of effect layers (highlights/glow) added to the scene
  105977. * @see http://doc.babylonjs.com/how_to/highlight_layer
  105978. * @see http://doc.babylonjs.com/how_to/glow_layer
  105979. */
  105980. effectLayers: Array<EffectLayer>;
  105981. /**
  105982. * Removes the given effect layer from this scene.
  105983. * @param toRemove defines the effect layer to remove
  105984. * @returns the index of the removed effect layer
  105985. */
  105986. removeEffectLayer(toRemove: EffectLayer): number;
  105987. /**
  105988. * Adds the given effect layer to this scene
  105989. * @param newEffectLayer defines the effect layer to add
  105990. */
  105991. addEffectLayer(newEffectLayer: EffectLayer): void;
  105992. }
  105993. /**
  105994. * Defines the layer scene component responsible to manage any effect layers
  105995. * in a given scene.
  105996. */
  105997. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  105998. /**
  105999. * The component name helpfull to identify the component in the list of scene components.
  106000. */
  106001. readonly name: string;
  106002. /**
  106003. * The scene the component belongs to.
  106004. */
  106005. scene: Scene;
  106006. private _engine;
  106007. private _renderEffects;
  106008. private _needStencil;
  106009. private _previousStencilState;
  106010. /**
  106011. * Creates a new instance of the component for the given scene
  106012. * @param scene Defines the scene to register the component in
  106013. */
  106014. constructor(scene: Scene);
  106015. /**
  106016. * Registers the component in a given scene
  106017. */
  106018. register(): void;
  106019. /**
  106020. * Rebuilds the elements related to this component in case of
  106021. * context lost for instance.
  106022. */
  106023. rebuild(): void;
  106024. /**
  106025. * Serializes the component data to the specified json object
  106026. * @param serializationObject The object to serialize to
  106027. */
  106028. serialize(serializationObject: any): void;
  106029. /**
  106030. * Adds all the element from the container to the scene
  106031. * @param container the container holding the elements
  106032. */
  106033. addFromContainer(container: AbstractScene): void;
  106034. /**
  106035. * Removes all the elements in the container from the scene
  106036. * @param container contains the elements to remove
  106037. * @param dispose if the removed element should be disposed (default: false)
  106038. */
  106039. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106040. /**
  106041. * Disposes the component and the associated ressources.
  106042. */
  106043. dispose(): void;
  106044. private _isReadyForMesh;
  106045. private _renderMainTexture;
  106046. private _setStencil;
  106047. private _setStencilBack;
  106048. private _draw;
  106049. private _drawCamera;
  106050. private _drawRenderingGroup;
  106051. }
  106052. }
  106053. declare module BABYLON {
  106054. /** @hidden */
  106055. export var glowMapMergePixelShader: {
  106056. name: string;
  106057. shader: string;
  106058. };
  106059. }
  106060. declare module BABYLON {
  106061. /** @hidden */
  106062. export var glowMapMergeVertexShader: {
  106063. name: string;
  106064. shader: string;
  106065. };
  106066. }
  106067. declare module BABYLON {
  106068. interface AbstractScene {
  106069. /**
  106070. * Return a the first highlight layer of the scene with a given name.
  106071. * @param name The name of the highlight layer to look for.
  106072. * @return The highlight layer if found otherwise null.
  106073. */
  106074. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  106075. }
  106076. /**
  106077. * Glow layer options. This helps customizing the behaviour
  106078. * of the glow layer.
  106079. */
  106080. export interface IGlowLayerOptions {
  106081. /**
  106082. * Multiplication factor apply to the canvas size to compute the render target size
  106083. * used to generated the glowing objects (the smaller the faster).
  106084. */
  106085. mainTextureRatio: number;
  106086. /**
  106087. * Enforces a fixed size texture to ensure resize independant blur.
  106088. */
  106089. mainTextureFixedSize?: number;
  106090. /**
  106091. * How big is the kernel of the blur texture.
  106092. */
  106093. blurKernelSize: number;
  106094. /**
  106095. * The camera attached to the layer.
  106096. */
  106097. camera: Nullable<Camera>;
  106098. /**
  106099. * Enable MSAA by chosing the number of samples.
  106100. */
  106101. mainTextureSamples?: number;
  106102. /**
  106103. * The rendering group to draw the layer in.
  106104. */
  106105. renderingGroupId: number;
  106106. }
  106107. /**
  106108. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  106109. *
  106110. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106111. * glowy meshes to your scene.
  106112. *
  106113. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  106114. */
  106115. export class GlowLayer extends EffectLayer {
  106116. /**
  106117. * Effect Name of the layer.
  106118. */
  106119. static readonly EffectName: string;
  106120. /**
  106121. * The default blur kernel size used for the glow.
  106122. */
  106123. static DefaultBlurKernelSize: number;
  106124. /**
  106125. * The default texture size ratio used for the glow.
  106126. */
  106127. static DefaultTextureRatio: number;
  106128. /**
  106129. * Sets the kernel size of the blur.
  106130. */
  106131. /**
  106132. * Gets the kernel size of the blur.
  106133. */
  106134. blurKernelSize: number;
  106135. /**
  106136. * Sets the glow intensity.
  106137. */
  106138. /**
  106139. * Gets the glow intensity.
  106140. */
  106141. intensity: number;
  106142. private _options;
  106143. private _intensity;
  106144. private _horizontalBlurPostprocess1;
  106145. private _verticalBlurPostprocess1;
  106146. private _horizontalBlurPostprocess2;
  106147. private _verticalBlurPostprocess2;
  106148. private _blurTexture1;
  106149. private _blurTexture2;
  106150. private _postProcesses1;
  106151. private _postProcesses2;
  106152. private _includedOnlyMeshes;
  106153. private _excludedMeshes;
  106154. /**
  106155. * Callback used to let the user override the color selection on a per mesh basis
  106156. */
  106157. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  106158. /**
  106159. * Callback used to let the user override the texture selection on a per mesh basis
  106160. */
  106161. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  106162. /**
  106163. * Instantiates a new glow Layer and references it to the scene.
  106164. * @param name The name of the layer
  106165. * @param scene The scene to use the layer in
  106166. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  106167. */
  106168. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  106169. /**
  106170. * Get the effect name of the layer.
  106171. * @return The effect name
  106172. */
  106173. getEffectName(): string;
  106174. /**
  106175. * Create the merge effect. This is the shader use to blit the information back
  106176. * to the main canvas at the end of the scene rendering.
  106177. */
  106178. protected _createMergeEffect(): Effect;
  106179. /**
  106180. * Creates the render target textures and post processes used in the glow layer.
  106181. */
  106182. protected _createTextureAndPostProcesses(): void;
  106183. /**
  106184. * Checks for the readiness of the element composing the layer.
  106185. * @param subMesh the mesh to check for
  106186. * @param useInstances specify wether or not to use instances to render the mesh
  106187. * @param emissiveTexture the associated emissive texture used to generate the glow
  106188. * @return true if ready otherwise, false
  106189. */
  106190. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106191. /**
  106192. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106193. */
  106194. needStencil(): boolean;
  106195. /**
  106196. * Returns true if the mesh can be rendered, otherwise false.
  106197. * @param mesh The mesh to render
  106198. * @param material The material used on the mesh
  106199. * @returns true if it can be rendered otherwise false
  106200. */
  106201. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106202. /**
  106203. * Implementation specific of rendering the generating effect on the main canvas.
  106204. * @param effect The effect used to render through
  106205. */
  106206. protected _internalRender(effect: Effect): void;
  106207. /**
  106208. * Sets the required values for both the emissive texture and and the main color.
  106209. */
  106210. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106211. /**
  106212. * Returns true if the mesh should render, otherwise false.
  106213. * @param mesh The mesh to render
  106214. * @returns true if it should render otherwise false
  106215. */
  106216. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106217. /**
  106218. * Adds specific effects defines.
  106219. * @param defines The defines to add specifics to.
  106220. */
  106221. protected _addCustomEffectDefines(defines: string[]): void;
  106222. /**
  106223. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  106224. * @param mesh The mesh to exclude from the glow layer
  106225. */
  106226. addExcludedMesh(mesh: Mesh): void;
  106227. /**
  106228. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  106229. * @param mesh The mesh to remove
  106230. */
  106231. removeExcludedMesh(mesh: Mesh): void;
  106232. /**
  106233. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  106234. * @param mesh The mesh to include in the glow layer
  106235. */
  106236. addIncludedOnlyMesh(mesh: Mesh): void;
  106237. /**
  106238. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  106239. * @param mesh The mesh to remove
  106240. */
  106241. removeIncludedOnlyMesh(mesh: Mesh): void;
  106242. /**
  106243. * Determine if a given mesh will be used in the glow layer
  106244. * @param mesh The mesh to test
  106245. * @returns true if the mesh will be highlighted by the current glow layer
  106246. */
  106247. hasMesh(mesh: AbstractMesh): boolean;
  106248. /**
  106249. * Free any resources and references associated to a mesh.
  106250. * Internal use
  106251. * @param mesh The mesh to free.
  106252. * @hidden
  106253. */
  106254. _disposeMesh(mesh: Mesh): void;
  106255. /**
  106256. * Gets the class name of the effect layer
  106257. * @returns the string with the class name of the effect layer
  106258. */
  106259. getClassName(): string;
  106260. /**
  106261. * Serializes this glow layer
  106262. * @returns a serialized glow layer object
  106263. */
  106264. serialize(): any;
  106265. /**
  106266. * Creates a Glow Layer from parsed glow layer data
  106267. * @param parsedGlowLayer defines glow layer data
  106268. * @param scene defines the current scene
  106269. * @param rootUrl defines the root URL containing the glow layer information
  106270. * @returns a parsed Glow Layer
  106271. */
  106272. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  106273. }
  106274. }
  106275. declare module BABYLON {
  106276. /** @hidden */
  106277. export var glowBlurPostProcessPixelShader: {
  106278. name: string;
  106279. shader: string;
  106280. };
  106281. }
  106282. declare module BABYLON {
  106283. interface AbstractScene {
  106284. /**
  106285. * Return a the first highlight layer of the scene with a given name.
  106286. * @param name The name of the highlight layer to look for.
  106287. * @return The highlight layer if found otherwise null.
  106288. */
  106289. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  106290. }
  106291. /**
  106292. * Highlight layer options. This helps customizing the behaviour
  106293. * of the highlight layer.
  106294. */
  106295. export interface IHighlightLayerOptions {
  106296. /**
  106297. * Multiplication factor apply to the canvas size to compute the render target size
  106298. * used to generated the glowing objects (the smaller the faster).
  106299. */
  106300. mainTextureRatio: number;
  106301. /**
  106302. * Enforces a fixed size texture to ensure resize independant blur.
  106303. */
  106304. mainTextureFixedSize?: number;
  106305. /**
  106306. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  106307. * of the picture to blur (the smaller the faster).
  106308. */
  106309. blurTextureSizeRatio: number;
  106310. /**
  106311. * How big in texel of the blur texture is the vertical blur.
  106312. */
  106313. blurVerticalSize: number;
  106314. /**
  106315. * How big in texel of the blur texture is the horizontal blur.
  106316. */
  106317. blurHorizontalSize: number;
  106318. /**
  106319. * Alpha blending mode used to apply the blur. Default is combine.
  106320. */
  106321. alphaBlendingMode: number;
  106322. /**
  106323. * The camera attached to the layer.
  106324. */
  106325. camera: Nullable<Camera>;
  106326. /**
  106327. * Should we display highlight as a solid stroke?
  106328. */
  106329. isStroke?: boolean;
  106330. /**
  106331. * The rendering group to draw the layer in.
  106332. */
  106333. renderingGroupId: number;
  106334. }
  106335. /**
  106336. * The highlight layer Helps adding a glow effect around a mesh.
  106337. *
  106338. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106339. * glowy meshes to your scene.
  106340. *
  106341. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  106342. */
  106343. export class HighlightLayer extends EffectLayer {
  106344. name: string;
  106345. /**
  106346. * Effect Name of the highlight layer.
  106347. */
  106348. static readonly EffectName: string;
  106349. /**
  106350. * The neutral color used during the preparation of the glow effect.
  106351. * This is black by default as the blend operation is a blend operation.
  106352. */
  106353. static NeutralColor: Color4;
  106354. /**
  106355. * Stencil value used for glowing meshes.
  106356. */
  106357. static GlowingMeshStencilReference: number;
  106358. /**
  106359. * Stencil value used for the other meshes in the scene.
  106360. */
  106361. static NormalMeshStencilReference: number;
  106362. /**
  106363. * Specifies whether or not the inner glow is ACTIVE in the layer.
  106364. */
  106365. innerGlow: boolean;
  106366. /**
  106367. * Specifies whether or not the outer glow is ACTIVE in the layer.
  106368. */
  106369. outerGlow: boolean;
  106370. /**
  106371. * Specifies the horizontal size of the blur.
  106372. */
  106373. /**
  106374. * Gets the horizontal size of the blur.
  106375. */
  106376. blurHorizontalSize: number;
  106377. /**
  106378. * Specifies the vertical size of the blur.
  106379. */
  106380. /**
  106381. * Gets the vertical size of the blur.
  106382. */
  106383. blurVerticalSize: number;
  106384. /**
  106385. * An event triggered when the highlight layer is being blurred.
  106386. */
  106387. onBeforeBlurObservable: Observable<HighlightLayer>;
  106388. /**
  106389. * An event triggered when the highlight layer has been blurred.
  106390. */
  106391. onAfterBlurObservable: Observable<HighlightLayer>;
  106392. private _instanceGlowingMeshStencilReference;
  106393. private _options;
  106394. private _downSamplePostprocess;
  106395. private _horizontalBlurPostprocess;
  106396. private _verticalBlurPostprocess;
  106397. private _blurTexture;
  106398. private _meshes;
  106399. private _excludedMeshes;
  106400. /**
  106401. * Instantiates a new highlight Layer and references it to the scene..
  106402. * @param name The name of the layer
  106403. * @param scene The scene to use the layer in
  106404. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  106405. */
  106406. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  106407. /**
  106408. * Get the effect name of the layer.
  106409. * @return The effect name
  106410. */
  106411. getEffectName(): string;
  106412. /**
  106413. * Create the merge effect. This is the shader use to blit the information back
  106414. * to the main canvas at the end of the scene rendering.
  106415. */
  106416. protected _createMergeEffect(): Effect;
  106417. /**
  106418. * Creates the render target textures and post processes used in the highlight layer.
  106419. */
  106420. protected _createTextureAndPostProcesses(): void;
  106421. /**
  106422. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106423. */
  106424. needStencil(): boolean;
  106425. /**
  106426. * Checks for the readiness of the element composing the layer.
  106427. * @param subMesh the mesh to check for
  106428. * @param useInstances specify wether or not to use instances to render the mesh
  106429. * @param emissiveTexture the associated emissive texture used to generate the glow
  106430. * @return true if ready otherwise, false
  106431. */
  106432. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106433. /**
  106434. * Implementation specific of rendering the generating effect on the main canvas.
  106435. * @param effect The effect used to render through
  106436. */
  106437. protected _internalRender(effect: Effect): void;
  106438. /**
  106439. * Returns true if the layer contains information to display, otherwise false.
  106440. */
  106441. shouldRender(): boolean;
  106442. /**
  106443. * Returns true if the mesh should render, otherwise false.
  106444. * @param mesh The mesh to render
  106445. * @returns true if it should render otherwise false
  106446. */
  106447. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106448. /**
  106449. * Sets the required values for both the emissive texture and and the main color.
  106450. */
  106451. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106452. /**
  106453. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  106454. * @param mesh The mesh to exclude from the highlight layer
  106455. */
  106456. addExcludedMesh(mesh: Mesh): void;
  106457. /**
  106458. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  106459. * @param mesh The mesh to highlight
  106460. */
  106461. removeExcludedMesh(mesh: Mesh): void;
  106462. /**
  106463. * Determine if a given mesh will be highlighted by the current HighlightLayer
  106464. * @param mesh mesh to test
  106465. * @returns true if the mesh will be highlighted by the current HighlightLayer
  106466. */
  106467. hasMesh(mesh: AbstractMesh): boolean;
  106468. /**
  106469. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  106470. * @param mesh The mesh to highlight
  106471. * @param color The color of the highlight
  106472. * @param glowEmissiveOnly Extract the glow from the emissive texture
  106473. */
  106474. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  106475. /**
  106476. * Remove a mesh from the highlight layer in order to make it stop glowing.
  106477. * @param mesh The mesh to highlight
  106478. */
  106479. removeMesh(mesh: Mesh): void;
  106480. /**
  106481. * Force the stencil to the normal expected value for none glowing parts
  106482. */
  106483. private _defaultStencilReference;
  106484. /**
  106485. * Free any resources and references associated to a mesh.
  106486. * Internal use
  106487. * @param mesh The mesh to free.
  106488. * @hidden
  106489. */
  106490. _disposeMesh(mesh: Mesh): void;
  106491. /**
  106492. * Dispose the highlight layer and free resources.
  106493. */
  106494. dispose(): void;
  106495. /**
  106496. * Gets the class name of the effect layer
  106497. * @returns the string with the class name of the effect layer
  106498. */
  106499. getClassName(): string;
  106500. /**
  106501. * Serializes this Highlight layer
  106502. * @returns a serialized Highlight layer object
  106503. */
  106504. serialize(): any;
  106505. /**
  106506. * Creates a Highlight layer from parsed Highlight layer data
  106507. * @param parsedHightlightLayer defines the Highlight layer data
  106508. * @param scene defines the current scene
  106509. * @param rootUrl defines the root URL containing the Highlight layer information
  106510. * @returns a parsed Highlight layer
  106511. */
  106512. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  106513. }
  106514. }
  106515. declare module BABYLON {
  106516. /** @hidden */
  106517. export var lensFlarePixelShader: {
  106518. name: string;
  106519. shader: string;
  106520. };
  106521. }
  106522. declare module BABYLON {
  106523. /** @hidden */
  106524. export var lensFlareVertexShader: {
  106525. name: string;
  106526. shader: string;
  106527. };
  106528. }
  106529. declare module BABYLON {
  106530. /**
  106531. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106532. * It is usually composed of several `lensFlare`.
  106533. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106534. */
  106535. export class LensFlareSystem {
  106536. /**
  106537. * Define the name of the lens flare system
  106538. */
  106539. name: string;
  106540. /**
  106541. * List of lens flares used in this system.
  106542. */
  106543. lensFlares: LensFlare[];
  106544. /**
  106545. * Define a limit from the border the lens flare can be visible.
  106546. */
  106547. borderLimit: number;
  106548. /**
  106549. * Define a viewport border we do not want to see the lens flare in.
  106550. */
  106551. viewportBorder: number;
  106552. /**
  106553. * Define a predicate which could limit the list of meshes able to occlude the effect.
  106554. */
  106555. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106556. /**
  106557. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  106558. */
  106559. layerMask: number;
  106560. /**
  106561. * Define the id of the lens flare system in the scene.
  106562. * (equal to name by default)
  106563. */
  106564. id: string;
  106565. private _scene;
  106566. private _emitter;
  106567. private _vertexBuffers;
  106568. private _indexBuffer;
  106569. private _effect;
  106570. private _positionX;
  106571. private _positionY;
  106572. private _isEnabled;
  106573. /** @hidden */
  106574. static _SceneComponentInitialization: (scene: Scene) => void;
  106575. /**
  106576. * Instantiates a lens flare system.
  106577. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106578. * It is usually composed of several `lensFlare`.
  106579. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106580. * @param name Define the name of the lens flare system in the scene
  106581. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  106582. * @param scene Define the scene the lens flare system belongs to
  106583. */
  106584. constructor(
  106585. /**
  106586. * Define the name of the lens flare system
  106587. */
  106588. name: string, emitter: any, scene: Scene);
  106589. /**
  106590. * Define if the lens flare system is enabled.
  106591. */
  106592. isEnabled: boolean;
  106593. /**
  106594. * Get the scene the effects belongs to.
  106595. * @returns the scene holding the lens flare system
  106596. */
  106597. getScene(): Scene;
  106598. /**
  106599. * Get the emitter of the lens flare system.
  106600. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106601. * @returns the emitter of the lens flare system
  106602. */
  106603. getEmitter(): any;
  106604. /**
  106605. * Set the emitter of the lens flare system.
  106606. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106607. * @param newEmitter Define the new emitter of the system
  106608. */
  106609. setEmitter(newEmitter: any): void;
  106610. /**
  106611. * Get the lens flare system emitter position.
  106612. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  106613. * @returns the position
  106614. */
  106615. getEmitterPosition(): Vector3;
  106616. /**
  106617. * @hidden
  106618. */
  106619. computeEffectivePosition(globalViewport: Viewport): boolean;
  106620. /** @hidden */
  106621. _isVisible(): boolean;
  106622. /**
  106623. * @hidden
  106624. */
  106625. render(): boolean;
  106626. /**
  106627. * Dispose and release the lens flare with its associated resources.
  106628. */
  106629. dispose(): void;
  106630. /**
  106631. * Parse a lens flare system from a JSON repressentation
  106632. * @param parsedLensFlareSystem Define the JSON to parse
  106633. * @param scene Define the scene the parsed system should be instantiated in
  106634. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  106635. * @returns the parsed system
  106636. */
  106637. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  106638. /**
  106639. * Serialize the current Lens Flare System into a JSON representation.
  106640. * @returns the serialized JSON
  106641. */
  106642. serialize(): any;
  106643. }
  106644. }
  106645. declare module BABYLON {
  106646. /**
  106647. * This represents one of the lens effect in a `lensFlareSystem`.
  106648. * It controls one of the indiviual texture used in the effect.
  106649. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106650. */
  106651. export class LensFlare {
  106652. /**
  106653. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106654. */
  106655. size: number;
  106656. /**
  106657. * 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.
  106658. */
  106659. position: number;
  106660. /**
  106661. * Define the lens color.
  106662. */
  106663. color: Color3;
  106664. /**
  106665. * Define the lens texture.
  106666. */
  106667. texture: Nullable<Texture>;
  106668. /**
  106669. * Define the alpha mode to render this particular lens.
  106670. */
  106671. alphaMode: number;
  106672. private _system;
  106673. /**
  106674. * Creates a new Lens Flare.
  106675. * This represents one of the lens effect in a `lensFlareSystem`.
  106676. * It controls one of the indiviual texture used in the effect.
  106677. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106678. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  106679. * @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.
  106680. * @param color Define the lens color
  106681. * @param imgUrl Define the lens texture url
  106682. * @param system Define the `lensFlareSystem` this flare is part of
  106683. * @returns The newly created Lens Flare
  106684. */
  106685. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  106686. /**
  106687. * Instantiates a new Lens Flare.
  106688. * This represents one of the lens effect in a `lensFlareSystem`.
  106689. * It controls one of the indiviual texture used in the effect.
  106690. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106691. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  106692. * @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.
  106693. * @param color Define the lens color
  106694. * @param imgUrl Define the lens texture url
  106695. * @param system Define the `lensFlareSystem` this flare is part of
  106696. */
  106697. constructor(
  106698. /**
  106699. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106700. */
  106701. size: number,
  106702. /**
  106703. * 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.
  106704. */
  106705. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  106706. /**
  106707. * Dispose and release the lens flare with its associated resources.
  106708. */
  106709. dispose(): void;
  106710. }
  106711. }
  106712. declare module BABYLON {
  106713. interface AbstractScene {
  106714. /**
  106715. * The list of lens flare system added to the scene
  106716. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106717. */
  106718. lensFlareSystems: Array<LensFlareSystem>;
  106719. /**
  106720. * Removes the given lens flare system from this scene.
  106721. * @param toRemove The lens flare system to remove
  106722. * @returns The index of the removed lens flare system
  106723. */
  106724. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  106725. /**
  106726. * Adds the given lens flare system to this scene
  106727. * @param newLensFlareSystem The lens flare system to add
  106728. */
  106729. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  106730. /**
  106731. * Gets a lens flare system using its name
  106732. * @param name defines the name to look for
  106733. * @returns the lens flare system or null if not found
  106734. */
  106735. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  106736. /**
  106737. * Gets a lens flare system using its id
  106738. * @param id defines the id to look for
  106739. * @returns the lens flare system or null if not found
  106740. */
  106741. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  106742. }
  106743. /**
  106744. * Defines the lens flare scene component responsible to manage any lens flares
  106745. * in a given scene.
  106746. */
  106747. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  106748. /**
  106749. * The component name helpfull to identify the component in the list of scene components.
  106750. */
  106751. readonly name: string;
  106752. /**
  106753. * The scene the component belongs to.
  106754. */
  106755. scene: Scene;
  106756. /**
  106757. * Creates a new instance of the component for the given scene
  106758. * @param scene Defines the scene to register the component in
  106759. */
  106760. constructor(scene: Scene);
  106761. /**
  106762. * Registers the component in a given scene
  106763. */
  106764. register(): void;
  106765. /**
  106766. * Rebuilds the elements related to this component in case of
  106767. * context lost for instance.
  106768. */
  106769. rebuild(): void;
  106770. /**
  106771. * Adds all the element from the container to the scene
  106772. * @param container the container holding the elements
  106773. */
  106774. addFromContainer(container: AbstractScene): void;
  106775. /**
  106776. * Removes all the elements in the container from the scene
  106777. * @param container contains the elements to remove
  106778. * @param dispose if the removed element should be disposed (default: false)
  106779. */
  106780. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106781. /**
  106782. * Serializes the component data to the specified json object
  106783. * @param serializationObject The object to serialize to
  106784. */
  106785. serialize(serializationObject: any): void;
  106786. /**
  106787. * Disposes the component and the associated ressources.
  106788. */
  106789. dispose(): void;
  106790. private _draw;
  106791. }
  106792. }
  106793. declare module BABYLON {
  106794. /**
  106795. * Defines the shadow generator component responsible to manage any shadow generators
  106796. * in a given scene.
  106797. */
  106798. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  106799. /**
  106800. * The component name helpfull to identify the component in the list of scene components.
  106801. */
  106802. readonly name: string;
  106803. /**
  106804. * The scene the component belongs to.
  106805. */
  106806. scene: Scene;
  106807. /**
  106808. * Creates a new instance of the component for the given scene
  106809. * @param scene Defines the scene to register the component in
  106810. */
  106811. constructor(scene: Scene);
  106812. /**
  106813. * Registers the component in a given scene
  106814. */
  106815. register(): void;
  106816. /**
  106817. * Rebuilds the elements related to this component in case of
  106818. * context lost for instance.
  106819. */
  106820. rebuild(): void;
  106821. /**
  106822. * Serializes the component data to the specified json object
  106823. * @param serializationObject The object to serialize to
  106824. */
  106825. serialize(serializationObject: any): void;
  106826. /**
  106827. * Adds all the element from the container to the scene
  106828. * @param container the container holding the elements
  106829. */
  106830. addFromContainer(container: AbstractScene): void;
  106831. /**
  106832. * Removes all the elements in the container from the scene
  106833. * @param container contains the elements to remove
  106834. * @param dispose if the removed element should be disposed (default: false)
  106835. */
  106836. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106837. /**
  106838. * Rebuilds the elements related to this component in case of
  106839. * context lost for instance.
  106840. */
  106841. dispose(): void;
  106842. private _gatherRenderTargets;
  106843. }
  106844. }
  106845. declare module BABYLON {
  106846. /**
  106847. * A point light is a light defined by an unique point in world space.
  106848. * The light is emitted in every direction from this point.
  106849. * A good example of a point light is a standard light bulb.
  106850. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106851. */
  106852. export class PointLight extends ShadowLight {
  106853. private _shadowAngle;
  106854. /**
  106855. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106856. * This specifies what angle the shadow will use to be created.
  106857. *
  106858. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106859. */
  106860. /**
  106861. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106862. * This specifies what angle the shadow will use to be created.
  106863. *
  106864. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106865. */
  106866. shadowAngle: number;
  106867. /**
  106868. * Gets the direction if it has been set.
  106869. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106870. */
  106871. /**
  106872. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106873. */
  106874. direction: Vector3;
  106875. /**
  106876. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  106877. * A PointLight emits the light in every direction.
  106878. * It can cast shadows.
  106879. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  106880. * ```javascript
  106881. * var pointLight = new PointLight("pl", camera.position, scene);
  106882. * ```
  106883. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106884. * @param name The light friendly name
  106885. * @param position The position of the point light in the scene
  106886. * @param scene The scene the lights belongs to
  106887. */
  106888. constructor(name: string, position: Vector3, scene: Scene);
  106889. /**
  106890. * Returns the string "PointLight"
  106891. * @returns the class name
  106892. */
  106893. getClassName(): string;
  106894. /**
  106895. * Returns the integer 0.
  106896. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106897. */
  106898. getTypeID(): number;
  106899. /**
  106900. * Specifies wether or not the shadowmap should be a cube texture.
  106901. * @returns true if the shadowmap needs to be a cube texture.
  106902. */
  106903. needCube(): boolean;
  106904. /**
  106905. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  106906. * @param faceIndex The index of the face we are computed the direction to generate shadow
  106907. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  106908. */
  106909. getShadowDirection(faceIndex?: number): Vector3;
  106910. /**
  106911. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  106912. * - fov = PI / 2
  106913. * - aspect ratio : 1.0
  106914. * - z-near and far equal to the active camera minZ and maxZ.
  106915. * Returns the PointLight.
  106916. */
  106917. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106918. protected _buildUniformLayout(): void;
  106919. /**
  106920. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  106921. * @param effect The effect to update
  106922. * @param lightIndex The index of the light in the effect to update
  106923. * @returns The point light
  106924. */
  106925. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  106926. /**
  106927. * Prepares the list of defines specific to the light type.
  106928. * @param defines the list of defines
  106929. * @param lightIndex defines the index of the light for the effect
  106930. */
  106931. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106932. }
  106933. }
  106934. declare module BABYLON {
  106935. /**
  106936. * Header information of HDR texture files.
  106937. */
  106938. export interface HDRInfo {
  106939. /**
  106940. * The height of the texture in pixels.
  106941. */
  106942. height: number;
  106943. /**
  106944. * The width of the texture in pixels.
  106945. */
  106946. width: number;
  106947. /**
  106948. * The index of the beginning of the data in the binary file.
  106949. */
  106950. dataPosition: number;
  106951. }
  106952. /**
  106953. * This groups tools to convert HDR texture to native colors array.
  106954. */
  106955. export class HDRTools {
  106956. private static Ldexp;
  106957. private static Rgbe2float;
  106958. private static readStringLine;
  106959. /**
  106960. * Reads header information from an RGBE texture stored in a native array.
  106961. * More information on this format are available here:
  106962. * https://en.wikipedia.org/wiki/RGBE_image_format
  106963. *
  106964. * @param uint8array The binary file stored in native array.
  106965. * @return The header information.
  106966. */
  106967. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  106968. /**
  106969. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  106970. * This RGBE texture needs to store the information as a panorama.
  106971. *
  106972. * More information on this format are available here:
  106973. * https://en.wikipedia.org/wiki/RGBE_image_format
  106974. *
  106975. * @param buffer The binary file stored in an array buffer.
  106976. * @param size The expected size of the extracted cubemap.
  106977. * @return The Cube Map information.
  106978. */
  106979. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  106980. /**
  106981. * Returns the pixels data extracted from an RGBE texture.
  106982. * This pixels will be stored left to right up to down in the R G B order in one array.
  106983. *
  106984. * More information on this format are available here:
  106985. * https://en.wikipedia.org/wiki/RGBE_image_format
  106986. *
  106987. * @param uint8array The binary file stored in an array buffer.
  106988. * @param hdrInfo The header information of the file.
  106989. * @return The pixels data in RGB right to left up to down order.
  106990. */
  106991. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  106992. private static RGBE_ReadPixels_RLE;
  106993. }
  106994. }
  106995. declare module BABYLON {
  106996. /**
  106997. * This represents a texture coming from an HDR input.
  106998. *
  106999. * The only supported format is currently panorama picture stored in RGBE format.
  107000. * Example of such files can be found on HDRLib: http://hdrlib.com/
  107001. */
  107002. export class HDRCubeTexture extends BaseTexture {
  107003. private static _facesMapping;
  107004. private _generateHarmonics;
  107005. private _noMipmap;
  107006. private _textureMatrix;
  107007. private _size;
  107008. private _onLoad;
  107009. private _onError;
  107010. /**
  107011. * The texture URL.
  107012. */
  107013. url: string;
  107014. /**
  107015. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  107016. */
  107017. coordinatesMode: number;
  107018. protected _isBlocking: boolean;
  107019. /**
  107020. * Sets wether or not the texture is blocking during loading.
  107021. */
  107022. /**
  107023. * Gets wether or not the texture is blocking during loading.
  107024. */
  107025. isBlocking: boolean;
  107026. protected _rotationY: number;
  107027. /**
  107028. * Sets texture matrix rotation angle around Y axis in radians.
  107029. */
  107030. /**
  107031. * Gets texture matrix rotation angle around Y axis radians.
  107032. */
  107033. rotationY: number;
  107034. /**
  107035. * Gets or sets the center of the bounding box associated with the cube texture
  107036. * It must define where the camera used to render the texture was set
  107037. */
  107038. boundingBoxPosition: Vector3;
  107039. private _boundingBoxSize;
  107040. /**
  107041. * Gets or sets the size of the bounding box associated with the cube texture
  107042. * When defined, the cubemap will switch to local mode
  107043. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  107044. * @example https://www.babylonjs-playground.com/#RNASML
  107045. */
  107046. boundingBoxSize: Vector3;
  107047. /**
  107048. * Instantiates an HDRTexture from the following parameters.
  107049. *
  107050. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  107051. * @param scene The scene the texture will be used in
  107052. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  107053. * @param noMipmap Forces to not generate the mipmap if true
  107054. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  107055. * @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)
  107056. * @param reserved Reserved flag for internal use.
  107057. */
  107058. 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>);
  107059. /**
  107060. * Get the current class name of the texture useful for serialization or dynamic coding.
  107061. * @returns "HDRCubeTexture"
  107062. */
  107063. getClassName(): string;
  107064. /**
  107065. * Occurs when the file is raw .hdr file.
  107066. */
  107067. private loadTexture;
  107068. clone(): HDRCubeTexture;
  107069. delayLoad(): void;
  107070. /**
  107071. * Get the texture reflection matrix used to rotate/transform the reflection.
  107072. * @returns the reflection matrix
  107073. */
  107074. getReflectionTextureMatrix(): Matrix;
  107075. /**
  107076. * Set the texture reflection matrix used to rotate/transform the reflection.
  107077. * @param value Define the reflection matrix to set
  107078. */
  107079. setReflectionTextureMatrix(value: Matrix): void;
  107080. /**
  107081. * Parses a JSON representation of an HDR Texture in order to create the texture
  107082. * @param parsedTexture Define the JSON representation
  107083. * @param scene Define the scene the texture should be created in
  107084. * @param rootUrl Define the root url in case we need to load relative dependencies
  107085. * @returns the newly created texture after parsing
  107086. */
  107087. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  107088. serialize(): any;
  107089. }
  107090. }
  107091. declare module BABYLON {
  107092. /**
  107093. * Class used to control physics engine
  107094. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107095. */
  107096. export class PhysicsEngine implements IPhysicsEngine {
  107097. private _physicsPlugin;
  107098. /**
  107099. * Global value used to control the smallest number supported by the simulation
  107100. */
  107101. static Epsilon: number;
  107102. private _impostors;
  107103. private _joints;
  107104. /**
  107105. * Gets the gravity vector used by the simulation
  107106. */
  107107. gravity: Vector3;
  107108. /**
  107109. * Factory used to create the default physics plugin.
  107110. * @returns The default physics plugin
  107111. */
  107112. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  107113. /**
  107114. * Creates a new Physics Engine
  107115. * @param gravity defines the gravity vector used by the simulation
  107116. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  107117. */
  107118. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  107119. /**
  107120. * Sets the gravity vector used by the simulation
  107121. * @param gravity defines the gravity vector to use
  107122. */
  107123. setGravity(gravity: Vector3): void;
  107124. /**
  107125. * Set the time step of the physics engine.
  107126. * Default is 1/60.
  107127. * To slow it down, enter 1/600 for example.
  107128. * To speed it up, 1/30
  107129. * @param newTimeStep defines the new timestep to apply to this world.
  107130. */
  107131. setTimeStep(newTimeStep?: number): void;
  107132. /**
  107133. * Get the time step of the physics engine.
  107134. * @returns the current time step
  107135. */
  107136. getTimeStep(): number;
  107137. /**
  107138. * Release all resources
  107139. */
  107140. dispose(): void;
  107141. /**
  107142. * Gets the name of the current physics plugin
  107143. * @returns the name of the plugin
  107144. */
  107145. getPhysicsPluginName(): string;
  107146. /**
  107147. * Adding a new impostor for the impostor tracking.
  107148. * This will be done by the impostor itself.
  107149. * @param impostor the impostor to add
  107150. */
  107151. addImpostor(impostor: PhysicsImpostor): void;
  107152. /**
  107153. * Remove an impostor from the engine.
  107154. * This impostor and its mesh will not longer be updated by the physics engine.
  107155. * @param impostor the impostor to remove
  107156. */
  107157. removeImpostor(impostor: PhysicsImpostor): void;
  107158. /**
  107159. * Add a joint to the physics engine
  107160. * @param mainImpostor defines the main impostor to which the joint is added.
  107161. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107162. * @param joint defines the joint that will connect both impostors.
  107163. */
  107164. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107165. /**
  107166. * Removes a joint from the simulation
  107167. * @param mainImpostor defines the impostor used with the joint
  107168. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107169. * @param joint defines the joint to remove
  107170. */
  107171. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107172. /**
  107173. * Called by the scene. No need to call it.
  107174. * @param delta defines the timespam between frames
  107175. */
  107176. _step(delta: number): void;
  107177. /**
  107178. * Gets the current plugin used to run the simulation
  107179. * @returns current plugin
  107180. */
  107181. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107182. /**
  107183. * Gets the list of physic impostors
  107184. * @returns an array of PhysicsImpostor
  107185. */
  107186. getImpostors(): Array<PhysicsImpostor>;
  107187. /**
  107188. * Gets the impostor for a physics enabled object
  107189. * @param object defines the object impersonated by the impostor
  107190. * @returns the PhysicsImpostor or null if not found
  107191. */
  107192. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107193. /**
  107194. * Gets the impostor for a physics body object
  107195. * @param body defines physics body used by the impostor
  107196. * @returns the PhysicsImpostor or null if not found
  107197. */
  107198. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107199. /**
  107200. * Does a raycast in the physics world
  107201. * @param from when should the ray start?
  107202. * @param to when should the ray end?
  107203. * @returns PhysicsRaycastResult
  107204. */
  107205. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107206. }
  107207. }
  107208. declare module BABYLON {
  107209. /** @hidden */
  107210. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  107211. private _useDeltaForWorldStep;
  107212. world: any;
  107213. name: string;
  107214. private _physicsMaterials;
  107215. private _fixedTimeStep;
  107216. private _cannonRaycastResult;
  107217. private _raycastResult;
  107218. private _removeAfterStep;
  107219. BJSCANNON: any;
  107220. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  107221. setGravity(gravity: Vector3): void;
  107222. setTimeStep(timeStep: number): void;
  107223. getTimeStep(): number;
  107224. executeStep(delta: number): void;
  107225. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107226. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107227. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107228. private _processChildMeshes;
  107229. removePhysicsBody(impostor: PhysicsImpostor): void;
  107230. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107231. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107232. private _addMaterial;
  107233. private _checkWithEpsilon;
  107234. private _createShape;
  107235. private _createHeightmap;
  107236. private _minus90X;
  107237. private _plus90X;
  107238. private _tmpPosition;
  107239. private _tmpDeltaPosition;
  107240. private _tmpUnityRotation;
  107241. private _updatePhysicsBodyTransformation;
  107242. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107243. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107244. isSupported(): boolean;
  107245. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107246. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107247. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107248. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107249. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107250. getBodyMass(impostor: PhysicsImpostor): number;
  107251. getBodyFriction(impostor: PhysicsImpostor): number;
  107252. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107253. getBodyRestitution(impostor: PhysicsImpostor): number;
  107254. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107255. sleepBody(impostor: PhysicsImpostor): void;
  107256. wakeUpBody(impostor: PhysicsImpostor): void;
  107257. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  107258. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107259. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107260. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107261. getRadius(impostor: PhysicsImpostor): number;
  107262. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107263. dispose(): void;
  107264. private _extendNamespace;
  107265. /**
  107266. * Does a raycast in the physics world
  107267. * @param from when should the ray start?
  107268. * @param to when should the ray end?
  107269. * @returns PhysicsRaycastResult
  107270. */
  107271. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107272. }
  107273. }
  107274. declare module BABYLON {
  107275. /** @hidden */
  107276. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  107277. world: any;
  107278. name: string;
  107279. BJSOIMO: any;
  107280. private _raycastResult;
  107281. constructor(iterations?: number, oimoInjection?: any);
  107282. setGravity(gravity: Vector3): void;
  107283. setTimeStep(timeStep: number): void;
  107284. getTimeStep(): number;
  107285. private _tmpImpostorsArray;
  107286. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107287. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107288. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107289. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107290. private _tmpPositionVector;
  107291. removePhysicsBody(impostor: PhysicsImpostor): void;
  107292. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107293. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107294. isSupported(): boolean;
  107295. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107296. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107297. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107298. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107299. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107300. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107301. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107302. getBodyMass(impostor: PhysicsImpostor): number;
  107303. getBodyFriction(impostor: PhysicsImpostor): number;
  107304. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107305. getBodyRestitution(impostor: PhysicsImpostor): number;
  107306. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107307. sleepBody(impostor: PhysicsImpostor): void;
  107308. wakeUpBody(impostor: PhysicsImpostor): void;
  107309. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107310. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  107311. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107312. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107313. getRadius(impostor: PhysicsImpostor): number;
  107314. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107315. dispose(): void;
  107316. /**
  107317. * Does a raycast in the physics world
  107318. * @param from when should the ray start?
  107319. * @param to when should the ray end?
  107320. * @returns PhysicsRaycastResult
  107321. */
  107322. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107323. }
  107324. }
  107325. declare module BABYLON {
  107326. /**
  107327. * Class containing static functions to help procedurally build meshes
  107328. */
  107329. export class RibbonBuilder {
  107330. /**
  107331. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107332. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107333. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107334. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107335. * * 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
  107336. * * 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
  107337. * * 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
  107338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107339. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107340. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107341. * * 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
  107342. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107343. * * 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
  107344. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107346. * @param name defines the name of the mesh
  107347. * @param options defines the options used to create the mesh
  107348. * @param scene defines the hosting scene
  107349. * @returns the ribbon mesh
  107350. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107351. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107352. */
  107353. static CreateRibbon(name: string, options: {
  107354. pathArray: Vector3[][];
  107355. closeArray?: boolean;
  107356. closePath?: boolean;
  107357. offset?: number;
  107358. updatable?: boolean;
  107359. sideOrientation?: number;
  107360. frontUVs?: Vector4;
  107361. backUVs?: Vector4;
  107362. instance?: Mesh;
  107363. invertUV?: boolean;
  107364. uvs?: Vector2[];
  107365. colors?: Color4[];
  107366. }, scene?: Nullable<Scene>): Mesh;
  107367. }
  107368. }
  107369. declare module BABYLON {
  107370. /**
  107371. * Class containing static functions to help procedurally build meshes
  107372. */
  107373. export class ShapeBuilder {
  107374. /**
  107375. * 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.
  107376. * * 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.
  107377. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107378. * * 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.
  107379. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107380. * * 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
  107381. * * 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
  107382. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107385. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107387. * @param name defines the name of the mesh
  107388. * @param options defines the options used to create the mesh
  107389. * @param scene defines the hosting scene
  107390. * @returns the extruded shape mesh
  107391. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107393. */
  107394. static ExtrudeShape(name: string, options: {
  107395. shape: Vector3[];
  107396. path: Vector3[];
  107397. scale?: number;
  107398. rotation?: number;
  107399. cap?: number;
  107400. updatable?: boolean;
  107401. sideOrientation?: number;
  107402. frontUVs?: Vector4;
  107403. backUVs?: Vector4;
  107404. instance?: Mesh;
  107405. invertUV?: boolean;
  107406. }, scene?: Nullable<Scene>): Mesh;
  107407. /**
  107408. * Creates an custom extruded shape mesh.
  107409. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107410. * * 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.
  107411. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107412. * * 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
  107413. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107414. * * 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
  107415. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107416. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107417. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107418. * * 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
  107419. * * 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
  107420. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107423. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107425. * @param name defines the name of the mesh
  107426. * @param options defines the options used to create the mesh
  107427. * @param scene defines the hosting scene
  107428. * @returns the custom extruded shape mesh
  107429. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107430. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107431. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107432. */
  107433. static ExtrudeShapeCustom(name: string, options: {
  107434. shape: Vector3[];
  107435. path: Vector3[];
  107436. scaleFunction?: any;
  107437. rotationFunction?: any;
  107438. ribbonCloseArray?: boolean;
  107439. ribbonClosePath?: boolean;
  107440. cap?: number;
  107441. updatable?: boolean;
  107442. sideOrientation?: number;
  107443. frontUVs?: Vector4;
  107444. backUVs?: Vector4;
  107445. instance?: Mesh;
  107446. invertUV?: boolean;
  107447. }, scene?: Nullable<Scene>): Mesh;
  107448. private static _ExtrudeShapeGeneric;
  107449. }
  107450. }
  107451. declare module BABYLON {
  107452. /**
  107453. * AmmoJS Physics plugin
  107454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107455. * @see https://github.com/kripken/ammo.js/
  107456. */
  107457. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107458. private _useDeltaForWorldStep;
  107459. /**
  107460. * Reference to the Ammo library
  107461. */
  107462. bjsAMMO: any;
  107463. /**
  107464. * Created ammoJS world which physics bodies are added to
  107465. */
  107466. world: any;
  107467. /**
  107468. * Name of the plugin
  107469. */
  107470. name: string;
  107471. private _timeStep;
  107472. private _fixedTimeStep;
  107473. private _maxSteps;
  107474. private _tmpQuaternion;
  107475. private _tmpAmmoTransform;
  107476. private _tmpAmmoQuaternion;
  107477. private _tmpAmmoConcreteContactResultCallback;
  107478. private _collisionConfiguration;
  107479. private _dispatcher;
  107480. private _overlappingPairCache;
  107481. private _solver;
  107482. private _softBodySolver;
  107483. private _tmpAmmoVectorA;
  107484. private _tmpAmmoVectorB;
  107485. private _tmpAmmoVectorC;
  107486. private _tmpAmmoVectorD;
  107487. private _tmpContactCallbackResult;
  107488. private _tmpAmmoVectorRCA;
  107489. private _tmpAmmoVectorRCB;
  107490. private _raycastResult;
  107491. private static readonly DISABLE_COLLISION_FLAG;
  107492. private static readonly KINEMATIC_FLAG;
  107493. private static readonly DISABLE_DEACTIVATION_FLAG;
  107494. /**
  107495. * Initializes the ammoJS plugin
  107496. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107497. * @param ammoInjection can be used to inject your own ammo reference
  107498. */
  107499. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107500. /**
  107501. * Sets the gravity of the physics world (m/(s^2))
  107502. * @param gravity Gravity to set
  107503. */
  107504. setGravity(gravity: Vector3): void;
  107505. /**
  107506. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107507. * @param timeStep timestep to use in seconds
  107508. */
  107509. setTimeStep(timeStep: number): void;
  107510. /**
  107511. * 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)
  107512. * @param fixedTimeStep fixedTimeStep to use in seconds
  107513. */
  107514. setFixedTimeStep(fixedTimeStep: number): void;
  107515. /**
  107516. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107517. * @param maxSteps the maximum number of steps by the physics engine per frame
  107518. */
  107519. setMaxSteps(maxSteps: number): void;
  107520. /**
  107521. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107522. * @returns the current timestep in seconds
  107523. */
  107524. getTimeStep(): number;
  107525. private _isImpostorInContact;
  107526. private _isImpostorPairInContact;
  107527. private _stepSimulation;
  107528. /**
  107529. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107530. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107531. * After the step the babylon meshes are set to the position of the physics imposters
  107532. * @param delta amount of time to step forward
  107533. * @param impostors array of imposters to update before/after the step
  107534. */
  107535. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107536. /**
  107537. * Update babylon mesh to match physics world object
  107538. * @param impostor imposter to match
  107539. */
  107540. private _afterSoftStep;
  107541. /**
  107542. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107543. * @param impostor imposter to match
  107544. */
  107545. private _ropeStep;
  107546. /**
  107547. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107548. * @param impostor imposter to match
  107549. */
  107550. private _softbodyOrClothStep;
  107551. private _tmpVector;
  107552. private _tmpMatrix;
  107553. /**
  107554. * Applies an impulse on the imposter
  107555. * @param impostor imposter to apply impulse to
  107556. * @param force amount of force to be applied to the imposter
  107557. * @param contactPoint the location to apply the impulse on the imposter
  107558. */
  107559. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107560. /**
  107561. * Applies a force on the imposter
  107562. * @param impostor imposter to apply force
  107563. * @param force amount of force to be applied to the imposter
  107564. * @param contactPoint the location to apply the force on the imposter
  107565. */
  107566. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107567. /**
  107568. * Creates a physics body using the plugin
  107569. * @param impostor the imposter to create the physics body on
  107570. */
  107571. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107572. /**
  107573. * Removes the physics body from the imposter and disposes of the body's memory
  107574. * @param impostor imposter to remove the physics body from
  107575. */
  107576. removePhysicsBody(impostor: PhysicsImpostor): void;
  107577. /**
  107578. * Generates a joint
  107579. * @param impostorJoint the imposter joint to create the joint with
  107580. */
  107581. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107582. /**
  107583. * Removes a joint
  107584. * @param impostorJoint the imposter joint to remove the joint from
  107585. */
  107586. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107587. private _addMeshVerts;
  107588. /**
  107589. * Initialise the soft body vertices to match its object's (mesh) vertices
  107590. * Softbody vertices (nodes) are in world space and to match this
  107591. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  107592. * @param impostor to create the softbody for
  107593. */
  107594. private _softVertexData;
  107595. /**
  107596. * Create an impostor's soft body
  107597. * @param impostor to create the softbody for
  107598. */
  107599. private _createSoftbody;
  107600. /**
  107601. * Create cloth for an impostor
  107602. * @param impostor to create the softbody for
  107603. */
  107604. private _createCloth;
  107605. /**
  107606. * Create rope for an impostor
  107607. * @param impostor to create the softbody for
  107608. */
  107609. private _createRope;
  107610. private _addHullVerts;
  107611. private _createShape;
  107612. /**
  107613. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107614. * @param impostor imposter containing the physics body and babylon object
  107615. */
  107616. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107617. /**
  107618. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107619. * @param impostor imposter containing the physics body and babylon object
  107620. * @param newPosition new position
  107621. * @param newRotation new rotation
  107622. */
  107623. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107624. /**
  107625. * If this plugin is supported
  107626. * @returns true if its supported
  107627. */
  107628. isSupported(): boolean;
  107629. /**
  107630. * Sets the linear velocity of the physics body
  107631. * @param impostor imposter to set the velocity on
  107632. * @param velocity velocity to set
  107633. */
  107634. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107635. /**
  107636. * Sets the angular velocity of the physics body
  107637. * @param impostor imposter to set the velocity on
  107638. * @param velocity velocity to set
  107639. */
  107640. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107641. /**
  107642. * gets the linear velocity
  107643. * @param impostor imposter to get linear velocity from
  107644. * @returns linear velocity
  107645. */
  107646. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107647. /**
  107648. * gets the angular velocity
  107649. * @param impostor imposter to get angular velocity from
  107650. * @returns angular velocity
  107651. */
  107652. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107653. /**
  107654. * Sets the mass of physics body
  107655. * @param impostor imposter to set the mass on
  107656. * @param mass mass to set
  107657. */
  107658. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107659. /**
  107660. * Gets the mass of the physics body
  107661. * @param impostor imposter to get the mass from
  107662. * @returns mass
  107663. */
  107664. getBodyMass(impostor: PhysicsImpostor): number;
  107665. /**
  107666. * Gets friction of the impostor
  107667. * @param impostor impostor to get friction from
  107668. * @returns friction value
  107669. */
  107670. getBodyFriction(impostor: PhysicsImpostor): number;
  107671. /**
  107672. * Sets friction of the impostor
  107673. * @param impostor impostor to set friction on
  107674. * @param friction friction value
  107675. */
  107676. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107677. /**
  107678. * Gets restitution of the impostor
  107679. * @param impostor impostor to get restitution from
  107680. * @returns restitution value
  107681. */
  107682. getBodyRestitution(impostor: PhysicsImpostor): number;
  107683. /**
  107684. * Sets resitution of the impostor
  107685. * @param impostor impostor to set resitution on
  107686. * @param restitution resitution value
  107687. */
  107688. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107689. /**
  107690. * Gets pressure inside the impostor
  107691. * @param impostor impostor to get pressure from
  107692. * @returns pressure value
  107693. */
  107694. getBodyPressure(impostor: PhysicsImpostor): number;
  107695. /**
  107696. * Sets pressure inside a soft body impostor
  107697. * Cloth and rope must remain 0 pressure
  107698. * @param impostor impostor to set pressure on
  107699. * @param pressure pressure value
  107700. */
  107701. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  107702. /**
  107703. * Gets stiffness of the impostor
  107704. * @param impostor impostor to get stiffness from
  107705. * @returns pressure value
  107706. */
  107707. getBodyStiffness(impostor: PhysicsImpostor): number;
  107708. /**
  107709. * Sets stiffness of the impostor
  107710. * @param impostor impostor to set stiffness on
  107711. * @param stiffness stiffness value from 0 to 1
  107712. */
  107713. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  107714. /**
  107715. * Gets velocityIterations of the impostor
  107716. * @param impostor impostor to get velocity iterations from
  107717. * @returns velocityIterations value
  107718. */
  107719. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  107720. /**
  107721. * Sets velocityIterations of the impostor
  107722. * @param impostor impostor to set velocity iterations on
  107723. * @param velocityIterations velocityIterations value
  107724. */
  107725. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  107726. /**
  107727. * Gets positionIterations of the impostor
  107728. * @param impostor impostor to get position iterations from
  107729. * @returns positionIterations value
  107730. */
  107731. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  107732. /**
  107733. * Sets positionIterations of the impostor
  107734. * @param impostor impostor to set position on
  107735. * @param positionIterations positionIterations value
  107736. */
  107737. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  107738. /**
  107739. * Append an anchor to a cloth object
  107740. * @param impostor is the cloth impostor to add anchor to
  107741. * @param otherImpostor is the rigid impostor to anchor to
  107742. * @param width ratio across width from 0 to 1
  107743. * @param height ratio up height from 0 to 1
  107744. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107745. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107746. */
  107747. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107748. /**
  107749. * Append an hook to a rope object
  107750. * @param impostor is the rope impostor to add hook to
  107751. * @param otherImpostor is the rigid impostor to hook to
  107752. * @param length ratio along the rope from 0 to 1
  107753. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  107754. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107755. */
  107756. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107757. /**
  107758. * Sleeps the physics body and stops it from being active
  107759. * @param impostor impostor to sleep
  107760. */
  107761. sleepBody(impostor: PhysicsImpostor): void;
  107762. /**
  107763. * Activates the physics body
  107764. * @param impostor impostor to activate
  107765. */
  107766. wakeUpBody(impostor: PhysicsImpostor): void;
  107767. /**
  107768. * Updates the distance parameters of the joint
  107769. * @param joint joint to update
  107770. * @param maxDistance maximum distance of the joint
  107771. * @param minDistance minimum distance of the joint
  107772. */
  107773. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107774. /**
  107775. * Sets a motor on the joint
  107776. * @param joint joint to set motor on
  107777. * @param speed speed of the motor
  107778. * @param maxForce maximum force of the motor
  107779. * @param motorIndex index of the motor
  107780. */
  107781. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107782. /**
  107783. * Sets the motors limit
  107784. * @param joint joint to set limit on
  107785. * @param upperLimit upper limit
  107786. * @param lowerLimit lower limit
  107787. */
  107788. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107789. /**
  107790. * Syncs the position and rotation of a mesh with the impostor
  107791. * @param mesh mesh to sync
  107792. * @param impostor impostor to update the mesh with
  107793. */
  107794. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107795. /**
  107796. * Gets the radius of the impostor
  107797. * @param impostor impostor to get radius from
  107798. * @returns the radius
  107799. */
  107800. getRadius(impostor: PhysicsImpostor): number;
  107801. /**
  107802. * Gets the box size of the impostor
  107803. * @param impostor impostor to get box size from
  107804. * @param result the resulting box size
  107805. */
  107806. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107807. /**
  107808. * Disposes of the impostor
  107809. */
  107810. dispose(): void;
  107811. /**
  107812. * Does a raycast in the physics world
  107813. * @param from when should the ray start?
  107814. * @param to when should the ray end?
  107815. * @returns PhysicsRaycastResult
  107816. */
  107817. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107818. }
  107819. }
  107820. declare module BABYLON {
  107821. interface AbstractScene {
  107822. /**
  107823. * The list of reflection probes added to the scene
  107824. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107825. */
  107826. reflectionProbes: Array<ReflectionProbe>;
  107827. /**
  107828. * Removes the given reflection probe from this scene.
  107829. * @param toRemove The reflection probe to remove
  107830. * @returns The index of the removed reflection probe
  107831. */
  107832. removeReflectionProbe(toRemove: ReflectionProbe): number;
  107833. /**
  107834. * Adds the given reflection probe to this scene.
  107835. * @param newReflectionProbe The reflection probe to add
  107836. */
  107837. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  107838. }
  107839. /**
  107840. * Class used to generate realtime reflection / refraction cube textures
  107841. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107842. */
  107843. export class ReflectionProbe {
  107844. /** defines the name of the probe */
  107845. name: string;
  107846. private _scene;
  107847. private _renderTargetTexture;
  107848. private _projectionMatrix;
  107849. private _viewMatrix;
  107850. private _target;
  107851. private _add;
  107852. private _attachedMesh;
  107853. private _invertYAxis;
  107854. /** Gets or sets probe position (center of the cube map) */
  107855. position: Vector3;
  107856. /**
  107857. * Creates a new reflection probe
  107858. * @param name defines the name of the probe
  107859. * @param size defines the texture resolution (for each face)
  107860. * @param scene defines the hosting scene
  107861. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  107862. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  107863. */
  107864. constructor(
  107865. /** defines the name of the probe */
  107866. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  107867. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  107868. samples: number;
  107869. /** Gets or sets the refresh rate to use (on every frame by default) */
  107870. refreshRate: number;
  107871. /**
  107872. * Gets the hosting scene
  107873. * @returns a Scene
  107874. */
  107875. getScene(): Scene;
  107876. /** Gets the internal CubeTexture used to render to */
  107877. readonly cubeTexture: RenderTargetTexture;
  107878. /** Gets the list of meshes to render */
  107879. readonly renderList: Nullable<AbstractMesh[]>;
  107880. /**
  107881. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  107882. * @param mesh defines the mesh to attach to
  107883. */
  107884. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  107885. /**
  107886. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  107887. * @param renderingGroupId The rendering group id corresponding to its index
  107888. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  107889. */
  107890. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  107891. /**
  107892. * Clean all associated resources
  107893. */
  107894. dispose(): void;
  107895. /**
  107896. * Converts the reflection probe information to a readable string for debug purpose.
  107897. * @param fullDetails Supports for multiple levels of logging within scene loading
  107898. * @returns the human readable reflection probe info
  107899. */
  107900. toString(fullDetails?: boolean): string;
  107901. /**
  107902. * Get the class name of the relfection probe.
  107903. * @returns "ReflectionProbe"
  107904. */
  107905. getClassName(): string;
  107906. /**
  107907. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  107908. * @returns The JSON representation of the texture
  107909. */
  107910. serialize(): any;
  107911. /**
  107912. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  107913. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  107914. * @param scene Define the scene the parsed reflection probe should be instantiated in
  107915. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  107916. * @returns The parsed reflection probe if successful
  107917. */
  107918. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  107919. }
  107920. }
  107921. declare module BABYLON {
  107922. /** @hidden */
  107923. export var _BabylonLoaderRegistered: boolean;
  107924. }
  107925. declare module BABYLON {
  107926. /**
  107927. * The Physically based simple base material of BJS.
  107928. *
  107929. * This enables better naming and convention enforcements on top of the pbrMaterial.
  107930. * It is used as the base class for both the specGloss and metalRough conventions.
  107931. */
  107932. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  107933. /**
  107934. * Number of Simultaneous lights allowed on the material.
  107935. */
  107936. maxSimultaneousLights: number;
  107937. /**
  107938. * If sets to true, disables all the lights affecting the material.
  107939. */
  107940. disableLighting: boolean;
  107941. /**
  107942. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  107943. */
  107944. environmentTexture: BaseTexture;
  107945. /**
  107946. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107947. */
  107948. invertNormalMapX: boolean;
  107949. /**
  107950. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107951. */
  107952. invertNormalMapY: boolean;
  107953. /**
  107954. * Normal map used in the model.
  107955. */
  107956. normalTexture: BaseTexture;
  107957. /**
  107958. * Emissivie color used to self-illuminate the model.
  107959. */
  107960. emissiveColor: Color3;
  107961. /**
  107962. * Emissivie texture used to self-illuminate the model.
  107963. */
  107964. emissiveTexture: BaseTexture;
  107965. /**
  107966. * Occlusion Channel Strenght.
  107967. */
  107968. occlusionStrength: number;
  107969. /**
  107970. * Occlusion Texture of the material (adding extra occlusion effects).
  107971. */
  107972. occlusionTexture: BaseTexture;
  107973. /**
  107974. * Defines the alpha limits in alpha test mode.
  107975. */
  107976. alphaCutOff: number;
  107977. /**
  107978. * Gets the current double sided mode.
  107979. */
  107980. /**
  107981. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107982. */
  107983. doubleSided: boolean;
  107984. /**
  107985. * Stores the pre-calculated light information of a mesh in a texture.
  107986. */
  107987. lightmapTexture: BaseTexture;
  107988. /**
  107989. * If true, the light map contains occlusion information instead of lighting info.
  107990. */
  107991. useLightmapAsShadowmap: boolean;
  107992. /**
  107993. * Instantiates a new PBRMaterial instance.
  107994. *
  107995. * @param name The material name
  107996. * @param scene The scene the material will be use in.
  107997. */
  107998. constructor(name: string, scene: Scene);
  107999. getClassName(): string;
  108000. }
  108001. }
  108002. declare module BABYLON {
  108003. /**
  108004. * The PBR material of BJS following the metal roughness convention.
  108005. *
  108006. * This fits to the PBR convention in the GLTF definition:
  108007. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  108008. */
  108009. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  108010. /**
  108011. * The base color has two different interpretations depending on the value of metalness.
  108012. * When the material is a metal, the base color is the specific measured reflectance value
  108013. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  108014. * of the material.
  108015. */
  108016. baseColor: Color3;
  108017. /**
  108018. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  108019. * well as opacity information in the alpha channel.
  108020. */
  108021. baseTexture: BaseTexture;
  108022. /**
  108023. * Specifies the metallic scalar value of the material.
  108024. * Can also be used to scale the metalness values of the metallic texture.
  108025. */
  108026. metallic: number;
  108027. /**
  108028. * Specifies the roughness scalar value of the material.
  108029. * Can also be used to scale the roughness values of the metallic texture.
  108030. */
  108031. roughness: number;
  108032. /**
  108033. * Texture containing both the metallic value in the B channel and the
  108034. * roughness value in the G channel to keep better precision.
  108035. */
  108036. metallicRoughnessTexture: BaseTexture;
  108037. /**
  108038. * Instantiates a new PBRMetalRoughnessMaterial instance.
  108039. *
  108040. * @param name The material name
  108041. * @param scene The scene the material will be use in.
  108042. */
  108043. constructor(name: string, scene: Scene);
  108044. /**
  108045. * Return the currrent class name of the material.
  108046. */
  108047. getClassName(): string;
  108048. /**
  108049. * Makes a duplicate of the current material.
  108050. * @param name - name to use for the new material.
  108051. */
  108052. clone(name: string): PBRMetallicRoughnessMaterial;
  108053. /**
  108054. * Serialize the material to a parsable JSON object.
  108055. */
  108056. serialize(): any;
  108057. /**
  108058. * Parses a JSON object correponding to the serialize function.
  108059. */
  108060. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  108061. }
  108062. }
  108063. declare module BABYLON {
  108064. /**
  108065. * The PBR material of BJS following the specular glossiness convention.
  108066. *
  108067. * This fits to the PBR convention in the GLTF definition:
  108068. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  108069. */
  108070. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  108071. /**
  108072. * Specifies the diffuse color of the material.
  108073. */
  108074. diffuseColor: Color3;
  108075. /**
  108076. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  108077. * channel.
  108078. */
  108079. diffuseTexture: BaseTexture;
  108080. /**
  108081. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  108082. */
  108083. specularColor: Color3;
  108084. /**
  108085. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  108086. */
  108087. glossiness: number;
  108088. /**
  108089. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  108090. */
  108091. specularGlossinessTexture: BaseTexture;
  108092. /**
  108093. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  108094. *
  108095. * @param name The material name
  108096. * @param scene The scene the material will be use in.
  108097. */
  108098. constructor(name: string, scene: Scene);
  108099. /**
  108100. * Return the currrent class name of the material.
  108101. */
  108102. getClassName(): string;
  108103. /**
  108104. * Makes a duplicate of the current material.
  108105. * @param name - name to use for the new material.
  108106. */
  108107. clone(name: string): PBRSpecularGlossinessMaterial;
  108108. /**
  108109. * Serialize the material to a parsable JSON object.
  108110. */
  108111. serialize(): any;
  108112. /**
  108113. * Parses a JSON object correponding to the serialize function.
  108114. */
  108115. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  108116. }
  108117. }
  108118. declare module BABYLON {
  108119. /**
  108120. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  108121. * It can help converting any input color in a desired output one. This can then be used to create effects
  108122. * from sepia, black and white to sixties or futuristic rendering...
  108123. *
  108124. * The only supported format is currently 3dl.
  108125. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  108126. */
  108127. export class ColorGradingTexture extends BaseTexture {
  108128. /**
  108129. * The current texture matrix. (will always be identity in color grading texture)
  108130. */
  108131. private _textureMatrix;
  108132. /**
  108133. * The texture URL.
  108134. */
  108135. url: string;
  108136. /**
  108137. * Empty line regex stored for GC.
  108138. */
  108139. private static _noneEmptyLineRegex;
  108140. private _engine;
  108141. /**
  108142. * Instantiates a ColorGradingTexture from the following parameters.
  108143. *
  108144. * @param url The location of the color gradind data (currently only supporting 3dl)
  108145. * @param scene The scene the texture will be used in
  108146. */
  108147. constructor(url: string, scene: Scene);
  108148. /**
  108149. * Returns the texture matrix used in most of the material.
  108150. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  108151. */
  108152. getTextureMatrix(): Matrix;
  108153. /**
  108154. * Occurs when the file being loaded is a .3dl LUT file.
  108155. */
  108156. private load3dlTexture;
  108157. /**
  108158. * Starts the loading process of the texture.
  108159. */
  108160. private loadTexture;
  108161. /**
  108162. * Clones the color gradind texture.
  108163. */
  108164. clone(): ColorGradingTexture;
  108165. /**
  108166. * Called during delayed load for textures.
  108167. */
  108168. delayLoad(): void;
  108169. /**
  108170. * Parses a color grading texture serialized by Babylon.
  108171. * @param parsedTexture The texture information being parsedTexture
  108172. * @param scene The scene to load the texture in
  108173. * @param rootUrl The root url of the data assets to load
  108174. * @return A color gradind texture
  108175. */
  108176. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  108177. /**
  108178. * Serializes the LUT texture to json format.
  108179. */
  108180. serialize(): any;
  108181. }
  108182. }
  108183. declare module BABYLON {
  108184. /**
  108185. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  108186. */
  108187. export class EquiRectangularCubeTexture extends BaseTexture {
  108188. /** The six faces of the cube. */
  108189. private static _FacesMapping;
  108190. private _noMipmap;
  108191. private _onLoad;
  108192. private _onError;
  108193. /** The size of the cubemap. */
  108194. private _size;
  108195. /** The buffer of the image. */
  108196. private _buffer;
  108197. /** The width of the input image. */
  108198. private _width;
  108199. /** The height of the input image. */
  108200. private _height;
  108201. /** The URL to the image. */
  108202. url: string;
  108203. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  108204. coordinatesMode: number;
  108205. /**
  108206. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  108207. * @param url The location of the image
  108208. * @param scene The scene the texture will be used in
  108209. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108210. * @param noMipmap Forces to not generate the mipmap if true
  108211. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  108212. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  108213. * @param onLoad — defines a callback called when texture is loaded
  108214. * @param onError — defines a callback called if there is an error
  108215. */
  108216. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  108217. /**
  108218. * Load the image data, by putting the image on a canvas and extracting its buffer.
  108219. */
  108220. private loadImage;
  108221. /**
  108222. * Convert the image buffer into a cubemap and create a CubeTexture.
  108223. */
  108224. private loadTexture;
  108225. /**
  108226. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  108227. * @param buffer The ArrayBuffer that should be converted.
  108228. * @returns The buffer as Float32Array.
  108229. */
  108230. private getFloat32ArrayFromArrayBuffer;
  108231. /**
  108232. * Get the current class name of the texture useful for serialization or dynamic coding.
  108233. * @returns "EquiRectangularCubeTexture"
  108234. */
  108235. getClassName(): string;
  108236. /**
  108237. * Create a clone of the current EquiRectangularCubeTexture and return it.
  108238. * @returns A clone of the current EquiRectangularCubeTexture.
  108239. */
  108240. clone(): EquiRectangularCubeTexture;
  108241. }
  108242. }
  108243. declare module BABYLON {
  108244. /**
  108245. * Based on jsTGALoader - Javascript loader for TGA file
  108246. * By Vincent Thibault
  108247. * @see http://blog.robrowser.com/javascript-tga-loader.html
  108248. */
  108249. export class TGATools {
  108250. private static _TYPE_INDEXED;
  108251. private static _TYPE_RGB;
  108252. private static _TYPE_GREY;
  108253. private static _TYPE_RLE_INDEXED;
  108254. private static _TYPE_RLE_RGB;
  108255. private static _TYPE_RLE_GREY;
  108256. private static _ORIGIN_MASK;
  108257. private static _ORIGIN_SHIFT;
  108258. private static _ORIGIN_BL;
  108259. private static _ORIGIN_BR;
  108260. private static _ORIGIN_UL;
  108261. private static _ORIGIN_UR;
  108262. /**
  108263. * Gets the header of a TGA file
  108264. * @param data defines the TGA data
  108265. * @returns the header
  108266. */
  108267. static GetTGAHeader(data: Uint8Array): any;
  108268. /**
  108269. * Uploads TGA content to a Babylon Texture
  108270. * @hidden
  108271. */
  108272. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  108273. /** @hidden */
  108274. 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;
  108275. /** @hidden */
  108276. 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;
  108277. /** @hidden */
  108278. 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;
  108279. /** @hidden */
  108280. 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;
  108281. /** @hidden */
  108282. 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;
  108283. /** @hidden */
  108284. 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;
  108285. }
  108286. }
  108287. declare module BABYLON {
  108288. /**
  108289. * Implementation of the TGA Texture Loader.
  108290. * @hidden
  108291. */
  108292. export class _TGATextureLoader implements IInternalTextureLoader {
  108293. /**
  108294. * Defines wether the loader supports cascade loading the different faces.
  108295. */
  108296. readonly supportCascades: boolean;
  108297. /**
  108298. * This returns if the loader support the current file information.
  108299. * @param extension defines the file extension of the file being loaded
  108300. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108301. * @param fallback defines the fallback internal texture if any
  108302. * @param isBase64 defines whether the texture is encoded as a base64
  108303. * @param isBuffer defines whether the texture data are stored as a buffer
  108304. * @returns true if the loader can load the specified file
  108305. */
  108306. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108307. /**
  108308. * Transform the url before loading if required.
  108309. * @param rootUrl the url of the texture
  108310. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108311. * @returns the transformed texture
  108312. */
  108313. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108314. /**
  108315. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108316. * @param rootUrl the url of the texture
  108317. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108318. * @returns the fallback texture
  108319. */
  108320. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108321. /**
  108322. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108323. * @param data contains the texture data
  108324. * @param texture defines the BabylonJS internal texture
  108325. * @param createPolynomials will be true if polynomials have been requested
  108326. * @param onLoad defines the callback to trigger once the texture is ready
  108327. * @param onError defines the callback to trigger in case of error
  108328. */
  108329. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108330. /**
  108331. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108332. * @param data contains the texture data
  108333. * @param texture defines the BabylonJS internal texture
  108334. * @param callback defines the method to call once ready to upload
  108335. */
  108336. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108337. }
  108338. }
  108339. declare module BABYLON {
  108340. /**
  108341. * 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.
  108342. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108343. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108344. */
  108345. export class CustomProceduralTexture extends ProceduralTexture {
  108346. private _animate;
  108347. private _time;
  108348. private _config;
  108349. private _texturePath;
  108350. /**
  108351. * Instantiates a new Custom Procedural Texture.
  108352. * 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.
  108353. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108354. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108355. * @param name Define the name of the texture
  108356. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  108357. * @param size Define the size of the texture to create
  108358. * @param scene Define the scene the texture belongs to
  108359. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  108360. * @param generateMipMaps Define if the texture should creates mip maps or not
  108361. */
  108362. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108363. private _loadJson;
  108364. /**
  108365. * Is the texture ready to be used ? (rendered at least once)
  108366. * @returns true if ready, otherwise, false.
  108367. */
  108368. isReady(): boolean;
  108369. /**
  108370. * Render the texture to its associated render target.
  108371. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  108372. */
  108373. render(useCameraPostProcess?: boolean): void;
  108374. /**
  108375. * Update the list of dependant textures samplers in the shader.
  108376. */
  108377. updateTextures(): void;
  108378. /**
  108379. * Update the uniform values of the procedural texture in the shader.
  108380. */
  108381. updateShaderUniforms(): void;
  108382. /**
  108383. * Define if the texture animates or not.
  108384. */
  108385. animate: boolean;
  108386. }
  108387. }
  108388. declare module BABYLON {
  108389. /** @hidden */
  108390. export var noisePixelShader: {
  108391. name: string;
  108392. shader: string;
  108393. };
  108394. }
  108395. declare module BABYLON {
  108396. /**
  108397. * Class used to generate noise procedural textures
  108398. */
  108399. export class NoiseProceduralTexture extends ProceduralTexture {
  108400. private _time;
  108401. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  108402. brightness: number;
  108403. /** Defines the number of octaves to process */
  108404. octaves: number;
  108405. /** Defines the level of persistence (0.8 by default) */
  108406. persistence: number;
  108407. /** Gets or sets animation speed factor (default is 1) */
  108408. animationSpeedFactor: number;
  108409. /**
  108410. * Creates a new NoiseProceduralTexture
  108411. * @param name defines the name fo the texture
  108412. * @param size defines the size of the texture (default is 256)
  108413. * @param scene defines the hosting scene
  108414. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  108415. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  108416. */
  108417. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108418. private _updateShaderUniforms;
  108419. protected _getDefines(): string;
  108420. /** Generate the current state of the procedural texture */
  108421. render(useCameraPostProcess?: boolean): void;
  108422. /**
  108423. * Serializes this noise procedural texture
  108424. * @returns a serialized noise procedural texture object
  108425. */
  108426. serialize(): any;
  108427. /**
  108428. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  108429. * @param parsedTexture defines parsed texture data
  108430. * @param scene defines the current scene
  108431. * @param rootUrl defines the root URL containing noise procedural texture information
  108432. * @returns a parsed NoiseProceduralTexture
  108433. */
  108434. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  108435. }
  108436. }
  108437. declare module BABYLON {
  108438. /**
  108439. * Raw cube texture where the raw buffers are passed in
  108440. */
  108441. export class RawCubeTexture extends CubeTexture {
  108442. /**
  108443. * Creates a cube texture where the raw buffers are passed in.
  108444. * @param scene defines the scene the texture is attached to
  108445. * @param data defines the array of data to use to create each face
  108446. * @param size defines the size of the textures
  108447. * @param format defines the format of the data
  108448. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  108449. * @param generateMipMaps defines if the engine should generate the mip levels
  108450. * @param invertY defines if data must be stored with Y axis inverted
  108451. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  108452. * @param compression defines the compression used (null by default)
  108453. */
  108454. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  108455. /**
  108456. * Updates the raw cube texture.
  108457. * @param data defines the data to store
  108458. * @param format defines the data format
  108459. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  108460. * @param invertY defines if data must be stored with Y axis inverted
  108461. * @param compression defines the compression used (null by default)
  108462. * @param level defines which level of the texture to update
  108463. */
  108464. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  108465. /**
  108466. * Updates a raw cube texture with RGBD encoded data.
  108467. * @param data defines the array of data [mipmap][face] to use to create each face
  108468. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  108469. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  108470. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  108471. * @returns a promsie that resolves when the operation is complete
  108472. */
  108473. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  108474. /**
  108475. * Clones the raw cube texture.
  108476. * @return a new cube texture
  108477. */
  108478. clone(): CubeTexture;
  108479. /** @hidden */
  108480. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  108481. }
  108482. }
  108483. declare module BABYLON {
  108484. /**
  108485. * Class used to store 3D textures containing user data
  108486. */
  108487. export class RawTexture3D extends Texture {
  108488. /** Gets or sets the texture format to use */
  108489. format: number;
  108490. private _engine;
  108491. /**
  108492. * Create a new RawTexture3D
  108493. * @param data defines the data of the texture
  108494. * @param width defines the width of the texture
  108495. * @param height defines the height of the texture
  108496. * @param depth defines the depth of the texture
  108497. * @param format defines the texture format to use
  108498. * @param scene defines the hosting scene
  108499. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  108500. * @param invertY defines if texture must be stored with Y axis inverted
  108501. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108502. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  108503. */
  108504. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  108505. /** Gets or sets the texture format to use */
  108506. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  108507. /**
  108508. * Update the texture with new data
  108509. * @param data defines the data to store in the texture
  108510. */
  108511. update(data: ArrayBufferView): void;
  108512. }
  108513. }
  108514. declare module BABYLON {
  108515. /**
  108516. * Creates a refraction texture used by refraction channel of the standard material.
  108517. * It is like a mirror but to see through a material.
  108518. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108519. */
  108520. export class RefractionTexture extends RenderTargetTexture {
  108521. /**
  108522. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  108523. * 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.
  108524. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108525. */
  108526. refractionPlane: Plane;
  108527. /**
  108528. * Define how deep under the surface we should see.
  108529. */
  108530. depth: number;
  108531. /**
  108532. * Creates a refraction texture used by refraction channel of the standard material.
  108533. * It is like a mirror but to see through a material.
  108534. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108535. * @param name Define the texture name
  108536. * @param size Define the size of the underlying texture
  108537. * @param scene Define the scene the refraction belongs to
  108538. * @param generateMipMaps Define if we need to generate mips level for the refraction
  108539. */
  108540. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  108541. /**
  108542. * Clone the refraction texture.
  108543. * @returns the cloned texture
  108544. */
  108545. clone(): RefractionTexture;
  108546. /**
  108547. * Serialize the texture to a JSON representation you could use in Parse later on
  108548. * @returns the serialized JSON representation
  108549. */
  108550. serialize(): any;
  108551. }
  108552. }
  108553. declare module BABYLON {
  108554. /**
  108555. * Helper class to push actions to a pool of workers.
  108556. */
  108557. export class WorkerPool implements IDisposable {
  108558. private _workerInfos;
  108559. private _pendingActions;
  108560. /**
  108561. * Constructor
  108562. * @param workers Array of workers to use for actions
  108563. */
  108564. constructor(workers: Array<Worker>);
  108565. /**
  108566. * Terminates all workers and clears any pending actions.
  108567. */
  108568. dispose(): void;
  108569. /**
  108570. * Pushes an action to the worker pool. If all the workers are active, the action will be
  108571. * pended until a worker has completed its action.
  108572. * @param action The action to perform. Call onComplete when the action is complete.
  108573. */
  108574. push(action: (worker: Worker, onComplete: () => void) => void): void;
  108575. private _execute;
  108576. }
  108577. }
  108578. declare module BABYLON {
  108579. /**
  108580. * Configuration for Draco compression
  108581. */
  108582. export interface IDracoCompressionConfiguration {
  108583. /**
  108584. * Configuration for the decoder.
  108585. */
  108586. decoder?: {
  108587. /**
  108588. * The url to the WebAssembly module.
  108589. */
  108590. wasmUrl?: string;
  108591. /**
  108592. * The url to the WebAssembly binary.
  108593. */
  108594. wasmBinaryUrl?: string;
  108595. /**
  108596. * The url to the fallback JavaScript module.
  108597. */
  108598. fallbackUrl?: string;
  108599. };
  108600. }
  108601. /**
  108602. * Draco compression (https://google.github.io/draco/)
  108603. *
  108604. * This class wraps the Draco module.
  108605. *
  108606. * **Encoder**
  108607. *
  108608. * The encoder is not currently implemented.
  108609. *
  108610. * **Decoder**
  108611. *
  108612. * 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.
  108613. *
  108614. * To update the configuration, use the following code:
  108615. * ```javascript
  108616. * DracoCompression.Configuration = {
  108617. * decoder: {
  108618. * wasmUrl: "<url to the WebAssembly library>",
  108619. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  108620. * fallbackUrl: "<url to the fallback JavaScript library>",
  108621. * }
  108622. * };
  108623. * ```
  108624. *
  108625. * 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.
  108626. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  108627. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  108628. *
  108629. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  108630. * ```javascript
  108631. * var dracoCompression = new DracoCompression();
  108632. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  108633. * [VertexBuffer.PositionKind]: 0
  108634. * });
  108635. * ```
  108636. *
  108637. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  108638. */
  108639. export class DracoCompression implements IDisposable {
  108640. private _workerPoolPromise;
  108641. /**
  108642. * The configuration. Defaults to the following urls:
  108643. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  108644. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  108645. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  108646. */
  108647. static Configuration: IDracoCompressionConfiguration;
  108648. /**
  108649. * Returns true if the decoder is available.
  108650. */
  108651. static readonly DecoderAvailable: boolean;
  108652. /**
  108653. * Default number of workers to create when creating the draco compression object.
  108654. */
  108655. static DefaultNumWorkers: number;
  108656. private static GetDefaultNumWorkers;
  108657. /**
  108658. * Constructor
  108659. * @param numWorkers The number of workers for async operations
  108660. */
  108661. constructor(numWorkers?: number);
  108662. /**
  108663. * Stop all async operations and release resources.
  108664. */
  108665. dispose(): void;
  108666. /**
  108667. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  108668. * @returns a promise that resolves when ready
  108669. */
  108670. whenReadyAsync(): Promise<void>;
  108671. /**
  108672. * Decode Draco compressed mesh data to vertex data.
  108673. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  108674. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  108675. * @returns A promise that resolves with the decoded vertex data
  108676. */
  108677. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  108678. [kind: string]: number;
  108679. }): Promise<VertexData>;
  108680. /**
  108681. * The worker function that gets converted to a blob url to pass into a worker.
  108682. */
  108683. private static _Worker;
  108684. private _loadDecoderWasmBinaryAsync;
  108685. }
  108686. }
  108687. declare module BABYLON {
  108688. /**
  108689. * Class for building Constructive Solid Geometry
  108690. */
  108691. export class CSG {
  108692. private polygons;
  108693. /**
  108694. * The world matrix
  108695. */
  108696. matrix: Matrix;
  108697. /**
  108698. * Stores the position
  108699. */
  108700. position: Vector3;
  108701. /**
  108702. * Stores the rotation
  108703. */
  108704. rotation: Vector3;
  108705. /**
  108706. * Stores the rotation quaternion
  108707. */
  108708. rotationQuaternion: Nullable<Quaternion>;
  108709. /**
  108710. * Stores the scaling vector
  108711. */
  108712. scaling: Vector3;
  108713. /**
  108714. * Convert the Mesh to CSG
  108715. * @param mesh The Mesh to convert to CSG
  108716. * @returns A new CSG from the Mesh
  108717. */
  108718. static FromMesh(mesh: Mesh): CSG;
  108719. /**
  108720. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  108721. * @param polygons Polygons used to construct a CSG solid
  108722. */
  108723. private static FromPolygons;
  108724. /**
  108725. * Clones, or makes a deep copy, of the CSG
  108726. * @returns A new CSG
  108727. */
  108728. clone(): CSG;
  108729. /**
  108730. * Unions this CSG with another CSG
  108731. * @param csg The CSG to union against this CSG
  108732. * @returns The unioned CSG
  108733. */
  108734. union(csg: CSG): CSG;
  108735. /**
  108736. * Unions this CSG with another CSG in place
  108737. * @param csg The CSG to union against this CSG
  108738. */
  108739. unionInPlace(csg: CSG): void;
  108740. /**
  108741. * Subtracts this CSG with another CSG
  108742. * @param csg The CSG to subtract against this CSG
  108743. * @returns A new CSG
  108744. */
  108745. subtract(csg: CSG): CSG;
  108746. /**
  108747. * Subtracts this CSG with another CSG in place
  108748. * @param csg The CSG to subtact against this CSG
  108749. */
  108750. subtractInPlace(csg: CSG): void;
  108751. /**
  108752. * Intersect this CSG with another CSG
  108753. * @param csg The CSG to intersect against this CSG
  108754. * @returns A new CSG
  108755. */
  108756. intersect(csg: CSG): CSG;
  108757. /**
  108758. * Intersects this CSG with another CSG in place
  108759. * @param csg The CSG to intersect against this CSG
  108760. */
  108761. intersectInPlace(csg: CSG): void;
  108762. /**
  108763. * Return a new CSG solid with solid and empty space switched. This solid is
  108764. * not modified.
  108765. * @returns A new CSG solid with solid and empty space switched
  108766. */
  108767. inverse(): CSG;
  108768. /**
  108769. * Inverses the CSG in place
  108770. */
  108771. inverseInPlace(): void;
  108772. /**
  108773. * This is used to keep meshes transformations so they can be restored
  108774. * when we build back a Babylon Mesh
  108775. * NB : All CSG operations are performed in world coordinates
  108776. * @param csg The CSG to copy the transform attributes from
  108777. * @returns This CSG
  108778. */
  108779. copyTransformAttributes(csg: CSG): CSG;
  108780. /**
  108781. * Build Raw mesh from CSG
  108782. * Coordinates here are in world space
  108783. * @param name The name of the mesh geometry
  108784. * @param scene The Scene
  108785. * @param keepSubMeshes Specifies if the submeshes should be kept
  108786. * @returns A new Mesh
  108787. */
  108788. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  108789. /**
  108790. * Build Mesh from CSG taking material and transforms into account
  108791. * @param name The name of the Mesh
  108792. * @param material The material of the Mesh
  108793. * @param scene The Scene
  108794. * @param keepSubMeshes Specifies if submeshes should be kept
  108795. * @returns The new Mesh
  108796. */
  108797. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  108798. }
  108799. }
  108800. declare module BABYLON {
  108801. /**
  108802. * Class used to create a trail following a mesh
  108803. */
  108804. export class TrailMesh extends Mesh {
  108805. private _generator;
  108806. private _autoStart;
  108807. private _running;
  108808. private _diameter;
  108809. private _length;
  108810. private _sectionPolygonPointsCount;
  108811. private _sectionVectors;
  108812. private _sectionNormalVectors;
  108813. private _beforeRenderObserver;
  108814. /**
  108815. * @constructor
  108816. * @param name The value used by scene.getMeshByName() to do a lookup.
  108817. * @param generator The mesh to generate a trail.
  108818. * @param scene The scene to add this mesh to.
  108819. * @param diameter Diameter of trailing mesh. Default is 1.
  108820. * @param length Length of trailing mesh. Default is 60.
  108821. * @param autoStart Automatically start trailing mesh. Default true.
  108822. */
  108823. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  108824. /**
  108825. * "TrailMesh"
  108826. * @returns "TrailMesh"
  108827. */
  108828. getClassName(): string;
  108829. private _createMesh;
  108830. /**
  108831. * Start trailing mesh.
  108832. */
  108833. start(): void;
  108834. /**
  108835. * Stop trailing mesh.
  108836. */
  108837. stop(): void;
  108838. /**
  108839. * Update trailing mesh geometry.
  108840. */
  108841. update(): void;
  108842. /**
  108843. * Returns a new TrailMesh object.
  108844. * @param name is a string, the name given to the new mesh
  108845. * @param newGenerator use new generator object for cloned trail mesh
  108846. * @returns a new mesh
  108847. */
  108848. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  108849. /**
  108850. * Serializes this trail mesh
  108851. * @param serializationObject object to write serialization to
  108852. */
  108853. serialize(serializationObject: any): void;
  108854. /**
  108855. * Parses a serialized trail mesh
  108856. * @param parsedMesh the serialized mesh
  108857. * @param scene the scene to create the trail mesh in
  108858. * @returns the created trail mesh
  108859. */
  108860. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  108861. }
  108862. }
  108863. declare module BABYLON {
  108864. /**
  108865. * Class containing static functions to help procedurally build meshes
  108866. */
  108867. export class TorusKnotBuilder {
  108868. /**
  108869. * Creates a torus knot mesh
  108870. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  108871. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  108872. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  108873. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  108874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108877. * @param name defines the name of the mesh
  108878. * @param options defines the options used to create the mesh
  108879. * @param scene defines the hosting scene
  108880. * @returns the torus knot mesh
  108881. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  108882. */
  108883. static CreateTorusKnot(name: string, options: {
  108884. radius?: number;
  108885. tube?: number;
  108886. radialSegments?: number;
  108887. tubularSegments?: number;
  108888. p?: number;
  108889. q?: number;
  108890. updatable?: boolean;
  108891. sideOrientation?: number;
  108892. frontUVs?: Vector4;
  108893. backUVs?: Vector4;
  108894. }, scene: any): Mesh;
  108895. }
  108896. }
  108897. declare module BABYLON {
  108898. /**
  108899. * Polygon
  108900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  108901. */
  108902. export class Polygon {
  108903. /**
  108904. * Creates a rectangle
  108905. * @param xmin bottom X coord
  108906. * @param ymin bottom Y coord
  108907. * @param xmax top X coord
  108908. * @param ymax top Y coord
  108909. * @returns points that make the resulting rectation
  108910. */
  108911. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  108912. /**
  108913. * Creates a circle
  108914. * @param radius radius of circle
  108915. * @param cx scale in x
  108916. * @param cy scale in y
  108917. * @param numberOfSides number of sides that make up the circle
  108918. * @returns points that make the resulting circle
  108919. */
  108920. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  108921. /**
  108922. * Creates a polygon from input string
  108923. * @param input Input polygon data
  108924. * @returns the parsed points
  108925. */
  108926. static Parse(input: string): Vector2[];
  108927. /**
  108928. * Starts building a polygon from x and y coordinates
  108929. * @param x x coordinate
  108930. * @param y y coordinate
  108931. * @returns the started path2
  108932. */
  108933. static StartingAt(x: number, y: number): Path2;
  108934. }
  108935. /**
  108936. * Builds a polygon
  108937. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  108938. */
  108939. export class PolygonMeshBuilder {
  108940. private _points;
  108941. private _outlinepoints;
  108942. private _holes;
  108943. private _name;
  108944. private _scene;
  108945. private _epoints;
  108946. private _eholes;
  108947. private _addToepoint;
  108948. /**
  108949. * Babylon reference to the earcut plugin.
  108950. */
  108951. bjsEarcut: any;
  108952. /**
  108953. * Creates a PolygonMeshBuilder
  108954. * @param name name of the builder
  108955. * @param contours Path of the polygon
  108956. * @param scene scene to add to when creating the mesh
  108957. * @param earcutInjection can be used to inject your own earcut reference
  108958. */
  108959. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  108960. /**
  108961. * Adds a whole within the polygon
  108962. * @param hole Array of points defining the hole
  108963. * @returns this
  108964. */
  108965. addHole(hole: Vector2[]): PolygonMeshBuilder;
  108966. /**
  108967. * Creates the polygon
  108968. * @param updatable If the mesh should be updatable
  108969. * @param depth The depth of the mesh created
  108970. * @returns the created mesh
  108971. */
  108972. build(updatable?: boolean, depth?: number): Mesh;
  108973. /**
  108974. * Creates the polygon
  108975. * @param depth The depth of the mesh created
  108976. * @returns the created VertexData
  108977. */
  108978. buildVertexData(depth?: number): VertexData;
  108979. /**
  108980. * Adds a side to the polygon
  108981. * @param positions points that make the polygon
  108982. * @param normals normals of the polygon
  108983. * @param uvs uvs of the polygon
  108984. * @param indices indices of the polygon
  108985. * @param bounds bounds of the polygon
  108986. * @param points points of the polygon
  108987. * @param depth depth of the polygon
  108988. * @param flip flip of the polygon
  108989. */
  108990. private addSide;
  108991. }
  108992. }
  108993. declare module BABYLON {
  108994. /**
  108995. * Class containing static functions to help procedurally build meshes
  108996. */
  108997. export class PolygonBuilder {
  108998. /**
  108999. * Creates a polygon mesh
  109000. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109001. * * 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
  109002. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109004. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109005. * * Remember you can only change the shape positions, not their number when updating a polygon
  109006. * @param name defines the name of the mesh
  109007. * @param options defines the options used to create the mesh
  109008. * @param scene defines the hosting scene
  109009. * @param earcutInjection can be used to inject your own earcut reference
  109010. * @returns the polygon mesh
  109011. */
  109012. static CreatePolygon(name: string, options: {
  109013. shape: Vector3[];
  109014. holes?: Vector3[][];
  109015. depth?: number;
  109016. faceUV?: Vector4[];
  109017. faceColors?: Color4[];
  109018. updatable?: boolean;
  109019. sideOrientation?: number;
  109020. frontUVs?: Vector4;
  109021. backUVs?: Vector4;
  109022. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109023. /**
  109024. * Creates an extruded polygon mesh, with depth in the Y direction.
  109025. * * 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)
  109026. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109027. * @param name defines the name of the mesh
  109028. * @param options defines the options used to create the mesh
  109029. * @param scene defines the hosting scene
  109030. * @param earcutInjection can be used to inject your own earcut reference
  109031. * @returns the polygon mesh
  109032. */
  109033. static ExtrudePolygon(name: string, options: {
  109034. shape: Vector3[];
  109035. holes?: Vector3[][];
  109036. depth?: number;
  109037. faceUV?: Vector4[];
  109038. faceColors?: Color4[];
  109039. updatable?: boolean;
  109040. sideOrientation?: number;
  109041. frontUVs?: Vector4;
  109042. backUVs?: Vector4;
  109043. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109044. }
  109045. }
  109046. declare module BABYLON {
  109047. /**
  109048. * Class containing static functions to help procedurally build meshes
  109049. */
  109050. export class LatheBuilder {
  109051. /**
  109052. * Creates lathe mesh.
  109053. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109054. * * 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
  109055. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109056. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109057. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109058. * * 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
  109059. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109060. * * 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
  109061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109063. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109065. * @param name defines the name of the mesh
  109066. * @param options defines the options used to create the mesh
  109067. * @param scene defines the hosting scene
  109068. * @returns the lathe mesh
  109069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109070. */
  109071. static CreateLathe(name: string, options: {
  109072. shape: Vector3[];
  109073. radius?: number;
  109074. tessellation?: number;
  109075. clip?: number;
  109076. arc?: number;
  109077. closed?: boolean;
  109078. updatable?: boolean;
  109079. sideOrientation?: number;
  109080. frontUVs?: Vector4;
  109081. backUVs?: Vector4;
  109082. cap?: number;
  109083. invertUV?: boolean;
  109084. }, scene?: Nullable<Scene>): Mesh;
  109085. }
  109086. }
  109087. declare module BABYLON {
  109088. /**
  109089. * Class containing static functions to help procedurally build meshes
  109090. */
  109091. export class TubeBuilder {
  109092. /**
  109093. * Creates a tube mesh.
  109094. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109095. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109096. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109097. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109098. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109099. * * 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)
  109100. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109101. * * 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
  109102. * * 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
  109103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109105. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109107. * @param name defines the name of the mesh
  109108. * @param options defines the options used to create the mesh
  109109. * @param scene defines the hosting scene
  109110. * @returns the tube mesh
  109111. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109112. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109113. */
  109114. static CreateTube(name: string, options: {
  109115. path: Vector3[];
  109116. radius?: number;
  109117. tessellation?: number;
  109118. radiusFunction?: {
  109119. (i: number, distance: number): number;
  109120. };
  109121. cap?: number;
  109122. arc?: number;
  109123. updatable?: boolean;
  109124. sideOrientation?: number;
  109125. frontUVs?: Vector4;
  109126. backUVs?: Vector4;
  109127. instance?: Mesh;
  109128. invertUV?: boolean;
  109129. }, scene?: Nullable<Scene>): Mesh;
  109130. }
  109131. }
  109132. declare module BABYLON {
  109133. /**
  109134. * Class containing static functions to help procedurally build meshes
  109135. */
  109136. export class IcoSphereBuilder {
  109137. /**
  109138. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109139. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109140. * * 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`)
  109141. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109142. * * 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
  109143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109144. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109146. * @param name defines the name of the mesh
  109147. * @param options defines the options used to create the mesh
  109148. * @param scene defines the hosting scene
  109149. * @returns the icosahedron mesh
  109150. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109151. */
  109152. static CreateIcoSphere(name: string, options: {
  109153. radius?: number;
  109154. radiusX?: number;
  109155. radiusY?: number;
  109156. radiusZ?: number;
  109157. flat?: boolean;
  109158. subdivisions?: number;
  109159. sideOrientation?: number;
  109160. frontUVs?: Vector4;
  109161. backUVs?: Vector4;
  109162. updatable?: boolean;
  109163. }, scene?: Nullable<Scene>): Mesh;
  109164. }
  109165. }
  109166. declare module BABYLON {
  109167. /**
  109168. * Class containing static functions to help procedurally build meshes
  109169. */
  109170. export class DecalBuilder {
  109171. /**
  109172. * Creates a decal mesh.
  109173. * 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
  109174. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109175. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109176. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109177. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109178. * @param name defines the name of the mesh
  109179. * @param sourceMesh defines the mesh where the decal must be applied
  109180. * @param options defines the options used to create the mesh
  109181. * @param scene defines the hosting scene
  109182. * @returns the decal mesh
  109183. * @see https://doc.babylonjs.com/how_to/decals
  109184. */
  109185. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109186. position?: Vector3;
  109187. normal?: Vector3;
  109188. size?: Vector3;
  109189. angle?: number;
  109190. }): Mesh;
  109191. }
  109192. }
  109193. declare module BABYLON {
  109194. /**
  109195. * Class containing static functions to help procedurally build meshes
  109196. */
  109197. export class MeshBuilder {
  109198. /**
  109199. * Creates a box mesh
  109200. * * The parameter `size` sets the size (float) of each box side (default 1)
  109201. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109202. * * 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)
  109203. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109205. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109207. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109208. * @param name defines the name of the mesh
  109209. * @param options defines the options used to create the mesh
  109210. * @param scene defines the hosting scene
  109211. * @returns the box mesh
  109212. */
  109213. static CreateBox(name: string, options: {
  109214. size?: number;
  109215. width?: number;
  109216. height?: number;
  109217. depth?: number;
  109218. faceUV?: Vector4[];
  109219. faceColors?: Color4[];
  109220. sideOrientation?: number;
  109221. frontUVs?: Vector4;
  109222. backUVs?: Vector4;
  109223. updatable?: boolean;
  109224. }, scene?: Nullable<Scene>): Mesh;
  109225. /**
  109226. * Creates a sphere mesh
  109227. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109228. * * 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`)
  109229. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109230. * * 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
  109231. * * 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)
  109232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109235. * @param name defines the name of the mesh
  109236. * @param options defines the options used to create the mesh
  109237. * @param scene defines the hosting scene
  109238. * @returns the sphere mesh
  109239. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109240. */
  109241. static CreateSphere(name: string, options: {
  109242. segments?: number;
  109243. diameter?: number;
  109244. diameterX?: number;
  109245. diameterY?: number;
  109246. diameterZ?: number;
  109247. arc?: number;
  109248. slice?: number;
  109249. sideOrientation?: number;
  109250. frontUVs?: Vector4;
  109251. backUVs?: Vector4;
  109252. updatable?: boolean;
  109253. }, scene?: Nullable<Scene>): Mesh;
  109254. /**
  109255. * Creates a plane polygonal mesh. By default, this is a disc
  109256. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109257. * * 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
  109258. * * 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
  109259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109260. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109262. * @param name defines the name of the mesh
  109263. * @param options defines the options used to create the mesh
  109264. * @param scene defines the hosting scene
  109265. * @returns the plane polygonal mesh
  109266. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109267. */
  109268. static CreateDisc(name: string, options: {
  109269. radius?: number;
  109270. tessellation?: number;
  109271. arc?: number;
  109272. updatable?: boolean;
  109273. sideOrientation?: number;
  109274. frontUVs?: Vector4;
  109275. backUVs?: Vector4;
  109276. }, scene?: Nullable<Scene>): Mesh;
  109277. /**
  109278. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109279. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109280. * * 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`)
  109281. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109282. * * 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
  109283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109286. * @param name defines the name of the mesh
  109287. * @param options defines the options used to create the mesh
  109288. * @param scene defines the hosting scene
  109289. * @returns the icosahedron mesh
  109290. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109291. */
  109292. static CreateIcoSphere(name: string, options: {
  109293. radius?: number;
  109294. radiusX?: number;
  109295. radiusY?: number;
  109296. radiusZ?: number;
  109297. flat?: boolean;
  109298. subdivisions?: number;
  109299. sideOrientation?: number;
  109300. frontUVs?: Vector4;
  109301. backUVs?: Vector4;
  109302. updatable?: boolean;
  109303. }, scene?: Nullable<Scene>): Mesh;
  109304. /**
  109305. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109306. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  109307. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  109308. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  109309. * * 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
  109310. * * 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
  109311. * * 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
  109312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109313. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109314. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109315. * * 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
  109316. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  109317. * * 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
  109318. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  109319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109320. * @param name defines the name of the mesh
  109321. * @param options defines the options used to create the mesh
  109322. * @param scene defines the hosting scene
  109323. * @returns the ribbon mesh
  109324. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  109325. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109326. */
  109327. static CreateRibbon(name: string, options: {
  109328. pathArray: Vector3[][];
  109329. closeArray?: boolean;
  109330. closePath?: boolean;
  109331. offset?: number;
  109332. updatable?: boolean;
  109333. sideOrientation?: number;
  109334. frontUVs?: Vector4;
  109335. backUVs?: Vector4;
  109336. instance?: Mesh;
  109337. invertUV?: boolean;
  109338. uvs?: Vector2[];
  109339. colors?: Color4[];
  109340. }, scene?: Nullable<Scene>): Mesh;
  109341. /**
  109342. * Creates a cylinder or a cone mesh
  109343. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109344. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109345. * * 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.
  109346. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109347. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109348. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109349. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109350. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109351. * * 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).
  109352. * * 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
  109353. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109354. * * 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
  109355. * * 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.
  109356. * * If `enclose` is false, a ring surface is one element.
  109357. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109358. * * 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
  109359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109362. * @param name defines the name of the mesh
  109363. * @param options defines the options used to create the mesh
  109364. * @param scene defines the hosting scene
  109365. * @returns the cylinder mesh
  109366. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109367. */
  109368. static CreateCylinder(name: string, options: {
  109369. height?: number;
  109370. diameterTop?: number;
  109371. diameterBottom?: number;
  109372. diameter?: number;
  109373. tessellation?: number;
  109374. subdivisions?: number;
  109375. arc?: number;
  109376. faceColors?: Color4[];
  109377. faceUV?: Vector4[];
  109378. updatable?: boolean;
  109379. hasRings?: boolean;
  109380. enclose?: boolean;
  109381. sideOrientation?: number;
  109382. frontUVs?: Vector4;
  109383. backUVs?: Vector4;
  109384. }, scene?: Nullable<Scene>): Mesh;
  109385. /**
  109386. * Creates a torus mesh
  109387. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109388. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109389. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109391. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109393. * @param name defines the name of the mesh
  109394. * @param options defines the options used to create the mesh
  109395. * @param scene defines the hosting scene
  109396. * @returns the torus mesh
  109397. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109398. */
  109399. static CreateTorus(name: string, options: {
  109400. diameter?: number;
  109401. thickness?: number;
  109402. tessellation?: number;
  109403. updatable?: boolean;
  109404. sideOrientation?: number;
  109405. frontUVs?: Vector4;
  109406. backUVs?: Vector4;
  109407. }, scene?: Nullable<Scene>): Mesh;
  109408. /**
  109409. * Creates a torus knot mesh
  109410. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109411. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109412. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109413. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109417. * @param name defines the name of the mesh
  109418. * @param options defines the options used to create the mesh
  109419. * @param scene defines the hosting scene
  109420. * @returns the torus knot mesh
  109421. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109422. */
  109423. static CreateTorusKnot(name: string, options: {
  109424. radius?: number;
  109425. tube?: number;
  109426. radialSegments?: number;
  109427. tubularSegments?: number;
  109428. p?: number;
  109429. q?: number;
  109430. updatable?: boolean;
  109431. sideOrientation?: number;
  109432. frontUVs?: Vector4;
  109433. backUVs?: Vector4;
  109434. }, scene?: Nullable<Scene>): Mesh;
  109435. /**
  109436. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109437. * * 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
  109438. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109439. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109440. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109441. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109442. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109443. * * 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
  109444. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109447. * @param name defines the name of the new line system
  109448. * @param options defines the options used to create the line system
  109449. * @param scene defines the hosting scene
  109450. * @returns a new line system mesh
  109451. */
  109452. static CreateLineSystem(name: string, options: {
  109453. lines: Vector3[][];
  109454. updatable?: boolean;
  109455. instance?: Nullable<LinesMesh>;
  109456. colors?: Nullable<Color4[][]>;
  109457. useVertexAlpha?: boolean;
  109458. }, scene: Nullable<Scene>): LinesMesh;
  109459. /**
  109460. * Creates a line mesh
  109461. * 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
  109462. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109463. * * The parameter `points` is an array successive Vector3
  109464. * * 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
  109465. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109466. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109467. * * When updating an instance, remember that only point positions can change, not the number of points
  109468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109469. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109470. * @param name defines the name of the new line system
  109471. * @param options defines the options used to create the line system
  109472. * @param scene defines the hosting scene
  109473. * @returns a new line mesh
  109474. */
  109475. static CreateLines(name: string, options: {
  109476. points: Vector3[];
  109477. updatable?: boolean;
  109478. instance?: Nullable<LinesMesh>;
  109479. colors?: Color4[];
  109480. useVertexAlpha?: boolean;
  109481. }, scene?: Nullable<Scene>): LinesMesh;
  109482. /**
  109483. * Creates a dashed line mesh
  109484. * * 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
  109485. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109486. * * The parameter `points` is an array successive Vector3
  109487. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109488. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109489. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109490. * * 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
  109491. * * When updating an instance, remember that only point positions can change, not the number of points
  109492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109493. * @param name defines the name of the mesh
  109494. * @param options defines the options used to create the mesh
  109495. * @param scene defines the hosting scene
  109496. * @returns the dashed line mesh
  109497. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109498. */
  109499. static CreateDashedLines(name: string, options: {
  109500. points: Vector3[];
  109501. dashSize?: number;
  109502. gapSize?: number;
  109503. dashNb?: number;
  109504. updatable?: boolean;
  109505. instance?: LinesMesh;
  109506. }, scene?: Nullable<Scene>): LinesMesh;
  109507. /**
  109508. * 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.
  109509. * * 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.
  109510. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109511. * * 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.
  109512. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  109513. * * 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
  109514. * * 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
  109515. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  109516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109518. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  109519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109520. * @param name defines the name of the mesh
  109521. * @param options defines the options used to create the mesh
  109522. * @param scene defines the hosting scene
  109523. * @returns the extruded shape mesh
  109524. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109525. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109526. */
  109527. static ExtrudeShape(name: string, options: {
  109528. shape: Vector3[];
  109529. path: Vector3[];
  109530. scale?: number;
  109531. rotation?: number;
  109532. cap?: number;
  109533. updatable?: boolean;
  109534. sideOrientation?: number;
  109535. frontUVs?: Vector4;
  109536. backUVs?: Vector4;
  109537. instance?: Mesh;
  109538. invertUV?: boolean;
  109539. }, scene?: Nullable<Scene>): Mesh;
  109540. /**
  109541. * Creates an custom extruded shape mesh.
  109542. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  109543. * * 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.
  109544. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109545. * * 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
  109546. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  109547. * * 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
  109548. * * It must returns a float value that will be the scale value applied to the shape on each path point
  109549. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109550. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  109551. * * 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
  109552. * * 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
  109553. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  109554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109556. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109558. * @param name defines the name of the mesh
  109559. * @param options defines the options used to create the mesh
  109560. * @param scene defines the hosting scene
  109561. * @returns the custom extruded shape mesh
  109562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  109563. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109564. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109565. */
  109566. static ExtrudeShapeCustom(name: string, options: {
  109567. shape: Vector3[];
  109568. path: Vector3[];
  109569. scaleFunction?: any;
  109570. rotationFunction?: any;
  109571. ribbonCloseArray?: boolean;
  109572. ribbonClosePath?: boolean;
  109573. cap?: number;
  109574. updatable?: boolean;
  109575. sideOrientation?: number;
  109576. frontUVs?: Vector4;
  109577. backUVs?: Vector4;
  109578. instance?: Mesh;
  109579. invertUV?: boolean;
  109580. }, scene?: Nullable<Scene>): Mesh;
  109581. /**
  109582. * Creates lathe mesh.
  109583. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109584. * * 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
  109585. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109586. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109587. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109588. * * 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
  109589. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109590. * * 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
  109591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109592. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109593. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109595. * @param name defines the name of the mesh
  109596. * @param options defines the options used to create the mesh
  109597. * @param scene defines the hosting scene
  109598. * @returns the lathe mesh
  109599. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109600. */
  109601. static CreateLathe(name: string, options: {
  109602. shape: Vector3[];
  109603. radius?: number;
  109604. tessellation?: number;
  109605. clip?: number;
  109606. arc?: number;
  109607. closed?: boolean;
  109608. updatable?: boolean;
  109609. sideOrientation?: number;
  109610. frontUVs?: Vector4;
  109611. backUVs?: Vector4;
  109612. cap?: number;
  109613. invertUV?: boolean;
  109614. }, scene?: Nullable<Scene>): Mesh;
  109615. /**
  109616. * Creates a plane mesh
  109617. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109618. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109619. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109623. * @param name defines the name of the mesh
  109624. * @param options defines the options used to create the mesh
  109625. * @param scene defines the hosting scene
  109626. * @returns the plane mesh
  109627. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109628. */
  109629. static CreatePlane(name: string, options: {
  109630. size?: number;
  109631. width?: number;
  109632. height?: number;
  109633. sideOrientation?: number;
  109634. frontUVs?: Vector4;
  109635. backUVs?: Vector4;
  109636. updatable?: boolean;
  109637. sourcePlane?: Plane;
  109638. }, scene?: Nullable<Scene>): Mesh;
  109639. /**
  109640. * Creates a ground mesh
  109641. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109642. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109644. * @param name defines the name of the mesh
  109645. * @param options defines the options used to create the mesh
  109646. * @param scene defines the hosting scene
  109647. * @returns the ground mesh
  109648. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109649. */
  109650. static CreateGround(name: string, options: {
  109651. width?: number;
  109652. height?: number;
  109653. subdivisions?: number;
  109654. subdivisionsX?: number;
  109655. subdivisionsY?: number;
  109656. updatable?: boolean;
  109657. }, scene?: Nullable<Scene>): Mesh;
  109658. /**
  109659. * Creates a tiled ground mesh
  109660. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109661. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109662. * * 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
  109663. * * 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
  109664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109665. * @param name defines the name of the mesh
  109666. * @param options defines the options used to create the mesh
  109667. * @param scene defines the hosting scene
  109668. * @returns the tiled ground mesh
  109669. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109670. */
  109671. static CreateTiledGround(name: string, options: {
  109672. xmin: number;
  109673. zmin: number;
  109674. xmax: number;
  109675. zmax: number;
  109676. subdivisions?: {
  109677. w: number;
  109678. h: number;
  109679. };
  109680. precision?: {
  109681. w: number;
  109682. h: number;
  109683. };
  109684. updatable?: boolean;
  109685. }, scene?: Nullable<Scene>): Mesh;
  109686. /**
  109687. * Creates a ground mesh from a height map
  109688. * * The parameter `url` sets the URL of the height map image resource.
  109689. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109690. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109691. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109692. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109693. * * 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.
  109694. * * 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).
  109695. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109697. * @param name defines the name of the mesh
  109698. * @param url defines the url to the height map
  109699. * @param options defines the options used to create the mesh
  109700. * @param scene defines the hosting scene
  109701. * @returns the ground mesh
  109702. * @see https://doc.babylonjs.com/babylon101/height_map
  109703. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109704. */
  109705. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109706. width?: number;
  109707. height?: number;
  109708. subdivisions?: number;
  109709. minHeight?: number;
  109710. maxHeight?: number;
  109711. colorFilter?: Color3;
  109712. alphaFilter?: number;
  109713. updatable?: boolean;
  109714. onReady?: (mesh: GroundMesh) => void;
  109715. }, scene?: Nullable<Scene>): GroundMesh;
  109716. /**
  109717. * Creates a polygon mesh
  109718. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109719. * * 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
  109720. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109723. * * Remember you can only change the shape positions, not their number when updating a polygon
  109724. * @param name defines the name of the mesh
  109725. * @param options defines the options used to create the mesh
  109726. * @param scene defines the hosting scene
  109727. * @param earcutInjection can be used to inject your own earcut reference
  109728. * @returns the polygon mesh
  109729. */
  109730. static CreatePolygon(name: string, options: {
  109731. shape: Vector3[];
  109732. holes?: Vector3[][];
  109733. depth?: number;
  109734. faceUV?: Vector4[];
  109735. faceColors?: Color4[];
  109736. updatable?: boolean;
  109737. sideOrientation?: number;
  109738. frontUVs?: Vector4;
  109739. backUVs?: Vector4;
  109740. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109741. /**
  109742. * Creates an extruded polygon mesh, with depth in the Y direction.
  109743. * * 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)
  109744. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109745. * @param name defines the name of the mesh
  109746. * @param options defines the options used to create the mesh
  109747. * @param scene defines the hosting scene
  109748. * @param earcutInjection can be used to inject your own earcut reference
  109749. * @returns the polygon mesh
  109750. */
  109751. static ExtrudePolygon(name: string, options: {
  109752. shape: Vector3[];
  109753. holes?: Vector3[][];
  109754. depth?: number;
  109755. faceUV?: Vector4[];
  109756. faceColors?: Color4[];
  109757. updatable?: boolean;
  109758. sideOrientation?: number;
  109759. frontUVs?: Vector4;
  109760. backUVs?: Vector4;
  109761. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109762. /**
  109763. * Creates a tube mesh.
  109764. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109765. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109766. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109767. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109768. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109769. * * 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)
  109770. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109771. * * 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
  109772. * * 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
  109773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109775. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109777. * @param name defines the name of the mesh
  109778. * @param options defines the options used to create the mesh
  109779. * @param scene defines the hosting scene
  109780. * @returns the tube mesh
  109781. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109782. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109783. */
  109784. static CreateTube(name: string, options: {
  109785. path: Vector3[];
  109786. radius?: number;
  109787. tessellation?: number;
  109788. radiusFunction?: {
  109789. (i: number, distance: number): number;
  109790. };
  109791. cap?: number;
  109792. arc?: number;
  109793. updatable?: boolean;
  109794. sideOrientation?: number;
  109795. frontUVs?: Vector4;
  109796. backUVs?: Vector4;
  109797. instance?: Mesh;
  109798. invertUV?: boolean;
  109799. }, scene?: Nullable<Scene>): Mesh;
  109800. /**
  109801. * Creates a polyhedron mesh
  109802. * * 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
  109803. * * The parameter `size` (positive float, default 1) sets the polygon size
  109804. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109805. * * 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`
  109806. * * 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
  109807. * * 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)`)
  109808. * * 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
  109809. * * 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
  109810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109813. * @param name defines the name of the mesh
  109814. * @param options defines the options used to create the mesh
  109815. * @param scene defines the hosting scene
  109816. * @returns the polyhedron mesh
  109817. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  109818. */
  109819. static CreatePolyhedron(name: string, options: {
  109820. type?: number;
  109821. size?: number;
  109822. sizeX?: number;
  109823. sizeY?: number;
  109824. sizeZ?: number;
  109825. custom?: any;
  109826. faceUV?: Vector4[];
  109827. faceColors?: Color4[];
  109828. flat?: boolean;
  109829. updatable?: boolean;
  109830. sideOrientation?: number;
  109831. frontUVs?: Vector4;
  109832. backUVs?: Vector4;
  109833. }, scene?: Nullable<Scene>): Mesh;
  109834. /**
  109835. * Creates a decal mesh.
  109836. * 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
  109837. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109838. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109839. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109840. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109841. * @param name defines the name of the mesh
  109842. * @param sourceMesh defines the mesh where the decal must be applied
  109843. * @param options defines the options used to create the mesh
  109844. * @param scene defines the hosting scene
  109845. * @returns the decal mesh
  109846. * @see https://doc.babylonjs.com/how_to/decals
  109847. */
  109848. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109849. position?: Vector3;
  109850. normal?: Vector3;
  109851. size?: Vector3;
  109852. angle?: number;
  109853. }): Mesh;
  109854. }
  109855. }
  109856. declare module BABYLON {
  109857. /**
  109858. * A simplifier interface for future simplification implementations
  109859. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109860. */
  109861. export interface ISimplifier {
  109862. /**
  109863. * Simplification of a given mesh according to the given settings.
  109864. * Since this requires computation, it is assumed that the function runs async.
  109865. * @param settings The settings of the simplification, including quality and distance
  109866. * @param successCallback A callback that will be called after the mesh was simplified.
  109867. * @param errorCallback in case of an error, this callback will be called. optional.
  109868. */
  109869. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  109870. }
  109871. /**
  109872. * Expected simplification settings.
  109873. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  109874. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109875. */
  109876. export interface ISimplificationSettings {
  109877. /**
  109878. * Gets or sets the expected quality
  109879. */
  109880. quality: number;
  109881. /**
  109882. * Gets or sets the distance when this optimized version should be used
  109883. */
  109884. distance: number;
  109885. /**
  109886. * Gets an already optimized mesh
  109887. */
  109888. optimizeMesh?: boolean;
  109889. }
  109890. /**
  109891. * Class used to specify simplification options
  109892. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109893. */
  109894. export class SimplificationSettings implements ISimplificationSettings {
  109895. /** expected quality */
  109896. quality: number;
  109897. /** distance when this optimized version should be used */
  109898. distance: number;
  109899. /** already optimized mesh */
  109900. optimizeMesh?: boolean | undefined;
  109901. /**
  109902. * Creates a SimplificationSettings
  109903. * @param quality expected quality
  109904. * @param distance distance when this optimized version should be used
  109905. * @param optimizeMesh already optimized mesh
  109906. */
  109907. constructor(
  109908. /** expected quality */
  109909. quality: number,
  109910. /** distance when this optimized version should be used */
  109911. distance: number,
  109912. /** already optimized mesh */
  109913. optimizeMesh?: boolean | undefined);
  109914. }
  109915. /**
  109916. * Interface used to define a simplification task
  109917. */
  109918. export interface ISimplificationTask {
  109919. /**
  109920. * Array of settings
  109921. */
  109922. settings: Array<ISimplificationSettings>;
  109923. /**
  109924. * Simplification type
  109925. */
  109926. simplificationType: SimplificationType;
  109927. /**
  109928. * Mesh to simplify
  109929. */
  109930. mesh: Mesh;
  109931. /**
  109932. * Callback called on success
  109933. */
  109934. successCallback?: () => void;
  109935. /**
  109936. * Defines if parallel processing can be used
  109937. */
  109938. parallelProcessing: boolean;
  109939. }
  109940. /**
  109941. * Queue used to order the simplification tasks
  109942. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109943. */
  109944. export class SimplificationQueue {
  109945. private _simplificationArray;
  109946. /**
  109947. * Gets a boolean indicating that the process is still running
  109948. */
  109949. running: boolean;
  109950. /**
  109951. * Creates a new queue
  109952. */
  109953. constructor();
  109954. /**
  109955. * Adds a new simplification task
  109956. * @param task defines a task to add
  109957. */
  109958. addTask(task: ISimplificationTask): void;
  109959. /**
  109960. * Execute next task
  109961. */
  109962. executeNext(): void;
  109963. /**
  109964. * Execute a simplification task
  109965. * @param task defines the task to run
  109966. */
  109967. runSimplification(task: ISimplificationTask): void;
  109968. private getSimplifier;
  109969. }
  109970. /**
  109971. * The implemented types of simplification
  109972. * At the moment only Quadratic Error Decimation is implemented
  109973. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109974. */
  109975. export enum SimplificationType {
  109976. /** Quadratic error decimation */
  109977. QUADRATIC = 0
  109978. }
  109979. }
  109980. declare module BABYLON {
  109981. interface Scene {
  109982. /** @hidden (Backing field) */
  109983. _simplificationQueue: SimplificationQueue;
  109984. /**
  109985. * Gets or sets the simplification queue attached to the scene
  109986. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109987. */
  109988. simplificationQueue: SimplificationQueue;
  109989. }
  109990. interface Mesh {
  109991. /**
  109992. * Simplify the mesh according to the given array of settings.
  109993. * Function will return immediately and will simplify async
  109994. * @param settings a collection of simplification settings
  109995. * @param parallelProcessing should all levels calculate parallel or one after the other
  109996. * @param simplificationType the type of simplification to run
  109997. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  109998. * @returns the current mesh
  109999. */
  110000. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  110001. }
  110002. /**
  110003. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  110004. * created in a scene
  110005. */
  110006. export class SimplicationQueueSceneComponent implements ISceneComponent {
  110007. /**
  110008. * The component name helpfull to identify the component in the list of scene components.
  110009. */
  110010. readonly name: string;
  110011. /**
  110012. * The scene the component belongs to.
  110013. */
  110014. scene: Scene;
  110015. /**
  110016. * Creates a new instance of the component for the given scene
  110017. * @param scene Defines the scene to register the component in
  110018. */
  110019. constructor(scene: Scene);
  110020. /**
  110021. * Registers the component in a given scene
  110022. */
  110023. register(): void;
  110024. /**
  110025. * Rebuilds the elements related to this component in case of
  110026. * context lost for instance.
  110027. */
  110028. rebuild(): void;
  110029. /**
  110030. * Disposes the component and the associated ressources
  110031. */
  110032. dispose(): void;
  110033. private _beforeCameraUpdate;
  110034. }
  110035. }
  110036. declare module BABYLON {
  110037. /**
  110038. * Class used to enable access to IndexedDB
  110039. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110040. */
  110041. export class Database implements IOfflineProvider {
  110042. private _callbackManifestChecked;
  110043. private _currentSceneUrl;
  110044. private _db;
  110045. private _enableSceneOffline;
  110046. private _enableTexturesOffline;
  110047. private _manifestVersionFound;
  110048. private _mustUpdateRessources;
  110049. private _hasReachedQuota;
  110050. private _isSupported;
  110051. private _idbFactory;
  110052. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  110053. private static IsUASupportingBlobStorage;
  110054. /**
  110055. * Gets a boolean indicating if Database storate is enabled (off by default)
  110056. */
  110057. static IDBStorageEnabled: boolean;
  110058. /**
  110059. * Gets a boolean indicating if scene must be saved in the database
  110060. */
  110061. readonly enableSceneOffline: boolean;
  110062. /**
  110063. * Gets a boolean indicating if textures must be saved in the database
  110064. */
  110065. readonly enableTexturesOffline: boolean;
  110066. /**
  110067. * Creates a new Database
  110068. * @param urlToScene defines the url to load the scene
  110069. * @param callbackManifestChecked defines the callback to use when manifest is checked
  110070. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  110071. */
  110072. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  110073. private static _ParseURL;
  110074. private static _ReturnFullUrlLocation;
  110075. private _checkManifestFile;
  110076. /**
  110077. * Open the database and make it available
  110078. * @param successCallback defines the callback to call on success
  110079. * @param errorCallback defines the callback to call on error
  110080. */
  110081. open(successCallback: () => void, errorCallback: () => void): void;
  110082. /**
  110083. * Loads an image from the database
  110084. * @param url defines the url to load from
  110085. * @param image defines the target DOM image
  110086. */
  110087. loadImage(url: string, image: HTMLImageElement): void;
  110088. private _loadImageFromDBAsync;
  110089. private _saveImageIntoDBAsync;
  110090. private _checkVersionFromDB;
  110091. private _loadVersionFromDBAsync;
  110092. private _saveVersionIntoDBAsync;
  110093. /**
  110094. * Loads a file from database
  110095. * @param url defines the URL to load from
  110096. * @param sceneLoaded defines a callback to call on success
  110097. * @param progressCallBack defines a callback to call when progress changed
  110098. * @param errorCallback defines a callback to call on error
  110099. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  110100. */
  110101. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  110102. private _loadFileAsync;
  110103. private _saveFileAsync;
  110104. /**
  110105. * Validates if xhr data is correct
  110106. * @param xhr defines the request to validate
  110107. * @param dataType defines the expected data type
  110108. * @returns true if data is correct
  110109. */
  110110. private static _ValidateXHRData;
  110111. }
  110112. }
  110113. declare module BABYLON {
  110114. /** @hidden */
  110115. export var gpuUpdateParticlesPixelShader: {
  110116. name: string;
  110117. shader: string;
  110118. };
  110119. }
  110120. declare module BABYLON {
  110121. /** @hidden */
  110122. export var gpuUpdateParticlesVertexShader: {
  110123. name: string;
  110124. shader: string;
  110125. };
  110126. }
  110127. declare module BABYLON {
  110128. /** @hidden */
  110129. export var clipPlaneFragmentDeclaration2: {
  110130. name: string;
  110131. shader: string;
  110132. };
  110133. }
  110134. declare module BABYLON {
  110135. /** @hidden */
  110136. export var gpuRenderParticlesPixelShader: {
  110137. name: string;
  110138. shader: string;
  110139. };
  110140. }
  110141. declare module BABYLON {
  110142. /** @hidden */
  110143. export var clipPlaneVertexDeclaration2: {
  110144. name: string;
  110145. shader: string;
  110146. };
  110147. }
  110148. declare module BABYLON {
  110149. /** @hidden */
  110150. export var gpuRenderParticlesVertexShader: {
  110151. name: string;
  110152. shader: string;
  110153. };
  110154. }
  110155. declare module BABYLON {
  110156. /**
  110157. * This represents a GPU particle system in Babylon
  110158. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  110159. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  110160. */
  110161. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  110162. /**
  110163. * The layer mask we are rendering the particles through.
  110164. */
  110165. layerMask: number;
  110166. private _capacity;
  110167. private _activeCount;
  110168. private _currentActiveCount;
  110169. private _accumulatedCount;
  110170. private _renderEffect;
  110171. private _updateEffect;
  110172. private _buffer0;
  110173. private _buffer1;
  110174. private _spriteBuffer;
  110175. private _updateVAO;
  110176. private _renderVAO;
  110177. private _targetIndex;
  110178. private _sourceBuffer;
  110179. private _targetBuffer;
  110180. private _engine;
  110181. private _currentRenderId;
  110182. private _started;
  110183. private _stopped;
  110184. private _timeDelta;
  110185. private _randomTexture;
  110186. private _randomTexture2;
  110187. private _attributesStrideSize;
  110188. private _updateEffectOptions;
  110189. private _randomTextureSize;
  110190. private _actualFrame;
  110191. private readonly _rawTextureWidth;
  110192. /**
  110193. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  110194. */
  110195. static readonly IsSupported: boolean;
  110196. /**
  110197. * An event triggered when the system is disposed.
  110198. */
  110199. onDisposeObservable: Observable<GPUParticleSystem>;
  110200. /**
  110201. * Gets the maximum number of particles active at the same time.
  110202. * @returns The max number of active particles.
  110203. */
  110204. getCapacity(): number;
  110205. /**
  110206. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  110207. * to override the particles.
  110208. */
  110209. forceDepthWrite: boolean;
  110210. /**
  110211. * Gets or set the number of active particles
  110212. */
  110213. activeParticleCount: number;
  110214. private _preWarmDone;
  110215. /**
  110216. * Is this system ready to be used/rendered
  110217. * @return true if the system is ready
  110218. */
  110219. isReady(): boolean;
  110220. /**
  110221. * Gets if the system has been started. (Note: this will still be true after stop is called)
  110222. * @returns True if it has been started, otherwise false.
  110223. */
  110224. isStarted(): boolean;
  110225. /**
  110226. * Starts the particle system and begins to emit
  110227. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  110228. */
  110229. start(delay?: number): void;
  110230. /**
  110231. * Stops the particle system.
  110232. */
  110233. stop(): void;
  110234. /**
  110235. * Remove all active particles
  110236. */
  110237. reset(): void;
  110238. /**
  110239. * Returns the string "GPUParticleSystem"
  110240. * @returns a string containing the class name
  110241. */
  110242. getClassName(): string;
  110243. private _colorGradientsTexture;
  110244. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  110245. /**
  110246. * Adds a new color gradient
  110247. * @param gradient defines the gradient to use (between 0 and 1)
  110248. * @param color1 defines the color to affect to the specified gradient
  110249. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  110250. * @returns the current particle system
  110251. */
  110252. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  110253. /**
  110254. * Remove a specific color gradient
  110255. * @param gradient defines the gradient to remove
  110256. * @returns the current particle system
  110257. */
  110258. removeColorGradient(gradient: number): GPUParticleSystem;
  110259. private _angularSpeedGradientsTexture;
  110260. private _sizeGradientsTexture;
  110261. private _velocityGradientsTexture;
  110262. private _limitVelocityGradientsTexture;
  110263. private _dragGradientsTexture;
  110264. private _addFactorGradient;
  110265. /**
  110266. * Adds a new size gradient
  110267. * @param gradient defines the gradient to use (between 0 and 1)
  110268. * @param factor defines the size factor to affect to the specified gradient
  110269. * @returns the current particle system
  110270. */
  110271. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  110272. /**
  110273. * Remove a specific size gradient
  110274. * @param gradient defines the gradient to remove
  110275. * @returns the current particle system
  110276. */
  110277. removeSizeGradient(gradient: number): GPUParticleSystem;
  110278. /**
  110279. * Adds a new angular speed gradient
  110280. * @param gradient defines the gradient to use (between 0 and 1)
  110281. * @param factor defines the angular speed to affect to the specified gradient
  110282. * @returns the current particle system
  110283. */
  110284. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  110285. /**
  110286. * Remove a specific angular speed gradient
  110287. * @param gradient defines the gradient to remove
  110288. * @returns the current particle system
  110289. */
  110290. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  110291. /**
  110292. * Adds a new velocity gradient
  110293. * @param gradient defines the gradient to use (between 0 and 1)
  110294. * @param factor defines the velocity to affect to the specified gradient
  110295. * @returns the current particle system
  110296. */
  110297. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110298. /**
  110299. * Remove a specific velocity gradient
  110300. * @param gradient defines the gradient to remove
  110301. * @returns the current particle system
  110302. */
  110303. removeVelocityGradient(gradient: number): GPUParticleSystem;
  110304. /**
  110305. * Adds a new limit velocity gradient
  110306. * @param gradient defines the gradient to use (between 0 and 1)
  110307. * @param factor defines the limit velocity value to affect to the specified gradient
  110308. * @returns the current particle system
  110309. */
  110310. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110311. /**
  110312. * Remove a specific limit velocity gradient
  110313. * @param gradient defines the gradient to remove
  110314. * @returns the current particle system
  110315. */
  110316. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  110317. /**
  110318. * Adds a new drag gradient
  110319. * @param gradient defines the gradient to use (between 0 and 1)
  110320. * @param factor defines the drag value to affect to the specified gradient
  110321. * @returns the current particle system
  110322. */
  110323. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  110324. /**
  110325. * Remove a specific drag gradient
  110326. * @param gradient defines the gradient to remove
  110327. * @returns the current particle system
  110328. */
  110329. removeDragGradient(gradient: number): GPUParticleSystem;
  110330. /**
  110331. * Not supported by GPUParticleSystem
  110332. * @param gradient defines the gradient to use (between 0 and 1)
  110333. * @param factor defines the emit rate value to affect to the specified gradient
  110334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110335. * @returns the current particle system
  110336. */
  110337. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110338. /**
  110339. * Not supported by GPUParticleSystem
  110340. * @param gradient defines the gradient to remove
  110341. * @returns the current particle system
  110342. */
  110343. removeEmitRateGradient(gradient: number): IParticleSystem;
  110344. /**
  110345. * Not supported by GPUParticleSystem
  110346. * @param gradient defines the gradient to use (between 0 and 1)
  110347. * @param factor defines the start size value to affect to the specified gradient
  110348. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110349. * @returns the current particle system
  110350. */
  110351. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110352. /**
  110353. * Not supported by GPUParticleSystem
  110354. * @param gradient defines the gradient to remove
  110355. * @returns the current particle system
  110356. */
  110357. removeStartSizeGradient(gradient: number): IParticleSystem;
  110358. /**
  110359. * Not supported by GPUParticleSystem
  110360. * @param gradient defines the gradient to use (between 0 and 1)
  110361. * @param min defines the color remap minimal range
  110362. * @param max defines the color remap maximal range
  110363. * @returns the current particle system
  110364. */
  110365. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110366. /**
  110367. * Not supported by GPUParticleSystem
  110368. * @param gradient defines the gradient to remove
  110369. * @returns the current particle system
  110370. */
  110371. removeColorRemapGradient(): IParticleSystem;
  110372. /**
  110373. * Not supported by GPUParticleSystem
  110374. * @param gradient defines the gradient to use (between 0 and 1)
  110375. * @param min defines the alpha remap minimal range
  110376. * @param max defines the alpha remap maximal range
  110377. * @returns the current particle system
  110378. */
  110379. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110380. /**
  110381. * Not supported by GPUParticleSystem
  110382. * @param gradient defines the gradient to remove
  110383. * @returns the current particle system
  110384. */
  110385. removeAlphaRemapGradient(): IParticleSystem;
  110386. /**
  110387. * Not supported by GPUParticleSystem
  110388. * @param gradient defines the gradient to use (between 0 and 1)
  110389. * @param color defines the color to affect to the specified gradient
  110390. * @returns the current particle system
  110391. */
  110392. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  110393. /**
  110394. * Not supported by GPUParticleSystem
  110395. * @param gradient defines the gradient to remove
  110396. * @returns the current particle system
  110397. */
  110398. removeRampGradient(): IParticleSystem;
  110399. /**
  110400. * Not supported by GPUParticleSystem
  110401. * @returns the list of ramp gradients
  110402. */
  110403. getRampGradients(): Nullable<Array<Color3Gradient>>;
  110404. /**
  110405. * Not supported by GPUParticleSystem
  110406. * Gets or sets a boolean indicating that ramp gradients must be used
  110407. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  110408. */
  110409. useRampGradients: boolean;
  110410. /**
  110411. * Not supported by GPUParticleSystem
  110412. * @param gradient defines the gradient to use (between 0 and 1)
  110413. * @param factor defines the life time factor to affect to the specified gradient
  110414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110415. * @returns the current particle system
  110416. */
  110417. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110418. /**
  110419. * Not supported by GPUParticleSystem
  110420. * @param gradient defines the gradient to remove
  110421. * @returns the current particle system
  110422. */
  110423. removeLifeTimeGradient(gradient: number): IParticleSystem;
  110424. /**
  110425. * Instantiates a GPU particle system.
  110426. * 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.
  110427. * @param name The name of the particle system
  110428. * @param options The options used to create the system
  110429. * @param scene The scene the particle system belongs to
  110430. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  110431. */
  110432. constructor(name: string, options: Partial<{
  110433. capacity: number;
  110434. randomTextureSize: number;
  110435. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  110436. protected _reset(): void;
  110437. private _createUpdateVAO;
  110438. private _createRenderVAO;
  110439. private _initialize;
  110440. /** @hidden */
  110441. _recreateUpdateEffect(): void;
  110442. /** @hidden */
  110443. _recreateRenderEffect(): void;
  110444. /**
  110445. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  110446. * @param preWarm defines if we are in the pre-warmimg phase
  110447. */
  110448. animate(preWarm?: boolean): void;
  110449. private _createFactorGradientTexture;
  110450. private _createSizeGradientTexture;
  110451. private _createAngularSpeedGradientTexture;
  110452. private _createVelocityGradientTexture;
  110453. private _createLimitVelocityGradientTexture;
  110454. private _createDragGradientTexture;
  110455. private _createColorGradientTexture;
  110456. /**
  110457. * Renders the particle system in its current state
  110458. * @param preWarm defines if the system should only update the particles but not render them
  110459. * @returns the current number of particles
  110460. */
  110461. render(preWarm?: boolean): number;
  110462. /**
  110463. * Rebuilds the particle system
  110464. */
  110465. rebuild(): void;
  110466. private _releaseBuffers;
  110467. private _releaseVAOs;
  110468. /**
  110469. * Disposes the particle system and free the associated resources
  110470. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  110471. */
  110472. dispose(disposeTexture?: boolean): void;
  110473. /**
  110474. * Clones the particle system.
  110475. * @param name The name of the cloned object
  110476. * @param newEmitter The new emitter to use
  110477. * @returns the cloned particle system
  110478. */
  110479. clone(name: string, newEmitter: any): GPUParticleSystem;
  110480. /**
  110481. * Serializes the particle system to a JSON object.
  110482. * @returns the JSON object
  110483. */
  110484. serialize(): any;
  110485. /**
  110486. * Parses a JSON object to create a GPU particle system.
  110487. * @param parsedParticleSystem The JSON object to parse
  110488. * @param scene The scene to create the particle system in
  110489. * @param rootUrl The root url to use to load external dependencies like texture
  110490. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  110491. * @returns the parsed GPU particle system
  110492. */
  110493. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  110494. }
  110495. }
  110496. declare module BABYLON {
  110497. /**
  110498. * Represents a set of particle systems working together to create a specific effect
  110499. */
  110500. export class ParticleSystemSet implements IDisposable {
  110501. private _emitterCreationOptions;
  110502. private _emitterNode;
  110503. /**
  110504. * Gets the particle system list
  110505. */
  110506. systems: IParticleSystem[];
  110507. /**
  110508. * Gets the emitter node used with this set
  110509. */
  110510. readonly emitterNode: Nullable<TransformNode>;
  110511. /**
  110512. * Creates a new emitter mesh as a sphere
  110513. * @param options defines the options used to create the sphere
  110514. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  110515. * @param scene defines the hosting scene
  110516. */
  110517. setEmitterAsSphere(options: {
  110518. diameter: number;
  110519. segments: number;
  110520. color: Color3;
  110521. }, renderingGroupId: number, scene: Scene): void;
  110522. /**
  110523. * Starts all particle systems of the set
  110524. * @param emitter defines an optional mesh to use as emitter for the particle systems
  110525. */
  110526. start(emitter?: AbstractMesh): void;
  110527. /**
  110528. * Release all associated resources
  110529. */
  110530. dispose(): void;
  110531. /**
  110532. * Serialize the set into a JSON compatible object
  110533. * @returns a JSON compatible representation of the set
  110534. */
  110535. serialize(): any;
  110536. /**
  110537. * Parse a new ParticleSystemSet from a serialized source
  110538. * @param data defines a JSON compatible representation of the set
  110539. * @param scene defines the hosting scene
  110540. * @param gpu defines if we want GPU particles or CPU particles
  110541. * @returns a new ParticleSystemSet
  110542. */
  110543. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  110544. }
  110545. }
  110546. declare module BABYLON {
  110547. /**
  110548. * This class is made for on one-liner static method to help creating particle system set.
  110549. */
  110550. export class ParticleHelper {
  110551. /**
  110552. * Gets or sets base Assets URL
  110553. */
  110554. static BaseAssetsUrl: string;
  110555. /**
  110556. * Create a default particle system that you can tweak
  110557. * @param emitter defines the emitter to use
  110558. * @param capacity defines the system capacity (default is 500 particles)
  110559. * @param scene defines the hosting scene
  110560. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  110561. * @returns the new Particle system
  110562. */
  110563. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  110564. /**
  110565. * This is the main static method (one-liner) of this helper to create different particle systems
  110566. * @param type This string represents the type to the particle system to create
  110567. * @param scene The scene where the particle system should live
  110568. * @param gpu If the system will use gpu
  110569. * @returns the ParticleSystemSet created
  110570. */
  110571. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  110572. /**
  110573. * Static function used to export a particle system to a ParticleSystemSet variable.
  110574. * Please note that the emitter shape is not exported
  110575. * @param systems defines the particle systems to export
  110576. * @returns the created particle system set
  110577. */
  110578. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  110579. }
  110580. }
  110581. declare module BABYLON {
  110582. interface Engine {
  110583. /**
  110584. * Create an effect to use with particle systems.
  110585. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  110586. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  110587. * @param uniformsNames defines a list of attribute names
  110588. * @param samplers defines an array of string used to represent textures
  110589. * @param defines defines the string containing the defines to use to compile the shaders
  110590. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  110591. * @param onCompiled defines a function to call when the effect creation is successful
  110592. * @param onError defines a function to call when the effect creation has failed
  110593. * @returns the new Effect
  110594. */
  110595. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  110596. }
  110597. interface Mesh {
  110598. /**
  110599. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  110600. * @returns an array of IParticleSystem
  110601. */
  110602. getEmittedParticleSystems(): IParticleSystem[];
  110603. /**
  110604. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  110605. * @returns an array of IParticleSystem
  110606. */
  110607. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  110608. }
  110609. /**
  110610. * @hidden
  110611. */
  110612. export var _IDoNeedToBeInTheBuild: number;
  110613. }
  110614. declare module BABYLON {
  110615. interface Scene {
  110616. /** @hidden (Backing field) */
  110617. _physicsEngine: Nullable<IPhysicsEngine>;
  110618. /**
  110619. * Gets the current physics engine
  110620. * @returns a IPhysicsEngine or null if none attached
  110621. */
  110622. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  110623. /**
  110624. * Enables physics to the current scene
  110625. * @param gravity defines the scene's gravity for the physics engine
  110626. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  110627. * @return a boolean indicating if the physics engine was initialized
  110628. */
  110629. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  110630. /**
  110631. * Disables and disposes the physics engine associated with the scene
  110632. */
  110633. disablePhysicsEngine(): void;
  110634. /**
  110635. * Gets a boolean indicating if there is an active physics engine
  110636. * @returns a boolean indicating if there is an active physics engine
  110637. */
  110638. isPhysicsEnabled(): boolean;
  110639. /**
  110640. * Deletes a physics compound impostor
  110641. * @param compound defines the compound to delete
  110642. */
  110643. deleteCompoundImpostor(compound: any): void;
  110644. /**
  110645. * An event triggered when physic simulation is about to be run
  110646. */
  110647. onBeforePhysicsObservable: Observable<Scene>;
  110648. /**
  110649. * An event triggered when physic simulation has been done
  110650. */
  110651. onAfterPhysicsObservable: Observable<Scene>;
  110652. }
  110653. interface AbstractMesh {
  110654. /** @hidden */
  110655. _physicsImpostor: Nullable<PhysicsImpostor>;
  110656. /**
  110657. * Gets or sets impostor used for physic simulation
  110658. * @see http://doc.babylonjs.com/features/physics_engine
  110659. */
  110660. physicsImpostor: Nullable<PhysicsImpostor>;
  110661. /**
  110662. * Gets the current physics impostor
  110663. * @see http://doc.babylonjs.com/features/physics_engine
  110664. * @returns a physics impostor or null
  110665. */
  110666. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  110667. /** Apply a physic impulse to the mesh
  110668. * @param force defines the force to apply
  110669. * @param contactPoint defines where to apply the force
  110670. * @returns the current mesh
  110671. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110672. */
  110673. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  110674. /**
  110675. * Creates a physic joint between two meshes
  110676. * @param otherMesh defines the other mesh to use
  110677. * @param pivot1 defines the pivot to use on this mesh
  110678. * @param pivot2 defines the pivot to use on the other mesh
  110679. * @param options defines additional options (can be plugin dependent)
  110680. * @returns the current mesh
  110681. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  110682. */
  110683. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  110684. /** @hidden */
  110685. _disposePhysicsObserver: Nullable<Observer<Node>>;
  110686. }
  110687. /**
  110688. * Defines the physics engine scene component responsible to manage a physics engine
  110689. */
  110690. export class PhysicsEngineSceneComponent implements ISceneComponent {
  110691. /**
  110692. * The component name helpful to identify the component in the list of scene components.
  110693. */
  110694. readonly name: string;
  110695. /**
  110696. * The scene the component belongs to.
  110697. */
  110698. scene: Scene;
  110699. /**
  110700. * Creates a new instance of the component for the given scene
  110701. * @param scene Defines the scene to register the component in
  110702. */
  110703. constructor(scene: Scene);
  110704. /**
  110705. * Registers the component in a given scene
  110706. */
  110707. register(): void;
  110708. /**
  110709. * Rebuilds the elements related to this component in case of
  110710. * context lost for instance.
  110711. */
  110712. rebuild(): void;
  110713. /**
  110714. * Disposes the component and the associated ressources
  110715. */
  110716. dispose(): void;
  110717. }
  110718. }
  110719. declare module BABYLON {
  110720. /**
  110721. * A helper for physics simulations
  110722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110723. */
  110724. export class PhysicsHelper {
  110725. private _scene;
  110726. private _physicsEngine;
  110727. /**
  110728. * Initializes the Physics helper
  110729. * @param scene Babylon.js scene
  110730. */
  110731. constructor(scene: Scene);
  110732. /**
  110733. * Applies a radial explosion impulse
  110734. * @param origin the origin of the explosion
  110735. * @param radiusOrEventOptions the radius or the options of radial explosion
  110736. * @param strength the explosion strength
  110737. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110738. * @returns A physics radial explosion event, or null
  110739. */
  110740. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110741. /**
  110742. * Applies a radial explosion force
  110743. * @param origin the origin of the explosion
  110744. * @param radiusOrEventOptions the radius or the options of radial explosion
  110745. * @param strength the explosion strength
  110746. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110747. * @returns A physics radial explosion event, or null
  110748. */
  110749. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110750. /**
  110751. * Creates a gravitational field
  110752. * @param origin the origin of the explosion
  110753. * @param radiusOrEventOptions the radius or the options of radial explosion
  110754. * @param strength the explosion strength
  110755. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110756. * @returns A physics gravitational field event, or null
  110757. */
  110758. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  110759. /**
  110760. * Creates a physics updraft event
  110761. * @param origin the origin of the updraft
  110762. * @param radiusOrEventOptions the radius or the options of the updraft
  110763. * @param strength the strength of the updraft
  110764. * @param height the height of the updraft
  110765. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  110766. * @returns A physics updraft event, or null
  110767. */
  110768. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  110769. /**
  110770. * Creates a physics vortex event
  110771. * @param origin the of the vortex
  110772. * @param radiusOrEventOptions the radius or the options of the vortex
  110773. * @param strength the strength of the vortex
  110774. * @param height the height of the vortex
  110775. * @returns a Physics vortex event, or null
  110776. * A physics vortex event or null
  110777. */
  110778. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  110779. }
  110780. /**
  110781. * Represents a physics radial explosion event
  110782. */
  110783. class PhysicsRadialExplosionEvent {
  110784. private _scene;
  110785. private _options;
  110786. private _sphere;
  110787. private _dataFetched;
  110788. /**
  110789. * Initializes a radial explosioin event
  110790. * @param _scene BabylonJS scene
  110791. * @param _options The options for the vortex event
  110792. */
  110793. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  110794. /**
  110795. * Returns the data related to the radial explosion event (sphere).
  110796. * @returns The radial explosion event data
  110797. */
  110798. getData(): PhysicsRadialExplosionEventData;
  110799. /**
  110800. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  110801. * @param impostor A physics imposter
  110802. * @param origin the origin of the explosion
  110803. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  110804. */
  110805. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  110806. /**
  110807. * Triggers affecterd impostors callbacks
  110808. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  110809. */
  110810. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  110811. /**
  110812. * Disposes the sphere.
  110813. * @param force Specifies if the sphere should be disposed by force
  110814. */
  110815. dispose(force?: boolean): void;
  110816. /*** Helpers ***/
  110817. private _prepareSphere;
  110818. private _intersectsWithSphere;
  110819. }
  110820. /**
  110821. * Represents a gravitational field event
  110822. */
  110823. class PhysicsGravitationalFieldEvent {
  110824. private _physicsHelper;
  110825. private _scene;
  110826. private _origin;
  110827. private _options;
  110828. private _tickCallback;
  110829. private _sphere;
  110830. private _dataFetched;
  110831. /**
  110832. * Initializes the physics gravitational field event
  110833. * @param _physicsHelper A physics helper
  110834. * @param _scene BabylonJS scene
  110835. * @param _origin The origin position of the gravitational field event
  110836. * @param _options The options for the vortex event
  110837. */
  110838. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  110839. /**
  110840. * Returns the data related to the gravitational field event (sphere).
  110841. * @returns A gravitational field event
  110842. */
  110843. getData(): PhysicsGravitationalFieldEventData;
  110844. /**
  110845. * Enables the gravitational field.
  110846. */
  110847. enable(): void;
  110848. /**
  110849. * Disables the gravitational field.
  110850. */
  110851. disable(): void;
  110852. /**
  110853. * Disposes the sphere.
  110854. * @param force The force to dispose from the gravitational field event
  110855. */
  110856. dispose(force?: boolean): void;
  110857. private _tick;
  110858. }
  110859. /**
  110860. * Represents a physics updraft event
  110861. */
  110862. class PhysicsUpdraftEvent {
  110863. private _scene;
  110864. private _origin;
  110865. private _options;
  110866. private _physicsEngine;
  110867. private _originTop;
  110868. private _originDirection;
  110869. private _tickCallback;
  110870. private _cylinder;
  110871. private _cylinderPosition;
  110872. private _dataFetched;
  110873. /**
  110874. * Initializes the physics updraft event
  110875. * @param _scene BabylonJS scene
  110876. * @param _origin The origin position of the updraft
  110877. * @param _options The options for the updraft event
  110878. */
  110879. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  110880. /**
  110881. * Returns the data related to the updraft event (cylinder).
  110882. * @returns A physics updraft event
  110883. */
  110884. getData(): PhysicsUpdraftEventData;
  110885. /**
  110886. * Enables the updraft.
  110887. */
  110888. enable(): void;
  110889. /**
  110890. * Disables the updraft.
  110891. */
  110892. disable(): void;
  110893. /**
  110894. * Disposes the cylinder.
  110895. * @param force Specifies if the updraft should be disposed by force
  110896. */
  110897. dispose(force?: boolean): void;
  110898. private getImpostorHitData;
  110899. private _tick;
  110900. /*** Helpers ***/
  110901. private _prepareCylinder;
  110902. private _intersectsWithCylinder;
  110903. }
  110904. /**
  110905. * Represents a physics vortex event
  110906. */
  110907. class PhysicsVortexEvent {
  110908. private _scene;
  110909. private _origin;
  110910. private _options;
  110911. private _physicsEngine;
  110912. private _originTop;
  110913. private _tickCallback;
  110914. private _cylinder;
  110915. private _cylinderPosition;
  110916. private _dataFetched;
  110917. /**
  110918. * Initializes the physics vortex event
  110919. * @param _scene The BabylonJS scene
  110920. * @param _origin The origin position of the vortex
  110921. * @param _options The options for the vortex event
  110922. */
  110923. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  110924. /**
  110925. * Returns the data related to the vortex event (cylinder).
  110926. * @returns The physics vortex event data
  110927. */
  110928. getData(): PhysicsVortexEventData;
  110929. /**
  110930. * Enables the vortex.
  110931. */
  110932. enable(): void;
  110933. /**
  110934. * Disables the cortex.
  110935. */
  110936. disable(): void;
  110937. /**
  110938. * Disposes the sphere.
  110939. * @param force
  110940. */
  110941. dispose(force?: boolean): void;
  110942. private getImpostorHitData;
  110943. private _tick;
  110944. /*** Helpers ***/
  110945. private _prepareCylinder;
  110946. private _intersectsWithCylinder;
  110947. }
  110948. /**
  110949. * Options fot the radial explosion event
  110950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110951. */
  110952. export class PhysicsRadialExplosionEventOptions {
  110953. /**
  110954. * The radius of the sphere for the radial explosion.
  110955. */
  110956. radius: number;
  110957. /**
  110958. * The strenth of the explosion.
  110959. */
  110960. strength: number;
  110961. /**
  110962. * The strenght of the force in correspondence to the distance of the affected object
  110963. */
  110964. falloff: PhysicsRadialImpulseFalloff;
  110965. /**
  110966. * Sphere options for the radial explosion.
  110967. */
  110968. sphere: {
  110969. segments: number;
  110970. diameter: number;
  110971. };
  110972. /**
  110973. * Sphere options for the radial explosion.
  110974. */
  110975. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  110976. }
  110977. /**
  110978. * Options fot the updraft event
  110979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110980. */
  110981. export class PhysicsUpdraftEventOptions {
  110982. /**
  110983. * The radius of the cylinder for the vortex
  110984. */
  110985. radius: number;
  110986. /**
  110987. * The strenth of the updraft.
  110988. */
  110989. strength: number;
  110990. /**
  110991. * The height of the cylinder for the updraft.
  110992. */
  110993. height: number;
  110994. /**
  110995. * The mode for the the updraft.
  110996. */
  110997. updraftMode: PhysicsUpdraftMode;
  110998. }
  110999. /**
  111000. * Options fot the vortex event
  111001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111002. */
  111003. export class PhysicsVortexEventOptions {
  111004. /**
  111005. * The radius of the cylinder for the vortex
  111006. */
  111007. radius: number;
  111008. /**
  111009. * The strenth of the vortex.
  111010. */
  111011. strength: number;
  111012. /**
  111013. * The height of the cylinder for the vortex.
  111014. */
  111015. height: number;
  111016. /**
  111017. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  111018. */
  111019. centripetalForceThreshold: number;
  111020. /**
  111021. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  111022. */
  111023. centripetalForceMultiplier: number;
  111024. /**
  111025. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  111026. */
  111027. centrifugalForceMultiplier: number;
  111028. /**
  111029. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  111030. */
  111031. updraftForceMultiplier: number;
  111032. }
  111033. /**
  111034. * The strenght of the force in correspondence to the distance of the affected object
  111035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111036. */
  111037. export enum PhysicsRadialImpulseFalloff {
  111038. /** Defines that impulse is constant in strength across it's whole radius */
  111039. Constant = 0,
  111040. /** Defines that impulse gets weaker if it's further from the origin */
  111041. Linear = 1
  111042. }
  111043. /**
  111044. * The strength of the force in correspondence to the distance of the affected object
  111045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111046. */
  111047. export enum PhysicsUpdraftMode {
  111048. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  111049. Center = 0,
  111050. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  111051. Perpendicular = 1
  111052. }
  111053. /**
  111054. * Interface for a physics hit data
  111055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111056. */
  111057. export interface PhysicsHitData {
  111058. /**
  111059. * The force applied at the contact point
  111060. */
  111061. force: Vector3;
  111062. /**
  111063. * The contact point
  111064. */
  111065. contactPoint: Vector3;
  111066. /**
  111067. * The distance from the origin to the contact point
  111068. */
  111069. distanceFromOrigin: number;
  111070. }
  111071. /**
  111072. * Interface for radial explosion event data
  111073. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111074. */
  111075. export interface PhysicsRadialExplosionEventData {
  111076. /**
  111077. * A sphere used for the radial explosion event
  111078. */
  111079. sphere: Mesh;
  111080. }
  111081. /**
  111082. * Interface for gravitational field event data
  111083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111084. */
  111085. export interface PhysicsGravitationalFieldEventData {
  111086. /**
  111087. * A sphere mesh used for the gravitational field event
  111088. */
  111089. sphere: Mesh;
  111090. }
  111091. /**
  111092. * Interface for updraft event data
  111093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111094. */
  111095. export interface PhysicsUpdraftEventData {
  111096. /**
  111097. * A cylinder used for the updraft event
  111098. */
  111099. cylinder: Mesh;
  111100. }
  111101. /**
  111102. * Interface for vortex event data
  111103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111104. */
  111105. export interface PhysicsVortexEventData {
  111106. /**
  111107. * A cylinder used for the vortex event
  111108. */
  111109. cylinder: Mesh;
  111110. }
  111111. /**
  111112. * Interface for an affected physics impostor
  111113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111114. */
  111115. export interface PhysicsAffectedImpostorWithData {
  111116. /**
  111117. * The impostor affected by the effect
  111118. */
  111119. impostor: PhysicsImpostor;
  111120. /**
  111121. * The data about the hit/horce from the explosion
  111122. */
  111123. hitData: PhysicsHitData;
  111124. }
  111125. }
  111126. declare module BABYLON {
  111127. /** @hidden */
  111128. export var blackAndWhitePixelShader: {
  111129. name: string;
  111130. shader: string;
  111131. };
  111132. }
  111133. declare module BABYLON {
  111134. /**
  111135. * Post process used to render in black and white
  111136. */
  111137. export class BlackAndWhitePostProcess extends PostProcess {
  111138. /**
  111139. * Linear about to convert he result to black and white (default: 1)
  111140. */
  111141. degree: number;
  111142. /**
  111143. * Creates a black and white post process
  111144. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  111145. * @param name The name of the effect.
  111146. * @param options The required width/height ratio to downsize to before computing the render pass.
  111147. * @param camera The camera to apply the render pass to.
  111148. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111149. * @param engine The engine which the post process will be applied. (default: current engine)
  111150. * @param reusable If the post process can be reused on the same frame. (default: false)
  111151. */
  111152. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111153. }
  111154. }
  111155. declare module BABYLON {
  111156. /**
  111157. * This represents a set of one or more post processes in Babylon.
  111158. * A post process can be used to apply a shader to a texture after it is rendered.
  111159. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111160. */
  111161. export class PostProcessRenderEffect {
  111162. private _postProcesses;
  111163. private _getPostProcesses;
  111164. private _singleInstance;
  111165. private _cameras;
  111166. private _indicesForCamera;
  111167. /**
  111168. * Name of the effect
  111169. * @hidden
  111170. */
  111171. _name: string;
  111172. /**
  111173. * Instantiates a post process render effect.
  111174. * A post process can be used to apply a shader to a texture after it is rendered.
  111175. * @param engine The engine the effect is tied to
  111176. * @param name The name of the effect
  111177. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  111178. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  111179. */
  111180. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  111181. /**
  111182. * Checks if all the post processes in the effect are supported.
  111183. */
  111184. readonly isSupported: boolean;
  111185. /**
  111186. * Updates the current state of the effect
  111187. * @hidden
  111188. */
  111189. _update(): void;
  111190. /**
  111191. * Attaches the effect on cameras
  111192. * @param cameras The camera to attach to.
  111193. * @hidden
  111194. */
  111195. _attachCameras(cameras: Camera): void;
  111196. /**
  111197. * Attaches the effect on cameras
  111198. * @param cameras The camera to attach to.
  111199. * @hidden
  111200. */
  111201. _attachCameras(cameras: Camera[]): void;
  111202. /**
  111203. * Detatches the effect on cameras
  111204. * @param cameras The camera to detatch from.
  111205. * @hidden
  111206. */
  111207. _detachCameras(cameras: Camera): void;
  111208. /**
  111209. * Detatches the effect on cameras
  111210. * @param cameras The camera to detatch from.
  111211. * @hidden
  111212. */
  111213. _detachCameras(cameras: Camera[]): void;
  111214. /**
  111215. * Enables the effect on given cameras
  111216. * @param cameras The camera to enable.
  111217. * @hidden
  111218. */
  111219. _enable(cameras: Camera): void;
  111220. /**
  111221. * Enables the effect on given cameras
  111222. * @param cameras The camera to enable.
  111223. * @hidden
  111224. */
  111225. _enable(cameras: Nullable<Camera[]>): void;
  111226. /**
  111227. * Disables the effect on the given cameras
  111228. * @param cameras The camera to disable.
  111229. * @hidden
  111230. */
  111231. _disable(cameras: Camera): void;
  111232. /**
  111233. * Disables the effect on the given cameras
  111234. * @param cameras The camera to disable.
  111235. * @hidden
  111236. */
  111237. _disable(cameras: Nullable<Camera[]>): void;
  111238. /**
  111239. * Gets a list of the post processes contained in the effect.
  111240. * @param camera The camera to get the post processes on.
  111241. * @returns The list of the post processes in the effect.
  111242. */
  111243. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  111244. }
  111245. }
  111246. declare module BABYLON {
  111247. /** @hidden */
  111248. export var extractHighlightsPixelShader: {
  111249. name: string;
  111250. shader: string;
  111251. };
  111252. }
  111253. declare module BABYLON {
  111254. /**
  111255. * 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.
  111256. */
  111257. export class ExtractHighlightsPostProcess extends PostProcess {
  111258. /**
  111259. * The luminance threshold, pixels below this value will be set to black.
  111260. */
  111261. threshold: number;
  111262. /** @hidden */
  111263. _exposure: number;
  111264. /**
  111265. * Post process which has the input texture to be used when performing highlight extraction
  111266. * @hidden
  111267. */
  111268. _inputPostProcess: Nullable<PostProcess>;
  111269. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111270. }
  111271. }
  111272. declare module BABYLON {
  111273. /** @hidden */
  111274. export var bloomMergePixelShader: {
  111275. name: string;
  111276. shader: string;
  111277. };
  111278. }
  111279. declare module BABYLON {
  111280. /**
  111281. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111282. */
  111283. export class BloomMergePostProcess extends PostProcess {
  111284. /** Weight of the bloom to be added to the original input. */
  111285. weight: number;
  111286. /**
  111287. * Creates a new instance of @see BloomMergePostProcess
  111288. * @param name The name of the effect.
  111289. * @param originalFromInput Post process which's input will be used for the merge.
  111290. * @param blurred Blurred highlights post process which's output will be used.
  111291. * @param weight Weight of the bloom to be added to the original input.
  111292. * @param options The required width/height ratio to downsize to before computing the render pass.
  111293. * @param camera The camera to apply the render pass to.
  111294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111295. * @param engine The engine which the post process will be applied. (default: current engine)
  111296. * @param reusable If the post process can be reused on the same frame. (default: false)
  111297. * @param textureType Type of textures used when performing the post process. (default: 0)
  111298. * @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)
  111299. */
  111300. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  111301. /** Weight of the bloom to be added to the original input. */
  111302. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111303. }
  111304. }
  111305. declare module BABYLON {
  111306. /**
  111307. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  111308. */
  111309. export class BloomEffect extends PostProcessRenderEffect {
  111310. private bloomScale;
  111311. /**
  111312. * @hidden Internal
  111313. */
  111314. _effects: Array<PostProcess>;
  111315. /**
  111316. * @hidden Internal
  111317. */
  111318. _downscale: ExtractHighlightsPostProcess;
  111319. private _blurX;
  111320. private _blurY;
  111321. private _merge;
  111322. /**
  111323. * The luminance threshold to find bright areas of the image to bloom.
  111324. */
  111325. threshold: number;
  111326. /**
  111327. * The strength of the bloom.
  111328. */
  111329. weight: number;
  111330. /**
  111331. * Specifies the size of the bloom blur kernel, relative to the final output size
  111332. */
  111333. kernel: number;
  111334. /**
  111335. * Creates a new instance of @see BloomEffect
  111336. * @param scene The scene the effect belongs to.
  111337. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  111338. * @param bloomKernel The size of the kernel to be used when applying the blur.
  111339. * @param bloomWeight The the strength of bloom.
  111340. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111341. * @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)
  111342. */
  111343. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  111344. /**
  111345. * Disposes each of the internal effects for a given camera.
  111346. * @param camera The camera to dispose the effect on.
  111347. */
  111348. disposeEffects(camera: Camera): void;
  111349. /**
  111350. * @hidden Internal
  111351. */
  111352. _updateEffects(): void;
  111353. /**
  111354. * Internal
  111355. * @returns if all the contained post processes are ready.
  111356. * @hidden
  111357. */
  111358. _isReady(): boolean;
  111359. }
  111360. }
  111361. declare module BABYLON {
  111362. /** @hidden */
  111363. export var chromaticAberrationPixelShader: {
  111364. name: string;
  111365. shader: string;
  111366. };
  111367. }
  111368. declare module BABYLON {
  111369. /**
  111370. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  111371. */
  111372. export class ChromaticAberrationPostProcess extends PostProcess {
  111373. /**
  111374. * The amount of seperation of rgb channels (default: 30)
  111375. */
  111376. aberrationAmount: number;
  111377. /**
  111378. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  111379. */
  111380. radialIntensity: number;
  111381. /**
  111382. * 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))
  111383. */
  111384. direction: Vector2;
  111385. /**
  111386. * 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))
  111387. */
  111388. centerPosition: Vector2;
  111389. /**
  111390. * Creates a new instance ChromaticAberrationPostProcess
  111391. * @param name The name of the effect.
  111392. * @param screenWidth The width of the screen to apply the effect on.
  111393. * @param screenHeight The height of the screen to apply the effect on.
  111394. * @param options The required width/height ratio to downsize to before computing the render pass.
  111395. * @param camera The camera to apply the render pass to.
  111396. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111397. * @param engine The engine which the post process will be applied. (default: current engine)
  111398. * @param reusable If the post process can be reused on the same frame. (default: false)
  111399. * @param textureType Type of textures used when performing the post process. (default: 0)
  111400. * @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)
  111401. */
  111402. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111403. }
  111404. }
  111405. declare module BABYLON {
  111406. /** @hidden */
  111407. export var circleOfConfusionPixelShader: {
  111408. name: string;
  111409. shader: string;
  111410. };
  111411. }
  111412. declare module BABYLON {
  111413. /**
  111414. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  111415. */
  111416. export class CircleOfConfusionPostProcess extends PostProcess {
  111417. /**
  111418. * 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.
  111419. */
  111420. lensSize: number;
  111421. /**
  111422. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111423. */
  111424. fStop: number;
  111425. /**
  111426. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111427. */
  111428. focusDistance: number;
  111429. /**
  111430. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  111431. */
  111432. focalLength: number;
  111433. private _depthTexture;
  111434. /**
  111435. * Creates a new instance CircleOfConfusionPostProcess
  111436. * @param name The name of the effect.
  111437. * @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.
  111438. * @param options The required width/height ratio to downsize to before computing the render pass.
  111439. * @param camera The camera to apply the render pass to.
  111440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111441. * @param engine The engine which the post process will be applied. (default: current engine)
  111442. * @param reusable If the post process can be reused on the same frame. (default: false)
  111443. * @param textureType Type of textures used when performing the post process. (default: 0)
  111444. * @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)
  111445. */
  111446. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111447. /**
  111448. * 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.
  111449. */
  111450. depthTexture: RenderTargetTexture;
  111451. }
  111452. }
  111453. declare module BABYLON {
  111454. /** @hidden */
  111455. export var colorCorrectionPixelShader: {
  111456. name: string;
  111457. shader: string;
  111458. };
  111459. }
  111460. declare module BABYLON {
  111461. /**
  111462. *
  111463. * This post-process allows the modification of rendered colors by using
  111464. * a 'look-up table' (LUT). This effect is also called Color Grading.
  111465. *
  111466. * The object needs to be provided an url to a texture containing the color
  111467. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  111468. * Use an image editing software to tweak the LUT to match your needs.
  111469. *
  111470. * For an example of a color LUT, see here:
  111471. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  111472. * For explanations on color grading, see here:
  111473. * @see http://udn.epicgames.com/Three/ColorGrading.html
  111474. *
  111475. */
  111476. export class ColorCorrectionPostProcess extends PostProcess {
  111477. private _colorTableTexture;
  111478. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111479. }
  111480. }
  111481. declare module BABYLON {
  111482. /** @hidden */
  111483. export var convolutionPixelShader: {
  111484. name: string;
  111485. shader: string;
  111486. };
  111487. }
  111488. declare module BABYLON {
  111489. /**
  111490. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  111491. * input texture to perform effects such as edge detection or sharpening
  111492. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  111493. */
  111494. export class ConvolutionPostProcess extends PostProcess {
  111495. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111496. kernel: number[];
  111497. /**
  111498. * Creates a new instance ConvolutionPostProcess
  111499. * @param name The name of the effect.
  111500. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  111501. * @param options The required width/height ratio to downsize to before computing the render pass.
  111502. * @param camera The camera to apply the render pass to.
  111503. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111504. * @param engine The engine which the post process will be applied. (default: current engine)
  111505. * @param reusable If the post process can be reused on the same frame. (default: false)
  111506. * @param textureType Type of textures used when performing the post process. (default: 0)
  111507. */
  111508. constructor(name: string,
  111509. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111510. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111511. /**
  111512. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111513. */
  111514. static EdgeDetect0Kernel: number[];
  111515. /**
  111516. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111517. */
  111518. static EdgeDetect1Kernel: number[];
  111519. /**
  111520. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111521. */
  111522. static EdgeDetect2Kernel: number[];
  111523. /**
  111524. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111525. */
  111526. static SharpenKernel: number[];
  111527. /**
  111528. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111529. */
  111530. static EmbossKernel: number[];
  111531. /**
  111532. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111533. */
  111534. static GaussianKernel: number[];
  111535. }
  111536. }
  111537. declare module BABYLON {
  111538. /**
  111539. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  111540. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  111541. * based on samples that have a large difference in distance than the center pixel.
  111542. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  111543. */
  111544. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  111545. direction: Vector2;
  111546. /**
  111547. * Creates a new instance CircleOfConfusionPostProcess
  111548. * @param name The name of the effect.
  111549. * @param scene The scene the effect belongs to.
  111550. * @param direction The direction the blur should be applied.
  111551. * @param kernel The size of the kernel used to blur.
  111552. * @param options The required width/height ratio to downsize to before computing the render pass.
  111553. * @param camera The camera to apply the render pass to.
  111554. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  111555. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  111556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111557. * @param engine The engine which the post process will be applied. (default: current engine)
  111558. * @param reusable If the post process can be reused on the same frame. (default: false)
  111559. * @param textureType Type of textures used when performing the post process. (default: 0)
  111560. * @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)
  111561. */
  111562. 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);
  111563. }
  111564. }
  111565. declare module BABYLON {
  111566. /** @hidden */
  111567. export var depthOfFieldMergePixelShader: {
  111568. name: string;
  111569. shader: string;
  111570. };
  111571. }
  111572. declare module BABYLON {
  111573. /**
  111574. * Options to be set when merging outputs from the default pipeline.
  111575. */
  111576. export class DepthOfFieldMergePostProcessOptions {
  111577. /**
  111578. * The original image to merge on top of
  111579. */
  111580. originalFromInput: PostProcess;
  111581. /**
  111582. * Parameters to perform the merge of the depth of field effect
  111583. */
  111584. depthOfField?: {
  111585. circleOfConfusion: PostProcess;
  111586. blurSteps: Array<PostProcess>;
  111587. };
  111588. /**
  111589. * Parameters to perform the merge of bloom effect
  111590. */
  111591. bloom?: {
  111592. blurred: PostProcess;
  111593. weight: number;
  111594. };
  111595. }
  111596. /**
  111597. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111598. */
  111599. export class DepthOfFieldMergePostProcess extends PostProcess {
  111600. private blurSteps;
  111601. /**
  111602. * Creates a new instance of DepthOfFieldMergePostProcess
  111603. * @param name The name of the effect.
  111604. * @param originalFromInput Post process which's input will be used for the merge.
  111605. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  111606. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  111607. * @param options The required width/height ratio to downsize to before computing the render pass.
  111608. * @param camera The camera to apply the render pass to.
  111609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111610. * @param engine The engine which the post process will be applied. (default: current engine)
  111611. * @param reusable If the post process can be reused on the same frame. (default: false)
  111612. * @param textureType Type of textures used when performing the post process. (default: 0)
  111613. * @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)
  111614. */
  111615. 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);
  111616. /**
  111617. * Updates the effect with the current post process compile time values and recompiles the shader.
  111618. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  111619. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  111620. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  111621. * @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
  111622. * @param onCompiled Called when the shader has been compiled.
  111623. * @param onError Called if there is an error when compiling a shader.
  111624. */
  111625. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  111626. }
  111627. }
  111628. declare module BABYLON {
  111629. /**
  111630. * Specifies the level of max blur that should be applied when using the depth of field effect
  111631. */
  111632. export enum DepthOfFieldEffectBlurLevel {
  111633. /**
  111634. * Subtle blur
  111635. */
  111636. Low = 0,
  111637. /**
  111638. * Medium blur
  111639. */
  111640. Medium = 1,
  111641. /**
  111642. * Large blur
  111643. */
  111644. High = 2
  111645. }
  111646. /**
  111647. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  111648. */
  111649. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  111650. private _circleOfConfusion;
  111651. /**
  111652. * @hidden Internal, blurs from high to low
  111653. */
  111654. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  111655. private _depthOfFieldBlurY;
  111656. private _dofMerge;
  111657. /**
  111658. * @hidden Internal post processes in depth of field effect
  111659. */
  111660. _effects: Array<PostProcess>;
  111661. /**
  111662. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  111663. */
  111664. focalLength: number;
  111665. /**
  111666. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111667. */
  111668. fStop: number;
  111669. /**
  111670. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111671. */
  111672. focusDistance: number;
  111673. /**
  111674. * 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.
  111675. */
  111676. lensSize: number;
  111677. /**
  111678. * Creates a new instance DepthOfFieldEffect
  111679. * @param scene The scene the effect belongs to.
  111680. * @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.
  111681. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111682. * @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)
  111683. */
  111684. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  111685. /**
  111686. * 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.
  111687. */
  111688. depthTexture: RenderTargetTexture;
  111689. /**
  111690. * Disposes each of the internal effects for a given camera.
  111691. * @param camera The camera to dispose the effect on.
  111692. */
  111693. disposeEffects(camera: Camera): void;
  111694. /**
  111695. * @hidden Internal
  111696. */
  111697. _updateEffects(): void;
  111698. /**
  111699. * Internal
  111700. * @returns if all the contained post processes are ready.
  111701. * @hidden
  111702. */
  111703. _isReady(): boolean;
  111704. }
  111705. }
  111706. declare module BABYLON {
  111707. /** @hidden */
  111708. export var displayPassPixelShader: {
  111709. name: string;
  111710. shader: string;
  111711. };
  111712. }
  111713. declare module BABYLON {
  111714. /**
  111715. * DisplayPassPostProcess which produces an output the same as it's input
  111716. */
  111717. export class DisplayPassPostProcess extends PostProcess {
  111718. /**
  111719. * Creates the DisplayPassPostProcess
  111720. * @param name The name of the effect.
  111721. * @param options The required width/height ratio to downsize to before computing the render pass.
  111722. * @param camera The camera to apply the render pass to.
  111723. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111724. * @param engine The engine which the post process will be applied. (default: current engine)
  111725. * @param reusable If the post process can be reused on the same frame. (default: false)
  111726. */
  111727. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111728. }
  111729. }
  111730. declare module BABYLON {
  111731. /** @hidden */
  111732. export var filterPixelShader: {
  111733. name: string;
  111734. shader: string;
  111735. };
  111736. }
  111737. declare module BABYLON {
  111738. /**
  111739. * Applies a kernel filter to the image
  111740. */
  111741. export class FilterPostProcess extends PostProcess {
  111742. /** The matrix to be applied to the image */
  111743. kernelMatrix: Matrix;
  111744. /**
  111745. *
  111746. * @param name The name of the effect.
  111747. * @param kernelMatrix The matrix to be applied to the image
  111748. * @param options The required width/height ratio to downsize to before computing the render pass.
  111749. * @param camera The camera to apply the render pass to.
  111750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111751. * @param engine The engine which the post process will be applied. (default: current engine)
  111752. * @param reusable If the post process can be reused on the same frame. (default: false)
  111753. */
  111754. constructor(name: string,
  111755. /** The matrix to be applied to the image */
  111756. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111757. }
  111758. }
  111759. declare module BABYLON {
  111760. /** @hidden */
  111761. export var fxaaPixelShader: {
  111762. name: string;
  111763. shader: string;
  111764. };
  111765. }
  111766. declare module BABYLON {
  111767. /** @hidden */
  111768. export var fxaaVertexShader: {
  111769. name: string;
  111770. shader: string;
  111771. };
  111772. }
  111773. declare module BABYLON {
  111774. /**
  111775. * Fxaa post process
  111776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  111777. */
  111778. export class FxaaPostProcess extends PostProcess {
  111779. /** @hidden */
  111780. texelWidth: number;
  111781. /** @hidden */
  111782. texelHeight: number;
  111783. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111784. private _getDefines;
  111785. }
  111786. }
  111787. declare module BABYLON {
  111788. /** @hidden */
  111789. export var grainPixelShader: {
  111790. name: string;
  111791. shader: string;
  111792. };
  111793. }
  111794. declare module BABYLON {
  111795. /**
  111796. * The GrainPostProcess adds noise to the image at mid luminance levels
  111797. */
  111798. export class GrainPostProcess extends PostProcess {
  111799. /**
  111800. * The intensity of the grain added (default: 30)
  111801. */
  111802. intensity: number;
  111803. /**
  111804. * If the grain should be randomized on every frame
  111805. */
  111806. animated: boolean;
  111807. /**
  111808. * Creates a new instance of @see GrainPostProcess
  111809. * @param name The name of the effect.
  111810. * @param options The required width/height ratio to downsize to before computing the render pass.
  111811. * @param camera The camera to apply the render pass to.
  111812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111813. * @param engine The engine which the post process will be applied. (default: current engine)
  111814. * @param reusable If the post process can be reused on the same frame. (default: false)
  111815. * @param textureType Type of textures used when performing the post process. (default: 0)
  111816. * @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)
  111817. */
  111818. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111819. }
  111820. }
  111821. declare module BABYLON {
  111822. /** @hidden */
  111823. export var highlightsPixelShader: {
  111824. name: string;
  111825. shader: string;
  111826. };
  111827. }
  111828. declare module BABYLON {
  111829. /**
  111830. * Extracts highlights from the image
  111831. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111832. */
  111833. export class HighlightsPostProcess extends PostProcess {
  111834. /**
  111835. * Extracts highlights from the image
  111836. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111837. * @param name The name of the effect.
  111838. * @param options The required width/height ratio to downsize to before computing the render pass.
  111839. * @param camera The camera to apply the render pass to.
  111840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111841. * @param engine The engine which the post process will be applied. (default: current engine)
  111842. * @param reusable If the post process can be reused on the same frame. (default: false)
  111843. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  111844. */
  111845. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111846. }
  111847. }
  111848. declare module BABYLON {
  111849. /** @hidden */
  111850. export var mrtFragmentDeclaration: {
  111851. name: string;
  111852. shader: string;
  111853. };
  111854. }
  111855. declare module BABYLON {
  111856. /** @hidden */
  111857. export var geometryPixelShader: {
  111858. name: string;
  111859. shader: string;
  111860. };
  111861. }
  111862. declare module BABYLON {
  111863. /** @hidden */
  111864. export var geometryVertexShader: {
  111865. name: string;
  111866. shader: string;
  111867. };
  111868. }
  111869. declare module BABYLON {
  111870. /**
  111871. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  111872. */
  111873. export class GeometryBufferRenderer {
  111874. /**
  111875. * Constant used to retrieve the position texture index in the G-Buffer textures array
  111876. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  111877. */
  111878. static readonly POSITION_TEXTURE_TYPE: number;
  111879. /**
  111880. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  111881. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  111882. */
  111883. static readonly VELOCITY_TEXTURE_TYPE: number;
  111884. /**
  111885. * Dictionary used to store the previous transformation matrices of each rendered mesh
  111886. * in order to compute objects velocities when enableVelocity is set to "true"
  111887. * @hidden
  111888. */
  111889. _previousTransformationMatrices: {
  111890. [index: number]: Matrix;
  111891. };
  111892. private _scene;
  111893. private _multiRenderTarget;
  111894. private _ratio;
  111895. private _enablePosition;
  111896. private _enableVelocity;
  111897. private _positionIndex;
  111898. private _velocityIndex;
  111899. protected _effect: Effect;
  111900. protected _cachedDefines: string;
  111901. /**
  111902. * Set the render list (meshes to be rendered) used in the G buffer.
  111903. */
  111904. renderList: Mesh[];
  111905. /**
  111906. * Gets wether or not G buffer are supported by the running hardware.
  111907. * This requires draw buffer supports
  111908. */
  111909. readonly isSupported: boolean;
  111910. /**
  111911. * Returns the index of the given texture type in the G-Buffer textures array
  111912. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  111913. * @returns the index of the given texture type in the G-Buffer textures array
  111914. */
  111915. getTextureIndex(textureType: number): number;
  111916. /**
  111917. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  111918. */
  111919. /**
  111920. * Sets whether or not objects positions are enabled for the G buffer.
  111921. */
  111922. enablePosition: boolean;
  111923. /**
  111924. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  111925. */
  111926. /**
  111927. * Sets wether or not objects velocities are enabled for the G buffer.
  111928. */
  111929. enableVelocity: boolean;
  111930. /**
  111931. * Gets the scene associated with the buffer.
  111932. */
  111933. readonly scene: Scene;
  111934. /**
  111935. * Gets the ratio used by the buffer during its creation.
  111936. * How big is the buffer related to the main canvas.
  111937. */
  111938. readonly ratio: number;
  111939. /** @hidden */
  111940. static _SceneComponentInitialization: (scene: Scene) => void;
  111941. /**
  111942. * Creates a new G Buffer for the scene
  111943. * @param scene The scene the buffer belongs to
  111944. * @param ratio How big is the buffer related to the main canvas.
  111945. */
  111946. constructor(scene: Scene, ratio?: number);
  111947. /**
  111948. * Checks wether everything is ready to render a submesh to the G buffer.
  111949. * @param subMesh the submesh to check readiness for
  111950. * @param useInstances is the mesh drawn using instance or not
  111951. * @returns true if ready otherwise false
  111952. */
  111953. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111954. /**
  111955. * Gets the current underlying G Buffer.
  111956. * @returns the buffer
  111957. */
  111958. getGBuffer(): MultiRenderTarget;
  111959. /**
  111960. * Gets the number of samples used to render the buffer (anti aliasing).
  111961. */
  111962. /**
  111963. * Sets the number of samples used to render the buffer (anti aliasing).
  111964. */
  111965. samples: number;
  111966. /**
  111967. * Disposes the renderer and frees up associated resources.
  111968. */
  111969. dispose(): void;
  111970. protected _createRenderTargets(): void;
  111971. }
  111972. }
  111973. declare module BABYLON {
  111974. interface Scene {
  111975. /** @hidden (Backing field) */
  111976. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  111977. /**
  111978. * Gets or Sets the current geometry buffer associated to the scene.
  111979. */
  111980. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  111981. /**
  111982. * Enables a GeometryBufferRender and associates it with the scene
  111983. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  111984. * @returns the GeometryBufferRenderer
  111985. */
  111986. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  111987. /**
  111988. * Disables the GeometryBufferRender associated with the scene
  111989. */
  111990. disableGeometryBufferRenderer(): void;
  111991. }
  111992. /**
  111993. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  111994. * in several rendering techniques.
  111995. */
  111996. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  111997. /**
  111998. * The component name helpful to identify the component in the list of scene components.
  111999. */
  112000. readonly name: string;
  112001. /**
  112002. * The scene the component belongs to.
  112003. */
  112004. scene: Scene;
  112005. /**
  112006. * Creates a new instance of the component for the given scene
  112007. * @param scene Defines the scene to register the component in
  112008. */
  112009. constructor(scene: Scene);
  112010. /**
  112011. * Registers the component in a given scene
  112012. */
  112013. register(): void;
  112014. /**
  112015. * Rebuilds the elements related to this component in case of
  112016. * context lost for instance.
  112017. */
  112018. rebuild(): void;
  112019. /**
  112020. * Disposes the component and the associated ressources
  112021. */
  112022. dispose(): void;
  112023. private _gatherRenderTargets;
  112024. }
  112025. }
  112026. declare module BABYLON {
  112027. /** @hidden */
  112028. export var motionBlurPixelShader: {
  112029. name: string;
  112030. shader: string;
  112031. };
  112032. }
  112033. declare module BABYLON {
  112034. /**
  112035. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  112036. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  112037. * As an example, all you have to do is to create the post-process:
  112038. * var mb = new BABYLON.MotionBlurPostProcess(
  112039. * 'mb', // The name of the effect.
  112040. * scene, // The scene containing the objects to blur according to their velocity.
  112041. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  112042. * camera // The camera to apply the render pass to.
  112043. * );
  112044. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  112045. */
  112046. export class MotionBlurPostProcess extends PostProcess {
  112047. /**
  112048. * Defines how much the image is blurred by the movement. Default value is equal to 1
  112049. */
  112050. motionStrength: number;
  112051. /**
  112052. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  112053. */
  112054. /**
  112055. * Sets the number of iterations to be used for motion blur quality
  112056. */
  112057. motionBlurSamples: number;
  112058. private _motionBlurSamples;
  112059. private _geometryBufferRenderer;
  112060. /**
  112061. * Creates a new instance MotionBlurPostProcess
  112062. * @param name The name of the effect.
  112063. * @param scene The scene containing the objects to blur according to their velocity.
  112064. * @param options The required width/height ratio to downsize to before computing the render pass.
  112065. * @param camera The camera to apply the render pass to.
  112066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112067. * @param engine The engine which the post process will be applied. (default: current engine)
  112068. * @param reusable If the post process can be reused on the same frame. (default: false)
  112069. * @param textureType Type of textures used when performing the post process. (default: 0)
  112070. * @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)
  112071. */
  112072. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112073. /**
  112074. * Disposes the post process.
  112075. * @param camera The camera to dispose the post process on.
  112076. */
  112077. dispose(camera?: Camera): void;
  112078. }
  112079. }
  112080. declare module BABYLON {
  112081. /** @hidden */
  112082. export var refractionPixelShader: {
  112083. name: string;
  112084. shader: string;
  112085. };
  112086. }
  112087. declare module BABYLON {
  112088. /**
  112089. * Post process which applies a refractin texture
  112090. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112091. */
  112092. export class RefractionPostProcess extends PostProcess {
  112093. /** the base color of the refraction (used to taint the rendering) */
  112094. color: Color3;
  112095. /** simulated refraction depth */
  112096. depth: number;
  112097. /** the coefficient of the base color (0 to remove base color tainting) */
  112098. colorLevel: number;
  112099. private _refTexture;
  112100. private _ownRefractionTexture;
  112101. /**
  112102. * Gets or sets the refraction texture
  112103. * Please note that you are responsible for disposing the texture if you set it manually
  112104. */
  112105. refractionTexture: Texture;
  112106. /**
  112107. * Initializes the RefractionPostProcess
  112108. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112109. * @param name The name of the effect.
  112110. * @param refractionTextureUrl Url of the refraction texture to use
  112111. * @param color the base color of the refraction (used to taint the rendering)
  112112. * @param depth simulated refraction depth
  112113. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  112114. * @param camera The camera to apply the render pass to.
  112115. * @param options The required width/height ratio to downsize to before computing the render pass.
  112116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112117. * @param engine The engine which the post process will be applied. (default: current engine)
  112118. * @param reusable If the post process can be reused on the same frame. (default: false)
  112119. */
  112120. constructor(name: string, refractionTextureUrl: string,
  112121. /** the base color of the refraction (used to taint the rendering) */
  112122. color: Color3,
  112123. /** simulated refraction depth */
  112124. depth: number,
  112125. /** the coefficient of the base color (0 to remove base color tainting) */
  112126. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112127. /**
  112128. * Disposes of the post process
  112129. * @param camera Camera to dispose post process on
  112130. */
  112131. dispose(camera: Camera): void;
  112132. }
  112133. }
  112134. declare module BABYLON {
  112135. /** @hidden */
  112136. export var sharpenPixelShader: {
  112137. name: string;
  112138. shader: string;
  112139. };
  112140. }
  112141. declare module BABYLON {
  112142. /**
  112143. * The SharpenPostProcess applies a sharpen kernel to every pixel
  112144. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112145. */
  112146. export class SharpenPostProcess extends PostProcess {
  112147. /**
  112148. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  112149. */
  112150. colorAmount: number;
  112151. /**
  112152. * How much sharpness should be applied (default: 0.3)
  112153. */
  112154. edgeAmount: number;
  112155. /**
  112156. * Creates a new instance ConvolutionPostProcess
  112157. * @param name The name of the effect.
  112158. * @param options The required width/height ratio to downsize to before computing the render pass.
  112159. * @param camera The camera to apply the render pass to.
  112160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112161. * @param engine The engine which the post process will be applied. (default: current engine)
  112162. * @param reusable If the post process can be reused on the same frame. (default: false)
  112163. * @param textureType Type of textures used when performing the post process. (default: 0)
  112164. * @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)
  112165. */
  112166. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112167. }
  112168. }
  112169. declare module BABYLON {
  112170. /**
  112171. * PostProcessRenderPipeline
  112172. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112173. */
  112174. export class PostProcessRenderPipeline {
  112175. private engine;
  112176. private _renderEffects;
  112177. private _renderEffectsForIsolatedPass;
  112178. /**
  112179. * List of inspectable custom properties (used by the Inspector)
  112180. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112181. */
  112182. inspectableCustomProperties: IInspectable[];
  112183. /**
  112184. * @hidden
  112185. */
  112186. protected _cameras: Camera[];
  112187. /** @hidden */
  112188. _name: string;
  112189. /**
  112190. * Gets pipeline name
  112191. */
  112192. readonly name: string;
  112193. /**
  112194. * Initializes a PostProcessRenderPipeline
  112195. * @param engine engine to add the pipeline to
  112196. * @param name name of the pipeline
  112197. */
  112198. constructor(engine: Engine, name: string);
  112199. /**
  112200. * Gets the class name
  112201. * @returns "PostProcessRenderPipeline"
  112202. */
  112203. getClassName(): string;
  112204. /**
  112205. * If all the render effects in the pipeline are supported
  112206. */
  112207. readonly isSupported: boolean;
  112208. /**
  112209. * Adds an effect to the pipeline
  112210. * @param renderEffect the effect to add
  112211. */
  112212. addEffect(renderEffect: PostProcessRenderEffect): void;
  112213. /** @hidden */
  112214. _rebuild(): void;
  112215. /** @hidden */
  112216. _enableEffect(renderEffectName: string, cameras: Camera): void;
  112217. /** @hidden */
  112218. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  112219. /** @hidden */
  112220. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112221. /** @hidden */
  112222. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112223. /** @hidden */
  112224. _attachCameras(cameras: Camera, unique: boolean): void;
  112225. /** @hidden */
  112226. _attachCameras(cameras: Camera[], unique: boolean): void;
  112227. /** @hidden */
  112228. _detachCameras(cameras: Camera): void;
  112229. /** @hidden */
  112230. _detachCameras(cameras: Nullable<Camera[]>): void;
  112231. /** @hidden */
  112232. _update(): void;
  112233. /** @hidden */
  112234. _reset(): void;
  112235. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  112236. /**
  112237. * Disposes of the pipeline
  112238. */
  112239. dispose(): void;
  112240. }
  112241. }
  112242. declare module BABYLON {
  112243. /**
  112244. * PostProcessRenderPipelineManager class
  112245. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112246. */
  112247. export class PostProcessRenderPipelineManager {
  112248. private _renderPipelines;
  112249. /**
  112250. * Initializes a PostProcessRenderPipelineManager
  112251. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112252. */
  112253. constructor();
  112254. /**
  112255. * Gets the list of supported render pipelines
  112256. */
  112257. readonly supportedPipelines: PostProcessRenderPipeline[];
  112258. /**
  112259. * Adds a pipeline to the manager
  112260. * @param renderPipeline The pipeline to add
  112261. */
  112262. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  112263. /**
  112264. * Attaches a camera to the pipeline
  112265. * @param renderPipelineName The name of the pipeline to attach to
  112266. * @param cameras the camera to attach
  112267. * @param unique if the camera can be attached multiple times to the pipeline
  112268. */
  112269. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  112270. /**
  112271. * Detaches a camera from the pipeline
  112272. * @param renderPipelineName The name of the pipeline to detach from
  112273. * @param cameras the camera to detach
  112274. */
  112275. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  112276. /**
  112277. * Enables an effect by name on a pipeline
  112278. * @param renderPipelineName the name of the pipeline to enable the effect in
  112279. * @param renderEffectName the name of the effect to enable
  112280. * @param cameras the cameras that the effect should be enabled on
  112281. */
  112282. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112283. /**
  112284. * Disables an effect by name on a pipeline
  112285. * @param renderPipelineName the name of the pipeline to disable the effect in
  112286. * @param renderEffectName the name of the effect to disable
  112287. * @param cameras the cameras that the effect should be disabled on
  112288. */
  112289. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112290. /**
  112291. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  112292. */
  112293. update(): void;
  112294. /** @hidden */
  112295. _rebuild(): void;
  112296. /**
  112297. * Disposes of the manager and pipelines
  112298. */
  112299. dispose(): void;
  112300. }
  112301. }
  112302. declare module BABYLON {
  112303. interface Scene {
  112304. /** @hidden (Backing field) */
  112305. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112306. /**
  112307. * Gets the postprocess render pipeline manager
  112308. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112309. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112310. */
  112311. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112312. }
  112313. /**
  112314. * Defines the Render Pipeline scene component responsible to rendering pipelines
  112315. */
  112316. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  112317. /**
  112318. * The component name helpfull to identify the component in the list of scene components.
  112319. */
  112320. readonly name: string;
  112321. /**
  112322. * The scene the component belongs to.
  112323. */
  112324. scene: Scene;
  112325. /**
  112326. * Creates a new instance of the component for the given scene
  112327. * @param scene Defines the scene to register the component in
  112328. */
  112329. constructor(scene: Scene);
  112330. /**
  112331. * Registers the component in a given scene
  112332. */
  112333. register(): void;
  112334. /**
  112335. * Rebuilds the elements related to this component in case of
  112336. * context lost for instance.
  112337. */
  112338. rebuild(): void;
  112339. /**
  112340. * Disposes the component and the associated ressources
  112341. */
  112342. dispose(): void;
  112343. private _gatherRenderTargets;
  112344. }
  112345. }
  112346. declare module BABYLON {
  112347. /**
  112348. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  112349. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112350. */
  112351. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  112352. private _scene;
  112353. private _camerasToBeAttached;
  112354. /**
  112355. * ID of the sharpen post process,
  112356. */
  112357. private readonly SharpenPostProcessId;
  112358. /**
  112359. * @ignore
  112360. * ID of the image processing post process;
  112361. */
  112362. readonly ImageProcessingPostProcessId: string;
  112363. /**
  112364. * @ignore
  112365. * ID of the Fast Approximate Anti-Aliasing post process;
  112366. */
  112367. readonly FxaaPostProcessId: string;
  112368. /**
  112369. * ID of the chromatic aberration post process,
  112370. */
  112371. private readonly ChromaticAberrationPostProcessId;
  112372. /**
  112373. * ID of the grain post process
  112374. */
  112375. private readonly GrainPostProcessId;
  112376. /**
  112377. * Sharpen post process which will apply a sharpen convolution to enhance edges
  112378. */
  112379. sharpen: SharpenPostProcess;
  112380. private _sharpenEffect;
  112381. private bloom;
  112382. /**
  112383. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  112384. */
  112385. depthOfField: DepthOfFieldEffect;
  112386. /**
  112387. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  112388. */
  112389. fxaa: FxaaPostProcess;
  112390. /**
  112391. * Image post processing pass used to perform operations such as tone mapping or color grading.
  112392. */
  112393. imageProcessing: ImageProcessingPostProcess;
  112394. /**
  112395. * Chromatic aberration post process which will shift rgb colors in the image
  112396. */
  112397. chromaticAberration: ChromaticAberrationPostProcess;
  112398. private _chromaticAberrationEffect;
  112399. /**
  112400. * Grain post process which add noise to the image
  112401. */
  112402. grain: GrainPostProcess;
  112403. private _grainEffect;
  112404. /**
  112405. * Glow post process which adds a glow to emissive areas of the image
  112406. */
  112407. private _glowLayer;
  112408. /**
  112409. * Animations which can be used to tweak settings over a period of time
  112410. */
  112411. animations: Animation[];
  112412. private _imageProcessingConfigurationObserver;
  112413. private _sharpenEnabled;
  112414. private _bloomEnabled;
  112415. private _depthOfFieldEnabled;
  112416. private _depthOfFieldBlurLevel;
  112417. private _fxaaEnabled;
  112418. private _imageProcessingEnabled;
  112419. private _defaultPipelineTextureType;
  112420. private _bloomScale;
  112421. private _chromaticAberrationEnabled;
  112422. private _grainEnabled;
  112423. private _buildAllowed;
  112424. /**
  112425. * Gets active scene
  112426. */
  112427. readonly scene: Scene;
  112428. /**
  112429. * Enable or disable the sharpen process from the pipeline
  112430. */
  112431. sharpenEnabled: boolean;
  112432. private _resizeObserver;
  112433. private _hardwareScaleLevel;
  112434. private _bloomKernel;
  112435. /**
  112436. * Specifies the size of the bloom blur kernel, relative to the final output size
  112437. */
  112438. bloomKernel: number;
  112439. /**
  112440. * Specifies the weight of the bloom in the final rendering
  112441. */
  112442. private _bloomWeight;
  112443. /**
  112444. * Specifies the luma threshold for the area that will be blurred by the bloom
  112445. */
  112446. private _bloomThreshold;
  112447. private _hdr;
  112448. /**
  112449. * The strength of the bloom.
  112450. */
  112451. bloomWeight: number;
  112452. /**
  112453. * The strength of the bloom.
  112454. */
  112455. bloomThreshold: number;
  112456. /**
  112457. * The scale of the bloom, lower value will provide better performance.
  112458. */
  112459. bloomScale: number;
  112460. /**
  112461. * Enable or disable the bloom from the pipeline
  112462. */
  112463. bloomEnabled: boolean;
  112464. private _rebuildBloom;
  112465. /**
  112466. * If the depth of field is enabled.
  112467. */
  112468. depthOfFieldEnabled: boolean;
  112469. /**
  112470. * Blur level of the depth of field effect. (Higher blur will effect performance)
  112471. */
  112472. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  112473. /**
  112474. * If the anti aliasing is enabled.
  112475. */
  112476. fxaaEnabled: boolean;
  112477. private _samples;
  112478. /**
  112479. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  112480. */
  112481. samples: number;
  112482. /**
  112483. * If image processing is enabled.
  112484. */
  112485. imageProcessingEnabled: boolean;
  112486. /**
  112487. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  112488. */
  112489. glowLayerEnabled: boolean;
  112490. /**
  112491. * Enable or disable the chromaticAberration process from the pipeline
  112492. */
  112493. chromaticAberrationEnabled: boolean;
  112494. /**
  112495. * Enable or disable the grain process from the pipeline
  112496. */
  112497. grainEnabled: boolean;
  112498. /**
  112499. * @constructor
  112500. * @param name - The rendering pipeline name (default: "")
  112501. * @param hdr - If high dynamic range textures should be used (default: true)
  112502. * @param scene - The scene linked to this pipeline (default: the last created scene)
  112503. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  112504. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  112505. */
  112506. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  112507. /**
  112508. * Get the class name
  112509. * @returns "DefaultRenderingPipeline"
  112510. */
  112511. getClassName(): string;
  112512. /**
  112513. * Force the compilation of the entire pipeline.
  112514. */
  112515. prepare(): void;
  112516. private _hasCleared;
  112517. private _prevPostProcess;
  112518. private _prevPrevPostProcess;
  112519. private _setAutoClearAndTextureSharing;
  112520. private _depthOfFieldSceneObserver;
  112521. private _buildPipeline;
  112522. private _disposePostProcesses;
  112523. /**
  112524. * Adds a camera to the pipeline
  112525. * @param camera the camera to be added
  112526. */
  112527. addCamera(camera: Camera): void;
  112528. /**
  112529. * Removes a camera from the pipeline
  112530. * @param camera the camera to remove
  112531. */
  112532. removeCamera(camera: Camera): void;
  112533. /**
  112534. * Dispose of the pipeline and stop all post processes
  112535. */
  112536. dispose(): void;
  112537. /**
  112538. * Serialize the rendering pipeline (Used when exporting)
  112539. * @returns the serialized object
  112540. */
  112541. serialize(): any;
  112542. /**
  112543. * Parse the serialized pipeline
  112544. * @param source Source pipeline.
  112545. * @param scene The scene to load the pipeline to.
  112546. * @param rootUrl The URL of the serialized pipeline.
  112547. * @returns An instantiated pipeline from the serialized object.
  112548. */
  112549. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  112550. }
  112551. }
  112552. declare module BABYLON {
  112553. /** @hidden */
  112554. export var lensHighlightsPixelShader: {
  112555. name: string;
  112556. shader: string;
  112557. };
  112558. }
  112559. declare module BABYLON {
  112560. /** @hidden */
  112561. export var depthOfFieldPixelShader: {
  112562. name: string;
  112563. shader: string;
  112564. };
  112565. }
  112566. declare module BABYLON {
  112567. /**
  112568. * BABYLON.JS Chromatic Aberration GLSL Shader
  112569. * Author: Olivier Guyot
  112570. * Separates very slightly R, G and B colors on the edges of the screen
  112571. * Inspired by Francois Tarlier & Martins Upitis
  112572. */
  112573. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  112574. /**
  112575. * @ignore
  112576. * The chromatic aberration PostProcess id in the pipeline
  112577. */
  112578. LensChromaticAberrationEffect: string;
  112579. /**
  112580. * @ignore
  112581. * The highlights enhancing PostProcess id in the pipeline
  112582. */
  112583. HighlightsEnhancingEffect: string;
  112584. /**
  112585. * @ignore
  112586. * The depth-of-field PostProcess id in the pipeline
  112587. */
  112588. LensDepthOfFieldEffect: string;
  112589. private _scene;
  112590. private _depthTexture;
  112591. private _grainTexture;
  112592. private _chromaticAberrationPostProcess;
  112593. private _highlightsPostProcess;
  112594. private _depthOfFieldPostProcess;
  112595. private _edgeBlur;
  112596. private _grainAmount;
  112597. private _chromaticAberration;
  112598. private _distortion;
  112599. private _highlightsGain;
  112600. private _highlightsThreshold;
  112601. private _dofDistance;
  112602. private _dofAperture;
  112603. private _dofDarken;
  112604. private _dofPentagon;
  112605. private _blurNoise;
  112606. /**
  112607. * @constructor
  112608. *
  112609. * Effect parameters are as follow:
  112610. * {
  112611. * chromatic_aberration: number; // from 0 to x (1 for realism)
  112612. * edge_blur: number; // from 0 to x (1 for realism)
  112613. * distortion: number; // from 0 to x (1 for realism)
  112614. * grain_amount: number; // from 0 to 1
  112615. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  112616. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  112617. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  112618. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  112619. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  112620. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  112621. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  112622. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  112623. * }
  112624. * Note: if an effect parameter is unset, effect is disabled
  112625. *
  112626. * @param name The rendering pipeline name
  112627. * @param parameters - An object containing all parameters (see above)
  112628. * @param scene The scene linked to this pipeline
  112629. * @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)
  112630. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112631. */
  112632. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  112633. /**
  112634. * Get the class name
  112635. * @returns "LensRenderingPipeline"
  112636. */
  112637. getClassName(): string;
  112638. /**
  112639. * Gets associated scene
  112640. */
  112641. readonly scene: Scene;
  112642. /**
  112643. * Gets or sets the edge blur
  112644. */
  112645. edgeBlur: number;
  112646. /**
  112647. * Gets or sets the grain amount
  112648. */
  112649. grainAmount: number;
  112650. /**
  112651. * Gets or sets the chromatic aberration amount
  112652. */
  112653. chromaticAberration: number;
  112654. /**
  112655. * Gets or sets the depth of field aperture
  112656. */
  112657. dofAperture: number;
  112658. /**
  112659. * Gets or sets the edge distortion
  112660. */
  112661. edgeDistortion: number;
  112662. /**
  112663. * Gets or sets the depth of field distortion
  112664. */
  112665. dofDistortion: number;
  112666. /**
  112667. * Gets or sets the darken out of focus amount
  112668. */
  112669. darkenOutOfFocus: number;
  112670. /**
  112671. * Gets or sets a boolean indicating if blur noise is enabled
  112672. */
  112673. blurNoise: boolean;
  112674. /**
  112675. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  112676. */
  112677. pentagonBokeh: boolean;
  112678. /**
  112679. * Gets or sets the highlight grain amount
  112680. */
  112681. highlightsGain: number;
  112682. /**
  112683. * Gets or sets the highlight threshold
  112684. */
  112685. highlightsThreshold: number;
  112686. /**
  112687. * Sets the amount of blur at the edges
  112688. * @param amount blur amount
  112689. */
  112690. setEdgeBlur(amount: number): void;
  112691. /**
  112692. * Sets edge blur to 0
  112693. */
  112694. disableEdgeBlur(): void;
  112695. /**
  112696. * Sets the amout of grain
  112697. * @param amount Amount of grain
  112698. */
  112699. setGrainAmount(amount: number): void;
  112700. /**
  112701. * Set grain amount to 0
  112702. */
  112703. disableGrain(): void;
  112704. /**
  112705. * Sets the chromatic aberration amount
  112706. * @param amount amount of chromatic aberration
  112707. */
  112708. setChromaticAberration(amount: number): void;
  112709. /**
  112710. * Sets chromatic aberration amount to 0
  112711. */
  112712. disableChromaticAberration(): void;
  112713. /**
  112714. * Sets the EdgeDistortion amount
  112715. * @param amount amount of EdgeDistortion
  112716. */
  112717. setEdgeDistortion(amount: number): void;
  112718. /**
  112719. * Sets edge distortion to 0
  112720. */
  112721. disableEdgeDistortion(): void;
  112722. /**
  112723. * Sets the FocusDistance amount
  112724. * @param amount amount of FocusDistance
  112725. */
  112726. setFocusDistance(amount: number): void;
  112727. /**
  112728. * Disables depth of field
  112729. */
  112730. disableDepthOfField(): void;
  112731. /**
  112732. * Sets the Aperture amount
  112733. * @param amount amount of Aperture
  112734. */
  112735. setAperture(amount: number): void;
  112736. /**
  112737. * Sets the DarkenOutOfFocus amount
  112738. * @param amount amount of DarkenOutOfFocus
  112739. */
  112740. setDarkenOutOfFocus(amount: number): void;
  112741. private _pentagonBokehIsEnabled;
  112742. /**
  112743. * Creates a pentagon bokeh effect
  112744. */
  112745. enablePentagonBokeh(): void;
  112746. /**
  112747. * Disables the pentagon bokeh effect
  112748. */
  112749. disablePentagonBokeh(): void;
  112750. /**
  112751. * Enables noise blur
  112752. */
  112753. enableNoiseBlur(): void;
  112754. /**
  112755. * Disables noise blur
  112756. */
  112757. disableNoiseBlur(): void;
  112758. /**
  112759. * Sets the HighlightsGain amount
  112760. * @param amount amount of HighlightsGain
  112761. */
  112762. setHighlightsGain(amount: number): void;
  112763. /**
  112764. * Sets the HighlightsThreshold amount
  112765. * @param amount amount of HighlightsThreshold
  112766. */
  112767. setHighlightsThreshold(amount: number): void;
  112768. /**
  112769. * Disables highlights
  112770. */
  112771. disableHighlights(): void;
  112772. /**
  112773. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  112774. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  112775. */
  112776. dispose(disableDepthRender?: boolean): void;
  112777. private _createChromaticAberrationPostProcess;
  112778. private _createHighlightsPostProcess;
  112779. private _createDepthOfFieldPostProcess;
  112780. private _createGrainTexture;
  112781. }
  112782. }
  112783. declare module BABYLON {
  112784. /** @hidden */
  112785. export var ssao2PixelShader: {
  112786. name: string;
  112787. shader: string;
  112788. };
  112789. }
  112790. declare module BABYLON {
  112791. /** @hidden */
  112792. export var ssaoCombinePixelShader: {
  112793. name: string;
  112794. shader: string;
  112795. };
  112796. }
  112797. declare module BABYLON {
  112798. /**
  112799. * Render pipeline to produce ssao effect
  112800. */
  112801. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  112802. /**
  112803. * @ignore
  112804. * The PassPostProcess id in the pipeline that contains the original scene color
  112805. */
  112806. SSAOOriginalSceneColorEffect: string;
  112807. /**
  112808. * @ignore
  112809. * The SSAO PostProcess id in the pipeline
  112810. */
  112811. SSAORenderEffect: string;
  112812. /**
  112813. * @ignore
  112814. * The horizontal blur PostProcess id in the pipeline
  112815. */
  112816. SSAOBlurHRenderEffect: string;
  112817. /**
  112818. * @ignore
  112819. * The vertical blur PostProcess id in the pipeline
  112820. */
  112821. SSAOBlurVRenderEffect: string;
  112822. /**
  112823. * @ignore
  112824. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112825. */
  112826. SSAOCombineRenderEffect: string;
  112827. /**
  112828. * The output strength of the SSAO post-process. Default value is 1.0.
  112829. */
  112830. totalStrength: number;
  112831. /**
  112832. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  112833. */
  112834. maxZ: number;
  112835. /**
  112836. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  112837. */
  112838. minZAspect: number;
  112839. private _samples;
  112840. /**
  112841. * Number of samples used for the SSAO calculations. Default value is 8
  112842. */
  112843. samples: number;
  112844. private _textureSamples;
  112845. /**
  112846. * Number of samples to use for antialiasing
  112847. */
  112848. textureSamples: number;
  112849. /**
  112850. * Ratio object used for SSAO ratio and blur ratio
  112851. */
  112852. private _ratio;
  112853. /**
  112854. * Dynamically generated sphere sampler.
  112855. */
  112856. private _sampleSphere;
  112857. /**
  112858. * Blur filter offsets
  112859. */
  112860. private _samplerOffsets;
  112861. private _expensiveBlur;
  112862. /**
  112863. * If bilateral blur should be used
  112864. */
  112865. expensiveBlur: boolean;
  112866. /**
  112867. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  112868. */
  112869. radius: number;
  112870. /**
  112871. * The base color of the SSAO post-process
  112872. * The final result is "base + ssao" between [0, 1]
  112873. */
  112874. base: number;
  112875. /**
  112876. * Support test.
  112877. */
  112878. static readonly IsSupported: boolean;
  112879. private _scene;
  112880. private _depthTexture;
  112881. private _normalTexture;
  112882. private _randomTexture;
  112883. private _originalColorPostProcess;
  112884. private _ssaoPostProcess;
  112885. private _blurHPostProcess;
  112886. private _blurVPostProcess;
  112887. private _ssaoCombinePostProcess;
  112888. private _firstUpdate;
  112889. /**
  112890. * Gets active scene
  112891. */
  112892. readonly scene: Scene;
  112893. /**
  112894. * @constructor
  112895. * @param name The rendering pipeline name
  112896. * @param scene The scene linked to this pipeline
  112897. * @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 }
  112898. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112899. */
  112900. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  112901. /**
  112902. * Get the class name
  112903. * @returns "SSAO2RenderingPipeline"
  112904. */
  112905. getClassName(): string;
  112906. /**
  112907. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  112908. */
  112909. dispose(disableGeometryBufferRenderer?: boolean): void;
  112910. private _createBlurPostProcess;
  112911. /** @hidden */
  112912. _rebuild(): void;
  112913. private _bits;
  112914. private _radicalInverse_VdC;
  112915. private _hammersley;
  112916. private _hemisphereSample_uniform;
  112917. private _generateHemisphere;
  112918. private _createSSAOPostProcess;
  112919. private _createSSAOCombinePostProcess;
  112920. private _createRandomTexture;
  112921. /**
  112922. * Serialize the rendering pipeline (Used when exporting)
  112923. * @returns the serialized object
  112924. */
  112925. serialize(): any;
  112926. /**
  112927. * Parse the serialized pipeline
  112928. * @param source Source pipeline.
  112929. * @param scene The scene to load the pipeline to.
  112930. * @param rootUrl The URL of the serialized pipeline.
  112931. * @returns An instantiated pipeline from the serialized object.
  112932. */
  112933. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  112934. }
  112935. }
  112936. declare module BABYLON {
  112937. /** @hidden */
  112938. export var ssaoPixelShader: {
  112939. name: string;
  112940. shader: string;
  112941. };
  112942. }
  112943. declare module BABYLON {
  112944. /**
  112945. * Render pipeline to produce ssao effect
  112946. */
  112947. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  112948. /**
  112949. * @ignore
  112950. * The PassPostProcess id in the pipeline that contains the original scene color
  112951. */
  112952. SSAOOriginalSceneColorEffect: string;
  112953. /**
  112954. * @ignore
  112955. * The SSAO PostProcess id in the pipeline
  112956. */
  112957. SSAORenderEffect: string;
  112958. /**
  112959. * @ignore
  112960. * The horizontal blur PostProcess id in the pipeline
  112961. */
  112962. SSAOBlurHRenderEffect: string;
  112963. /**
  112964. * @ignore
  112965. * The vertical blur PostProcess id in the pipeline
  112966. */
  112967. SSAOBlurVRenderEffect: string;
  112968. /**
  112969. * @ignore
  112970. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112971. */
  112972. SSAOCombineRenderEffect: string;
  112973. /**
  112974. * The output strength of the SSAO post-process. Default value is 1.0.
  112975. */
  112976. totalStrength: number;
  112977. /**
  112978. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  112979. */
  112980. radius: number;
  112981. /**
  112982. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  112983. * Must not be equal to fallOff and superior to fallOff.
  112984. * Default value is 0.0075
  112985. */
  112986. area: number;
  112987. /**
  112988. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  112989. * Must not be equal to area and inferior to area.
  112990. * Default value is 0.000001
  112991. */
  112992. fallOff: number;
  112993. /**
  112994. * The base color of the SSAO post-process
  112995. * The final result is "base + ssao" between [0, 1]
  112996. */
  112997. base: number;
  112998. private _scene;
  112999. private _depthTexture;
  113000. private _randomTexture;
  113001. private _originalColorPostProcess;
  113002. private _ssaoPostProcess;
  113003. private _blurHPostProcess;
  113004. private _blurVPostProcess;
  113005. private _ssaoCombinePostProcess;
  113006. private _firstUpdate;
  113007. /**
  113008. * Gets active scene
  113009. */
  113010. readonly scene: Scene;
  113011. /**
  113012. * @constructor
  113013. * @param name - The rendering pipeline name
  113014. * @param scene - The scene linked to this pipeline
  113015. * @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 }
  113016. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  113017. */
  113018. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113019. /**
  113020. * Get the class name
  113021. * @returns "SSAORenderingPipeline"
  113022. */
  113023. getClassName(): string;
  113024. /**
  113025. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113026. */
  113027. dispose(disableDepthRender?: boolean): void;
  113028. private _createBlurPostProcess;
  113029. /** @hidden */
  113030. _rebuild(): void;
  113031. private _createSSAOPostProcess;
  113032. private _createSSAOCombinePostProcess;
  113033. private _createRandomTexture;
  113034. }
  113035. }
  113036. declare module BABYLON {
  113037. /** @hidden */
  113038. export var standardPixelShader: {
  113039. name: string;
  113040. shader: string;
  113041. };
  113042. }
  113043. declare module BABYLON {
  113044. /**
  113045. * Standard rendering pipeline
  113046. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113047. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  113048. */
  113049. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113050. /**
  113051. * Public members
  113052. */
  113053. /**
  113054. * Post-process which contains the original scene color before the pipeline applies all the effects
  113055. */
  113056. originalPostProcess: Nullable<PostProcess>;
  113057. /**
  113058. * Post-process used to down scale an image x4
  113059. */
  113060. downSampleX4PostProcess: Nullable<PostProcess>;
  113061. /**
  113062. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  113063. */
  113064. brightPassPostProcess: Nullable<PostProcess>;
  113065. /**
  113066. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  113067. */
  113068. blurHPostProcesses: PostProcess[];
  113069. /**
  113070. * Post-process array storing all the vertical blur post-processes used by the pipeline
  113071. */
  113072. blurVPostProcesses: PostProcess[];
  113073. /**
  113074. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  113075. */
  113076. textureAdderPostProcess: Nullable<PostProcess>;
  113077. /**
  113078. * Post-process used to create volumetric lighting effect
  113079. */
  113080. volumetricLightPostProcess: Nullable<PostProcess>;
  113081. /**
  113082. * Post-process used to smooth the previous volumetric light post-process on the X axis
  113083. */
  113084. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  113085. /**
  113086. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  113087. */
  113088. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  113089. /**
  113090. * Post-process used to merge the volumetric light effect and the real scene color
  113091. */
  113092. volumetricLightMergePostProces: Nullable<PostProcess>;
  113093. /**
  113094. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  113095. */
  113096. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  113097. /**
  113098. * Base post-process used to calculate the average luminance of the final image for HDR
  113099. */
  113100. luminancePostProcess: Nullable<PostProcess>;
  113101. /**
  113102. * Post-processes used to create down sample post-processes in order to get
  113103. * the average luminance of the final image for HDR
  113104. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  113105. */
  113106. luminanceDownSamplePostProcesses: PostProcess[];
  113107. /**
  113108. * Post-process used to create a HDR effect (light adaptation)
  113109. */
  113110. hdrPostProcess: Nullable<PostProcess>;
  113111. /**
  113112. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  113113. */
  113114. textureAdderFinalPostProcess: Nullable<PostProcess>;
  113115. /**
  113116. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  113117. */
  113118. lensFlareFinalPostProcess: Nullable<PostProcess>;
  113119. /**
  113120. * Post-process used to merge the final HDR post-process and the real scene color
  113121. */
  113122. hdrFinalPostProcess: Nullable<PostProcess>;
  113123. /**
  113124. * Post-process used to create a lens flare effect
  113125. */
  113126. lensFlarePostProcess: Nullable<PostProcess>;
  113127. /**
  113128. * Post-process that merges the result of the lens flare post-process and the real scene color
  113129. */
  113130. lensFlareComposePostProcess: Nullable<PostProcess>;
  113131. /**
  113132. * Post-process used to create a motion blur effect
  113133. */
  113134. motionBlurPostProcess: Nullable<PostProcess>;
  113135. /**
  113136. * Post-process used to create a depth of field effect
  113137. */
  113138. depthOfFieldPostProcess: Nullable<PostProcess>;
  113139. /**
  113140. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113141. */
  113142. fxaaPostProcess: Nullable<FxaaPostProcess>;
  113143. /**
  113144. * Represents the brightness threshold in order to configure the illuminated surfaces
  113145. */
  113146. brightThreshold: number;
  113147. /**
  113148. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  113149. */
  113150. blurWidth: number;
  113151. /**
  113152. * Sets if the blur for highlighted surfaces must be only horizontal
  113153. */
  113154. horizontalBlur: boolean;
  113155. /**
  113156. * Gets the overall exposure used by the pipeline
  113157. */
  113158. /**
  113159. * Sets the overall exposure used by the pipeline
  113160. */
  113161. exposure: number;
  113162. /**
  113163. * Texture used typically to simulate "dirty" on camera lens
  113164. */
  113165. lensTexture: Nullable<Texture>;
  113166. /**
  113167. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  113168. */
  113169. volumetricLightCoefficient: number;
  113170. /**
  113171. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  113172. */
  113173. volumetricLightPower: number;
  113174. /**
  113175. * Used the set the blur intensity to smooth the volumetric lights
  113176. */
  113177. volumetricLightBlurScale: number;
  113178. /**
  113179. * Light (spot or directional) used to generate the volumetric lights rays
  113180. * The source light must have a shadow generate so the pipeline can get its
  113181. * depth map
  113182. */
  113183. sourceLight: Nullable<SpotLight | DirectionalLight>;
  113184. /**
  113185. * For eye adaptation, represents the minimum luminance the eye can see
  113186. */
  113187. hdrMinimumLuminance: number;
  113188. /**
  113189. * For eye adaptation, represents the decrease luminance speed
  113190. */
  113191. hdrDecreaseRate: number;
  113192. /**
  113193. * For eye adaptation, represents the increase luminance speed
  113194. */
  113195. hdrIncreaseRate: number;
  113196. /**
  113197. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113198. */
  113199. /**
  113200. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113201. */
  113202. hdrAutoExposure: boolean;
  113203. /**
  113204. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  113205. */
  113206. lensColorTexture: Nullable<Texture>;
  113207. /**
  113208. * The overall strengh for the lens flare effect
  113209. */
  113210. lensFlareStrength: number;
  113211. /**
  113212. * Dispersion coefficient for lens flare ghosts
  113213. */
  113214. lensFlareGhostDispersal: number;
  113215. /**
  113216. * Main lens flare halo width
  113217. */
  113218. lensFlareHaloWidth: number;
  113219. /**
  113220. * Based on the lens distortion effect, defines how much the lens flare result
  113221. * is distorted
  113222. */
  113223. lensFlareDistortionStrength: number;
  113224. /**
  113225. * Lens star texture must be used to simulate rays on the flares and is available
  113226. * in the documentation
  113227. */
  113228. lensStarTexture: Nullable<Texture>;
  113229. /**
  113230. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  113231. * flare effect by taking account of the dirt texture
  113232. */
  113233. lensFlareDirtTexture: Nullable<Texture>;
  113234. /**
  113235. * Represents the focal length for the depth of field effect
  113236. */
  113237. depthOfFieldDistance: number;
  113238. /**
  113239. * Represents the blur intensity for the blurred part of the depth of field effect
  113240. */
  113241. depthOfFieldBlurWidth: number;
  113242. /**
  113243. * For motion blur, defines how much the image is blurred by the movement
  113244. */
  113245. motionStrength: number;
  113246. /**
  113247. * List of animations for the pipeline (IAnimatable implementation)
  113248. */
  113249. animations: Animation[];
  113250. /**
  113251. * Private members
  113252. */
  113253. private _scene;
  113254. private _currentDepthOfFieldSource;
  113255. private _basePostProcess;
  113256. private _fixedExposure;
  113257. private _currentExposure;
  113258. private _hdrAutoExposure;
  113259. private _hdrCurrentLuminance;
  113260. private _floatTextureType;
  113261. private _ratio;
  113262. private _bloomEnabled;
  113263. private _depthOfFieldEnabled;
  113264. private _vlsEnabled;
  113265. private _lensFlareEnabled;
  113266. private _hdrEnabled;
  113267. private _motionBlurEnabled;
  113268. private _fxaaEnabled;
  113269. private _motionBlurSamples;
  113270. private _volumetricLightStepsCount;
  113271. private _samples;
  113272. /**
  113273. * @ignore
  113274. * Specifies if the bloom pipeline is enabled
  113275. */
  113276. BloomEnabled: boolean;
  113277. /**
  113278. * @ignore
  113279. * Specifies if the depth of field pipeline is enabed
  113280. */
  113281. DepthOfFieldEnabled: boolean;
  113282. /**
  113283. * @ignore
  113284. * Specifies if the lens flare pipeline is enabed
  113285. */
  113286. LensFlareEnabled: boolean;
  113287. /**
  113288. * @ignore
  113289. * Specifies if the HDR pipeline is enabled
  113290. */
  113291. HDREnabled: boolean;
  113292. /**
  113293. * @ignore
  113294. * Specifies if the volumetric lights scattering effect is enabled
  113295. */
  113296. VLSEnabled: boolean;
  113297. /**
  113298. * @ignore
  113299. * Specifies if the motion blur effect is enabled
  113300. */
  113301. MotionBlurEnabled: boolean;
  113302. /**
  113303. * Specifies if anti-aliasing is enabled
  113304. */
  113305. fxaaEnabled: boolean;
  113306. /**
  113307. * Specifies the number of steps used to calculate the volumetric lights
  113308. * Typically in interval [50, 200]
  113309. */
  113310. volumetricLightStepsCount: number;
  113311. /**
  113312. * Specifies the number of samples used for the motion blur effect
  113313. * Typically in interval [16, 64]
  113314. */
  113315. motionBlurSamples: number;
  113316. /**
  113317. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113318. */
  113319. samples: number;
  113320. /**
  113321. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113322. * @constructor
  113323. * @param name The rendering pipeline name
  113324. * @param scene The scene linked to this pipeline
  113325. * @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)
  113326. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  113327. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113328. */
  113329. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  113330. private _buildPipeline;
  113331. private _createDownSampleX4PostProcess;
  113332. private _createBrightPassPostProcess;
  113333. private _createBlurPostProcesses;
  113334. private _createTextureAdderPostProcess;
  113335. private _createVolumetricLightPostProcess;
  113336. private _createLuminancePostProcesses;
  113337. private _createHdrPostProcess;
  113338. private _createLensFlarePostProcess;
  113339. private _createDepthOfFieldPostProcess;
  113340. private _createMotionBlurPostProcess;
  113341. private _getDepthTexture;
  113342. private _disposePostProcesses;
  113343. /**
  113344. * Dispose of the pipeline and stop all post processes
  113345. */
  113346. dispose(): void;
  113347. /**
  113348. * Serialize the rendering pipeline (Used when exporting)
  113349. * @returns the serialized object
  113350. */
  113351. serialize(): any;
  113352. /**
  113353. * Parse the serialized pipeline
  113354. * @param source Source pipeline.
  113355. * @param scene The scene to load the pipeline to.
  113356. * @param rootUrl The URL of the serialized pipeline.
  113357. * @returns An instantiated pipeline from the serialized object.
  113358. */
  113359. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  113360. /**
  113361. * Luminance steps
  113362. */
  113363. static LuminanceSteps: number;
  113364. }
  113365. }
  113366. declare module BABYLON {
  113367. /** @hidden */
  113368. export var tonemapPixelShader: {
  113369. name: string;
  113370. shader: string;
  113371. };
  113372. }
  113373. declare module BABYLON {
  113374. /** Defines operator used for tonemapping */
  113375. export enum TonemappingOperator {
  113376. /** Hable */
  113377. Hable = 0,
  113378. /** Reinhard */
  113379. Reinhard = 1,
  113380. /** HejiDawson */
  113381. HejiDawson = 2,
  113382. /** Photographic */
  113383. Photographic = 3
  113384. }
  113385. /**
  113386. * Defines a post process to apply tone mapping
  113387. */
  113388. export class TonemapPostProcess extends PostProcess {
  113389. private _operator;
  113390. /** Defines the required exposure adjustement */
  113391. exposureAdjustment: number;
  113392. /**
  113393. * Creates a new TonemapPostProcess
  113394. * @param name defines the name of the postprocess
  113395. * @param _operator defines the operator to use
  113396. * @param exposureAdjustment defines the required exposure adjustement
  113397. * @param camera defines the camera to use (can be null)
  113398. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  113399. * @param engine defines the hosting engine (can be ignore if camera is set)
  113400. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113401. */
  113402. constructor(name: string, _operator: TonemappingOperator,
  113403. /** Defines the required exposure adjustement */
  113404. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  113405. }
  113406. }
  113407. declare module BABYLON {
  113408. /** @hidden */
  113409. export var depthVertexShader: {
  113410. name: string;
  113411. shader: string;
  113412. };
  113413. }
  113414. declare module BABYLON {
  113415. /** @hidden */
  113416. export var volumetricLightScatteringPixelShader: {
  113417. name: string;
  113418. shader: string;
  113419. };
  113420. }
  113421. declare module BABYLON {
  113422. /** @hidden */
  113423. export var volumetricLightScatteringPassPixelShader: {
  113424. name: string;
  113425. shader: string;
  113426. };
  113427. }
  113428. declare module BABYLON {
  113429. /**
  113430. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  113431. */
  113432. export class VolumetricLightScatteringPostProcess extends PostProcess {
  113433. private _volumetricLightScatteringPass;
  113434. private _volumetricLightScatteringRTT;
  113435. private _viewPort;
  113436. private _screenCoordinates;
  113437. private _cachedDefines;
  113438. /**
  113439. * If not undefined, the mesh position is computed from the attached node position
  113440. */
  113441. attachedNode: {
  113442. position: Vector3;
  113443. };
  113444. /**
  113445. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  113446. */
  113447. customMeshPosition: Vector3;
  113448. /**
  113449. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  113450. */
  113451. useCustomMeshPosition: boolean;
  113452. /**
  113453. * If the post-process should inverse the light scattering direction
  113454. */
  113455. invert: boolean;
  113456. /**
  113457. * The internal mesh used by the post-process
  113458. */
  113459. mesh: Mesh;
  113460. /**
  113461. * @hidden
  113462. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  113463. */
  113464. useDiffuseColor: boolean;
  113465. /**
  113466. * Array containing the excluded meshes not rendered in the internal pass
  113467. */
  113468. excludedMeshes: AbstractMesh[];
  113469. /**
  113470. * Controls the overall intensity of the post-process
  113471. */
  113472. exposure: number;
  113473. /**
  113474. * Dissipates each sample's contribution in range [0, 1]
  113475. */
  113476. decay: number;
  113477. /**
  113478. * Controls the overall intensity of each sample
  113479. */
  113480. weight: number;
  113481. /**
  113482. * Controls the density of each sample
  113483. */
  113484. density: number;
  113485. /**
  113486. * @constructor
  113487. * @param name The post-process name
  113488. * @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)
  113489. * @param camera The camera that the post-process will be attached to
  113490. * @param mesh The mesh used to create the light scattering
  113491. * @param samples The post-process quality, default 100
  113492. * @param samplingModeThe post-process filtering mode
  113493. * @param engine The babylon engine
  113494. * @param reusable If the post-process is reusable
  113495. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  113496. */
  113497. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  113498. /**
  113499. * Returns the string "VolumetricLightScatteringPostProcess"
  113500. * @returns "VolumetricLightScatteringPostProcess"
  113501. */
  113502. getClassName(): string;
  113503. private _isReady;
  113504. /**
  113505. * Sets the new light position for light scattering effect
  113506. * @param position The new custom light position
  113507. */
  113508. setCustomMeshPosition(position: Vector3): void;
  113509. /**
  113510. * Returns the light position for light scattering effect
  113511. * @return Vector3 The custom light position
  113512. */
  113513. getCustomMeshPosition(): Vector3;
  113514. /**
  113515. * Disposes the internal assets and detaches the post-process from the camera
  113516. */
  113517. dispose(camera: Camera): void;
  113518. /**
  113519. * Returns the render target texture used by the post-process
  113520. * @return the render target texture used by the post-process
  113521. */
  113522. getPass(): RenderTargetTexture;
  113523. private _meshExcluded;
  113524. private _createPass;
  113525. private _updateMeshScreenCoordinates;
  113526. /**
  113527. * Creates a default mesh for the Volumeric Light Scattering post-process
  113528. * @param name The mesh name
  113529. * @param scene The scene where to create the mesh
  113530. * @return the default mesh
  113531. */
  113532. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  113533. }
  113534. }
  113535. declare module BABYLON {
  113536. interface Scene {
  113537. /** @hidden (Backing field) */
  113538. _boundingBoxRenderer: BoundingBoxRenderer;
  113539. /** @hidden (Backing field) */
  113540. _forceShowBoundingBoxes: boolean;
  113541. /**
  113542. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  113543. */
  113544. forceShowBoundingBoxes: boolean;
  113545. /**
  113546. * Gets the bounding box renderer associated with the scene
  113547. * @returns a BoundingBoxRenderer
  113548. */
  113549. getBoundingBoxRenderer(): BoundingBoxRenderer;
  113550. }
  113551. interface AbstractMesh {
  113552. /** @hidden (Backing field) */
  113553. _showBoundingBox: boolean;
  113554. /**
  113555. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  113556. */
  113557. showBoundingBox: boolean;
  113558. }
  113559. /**
  113560. * Component responsible of rendering the bounding box of the meshes in a scene.
  113561. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  113562. */
  113563. export class BoundingBoxRenderer implements ISceneComponent {
  113564. /**
  113565. * The component name helpfull to identify the component in the list of scene components.
  113566. */
  113567. readonly name: string;
  113568. /**
  113569. * The scene the component belongs to.
  113570. */
  113571. scene: Scene;
  113572. /**
  113573. * Color of the bounding box lines placed in front of an object
  113574. */
  113575. frontColor: Color3;
  113576. /**
  113577. * Color of the bounding box lines placed behind an object
  113578. */
  113579. backColor: Color3;
  113580. /**
  113581. * Defines if the renderer should show the back lines or not
  113582. */
  113583. showBackLines: boolean;
  113584. /**
  113585. * @hidden
  113586. */
  113587. renderList: SmartArray<BoundingBox>;
  113588. private _colorShader;
  113589. private _vertexBuffers;
  113590. private _indexBuffer;
  113591. /**
  113592. * Instantiates a new bounding box renderer in a scene.
  113593. * @param scene the scene the renderer renders in
  113594. */
  113595. constructor(scene: Scene);
  113596. /**
  113597. * Registers the component in a given scene
  113598. */
  113599. register(): void;
  113600. private _evaluateSubMesh;
  113601. private _activeMesh;
  113602. private _prepareRessources;
  113603. private _createIndexBuffer;
  113604. /**
  113605. * Rebuilds the elements related to this component in case of
  113606. * context lost for instance.
  113607. */
  113608. rebuild(): void;
  113609. /**
  113610. * @hidden
  113611. */
  113612. reset(): void;
  113613. /**
  113614. * Render the bounding boxes of a specific rendering group
  113615. * @param renderingGroupId defines the rendering group to render
  113616. */
  113617. render(renderingGroupId: number): void;
  113618. /**
  113619. * In case of occlusion queries, we can render the occlusion bounding box through this method
  113620. * @param mesh Define the mesh to render the occlusion bounding box for
  113621. */
  113622. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  113623. /**
  113624. * Dispose and release the resources attached to this renderer.
  113625. */
  113626. dispose(): void;
  113627. }
  113628. }
  113629. declare module BABYLON {
  113630. /** @hidden */
  113631. export var depthPixelShader: {
  113632. name: string;
  113633. shader: string;
  113634. };
  113635. }
  113636. declare module BABYLON {
  113637. /**
  113638. * This represents a depth renderer in Babylon.
  113639. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  113640. */
  113641. export class DepthRenderer {
  113642. private _scene;
  113643. private _depthMap;
  113644. private _effect;
  113645. private _cachedDefines;
  113646. private _camera;
  113647. /**
  113648. * Specifiess that the depth renderer will only be used within
  113649. * the camera it is created for.
  113650. * This can help forcing its rendering during the camera processing.
  113651. */
  113652. useOnlyInActiveCamera: boolean;
  113653. /** @hidden */
  113654. static _SceneComponentInitialization: (scene: Scene) => void;
  113655. /**
  113656. * Instantiates a depth renderer
  113657. * @param scene The scene the renderer belongs to
  113658. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  113659. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  113660. */
  113661. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  113662. /**
  113663. * Creates the depth rendering effect and checks if the effect is ready.
  113664. * @param subMesh The submesh to be used to render the depth map of
  113665. * @param useInstances If multiple world instances should be used
  113666. * @returns if the depth renderer is ready to render the depth map
  113667. */
  113668. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113669. /**
  113670. * Gets the texture which the depth map will be written to.
  113671. * @returns The depth map texture
  113672. */
  113673. getDepthMap(): RenderTargetTexture;
  113674. /**
  113675. * Disposes of the depth renderer.
  113676. */
  113677. dispose(): void;
  113678. }
  113679. }
  113680. declare module BABYLON {
  113681. interface Scene {
  113682. /** @hidden (Backing field) */
  113683. _depthRenderer: {
  113684. [id: string]: DepthRenderer;
  113685. };
  113686. /**
  113687. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  113688. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  113689. * @returns the created depth renderer
  113690. */
  113691. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  113692. /**
  113693. * Disables a depth renderer for a given camera
  113694. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  113695. */
  113696. disableDepthRenderer(camera?: Nullable<Camera>): void;
  113697. }
  113698. /**
  113699. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  113700. * in several rendering techniques.
  113701. */
  113702. export class DepthRendererSceneComponent implements ISceneComponent {
  113703. /**
  113704. * The component name helpfull to identify the component in the list of scene components.
  113705. */
  113706. readonly name: string;
  113707. /**
  113708. * The scene the component belongs to.
  113709. */
  113710. scene: Scene;
  113711. /**
  113712. * Creates a new instance of the component for the given scene
  113713. * @param scene Defines the scene to register the component in
  113714. */
  113715. constructor(scene: Scene);
  113716. /**
  113717. * Registers the component in a given scene
  113718. */
  113719. register(): void;
  113720. /**
  113721. * Rebuilds the elements related to this component in case of
  113722. * context lost for instance.
  113723. */
  113724. rebuild(): void;
  113725. /**
  113726. * Disposes the component and the associated ressources
  113727. */
  113728. dispose(): void;
  113729. private _gatherRenderTargets;
  113730. private _gatherActiveCameraRenderTargets;
  113731. }
  113732. }
  113733. declare module BABYLON {
  113734. /** @hidden */
  113735. export var outlinePixelShader: {
  113736. name: string;
  113737. shader: string;
  113738. };
  113739. }
  113740. declare module BABYLON {
  113741. /** @hidden */
  113742. export var outlineVertexShader: {
  113743. name: string;
  113744. shader: string;
  113745. };
  113746. }
  113747. declare module BABYLON {
  113748. interface Scene {
  113749. /** @hidden */
  113750. _outlineRenderer: OutlineRenderer;
  113751. /**
  113752. * Gets the outline renderer associated with the scene
  113753. * @returns a OutlineRenderer
  113754. */
  113755. getOutlineRenderer(): OutlineRenderer;
  113756. }
  113757. interface AbstractMesh {
  113758. /** @hidden (Backing field) */
  113759. _renderOutline: boolean;
  113760. /**
  113761. * Gets or sets a boolean indicating if the outline must be rendered as well
  113762. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  113763. */
  113764. renderOutline: boolean;
  113765. /** @hidden (Backing field) */
  113766. _renderOverlay: boolean;
  113767. /**
  113768. * Gets or sets a boolean indicating if the overlay must be rendered as well
  113769. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  113770. */
  113771. renderOverlay: boolean;
  113772. }
  113773. /**
  113774. * This class is responsible to draw bothe outline/overlay of meshes.
  113775. * It should not be used directly but through the available method on mesh.
  113776. */
  113777. export class OutlineRenderer implements ISceneComponent {
  113778. /**
  113779. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  113780. */
  113781. private static _StencilReference;
  113782. /**
  113783. * The name of the component. Each component must have a unique name.
  113784. */
  113785. name: string;
  113786. /**
  113787. * The scene the component belongs to.
  113788. */
  113789. scene: Scene;
  113790. /**
  113791. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  113792. */
  113793. zOffset: number;
  113794. private _engine;
  113795. private _effect;
  113796. private _cachedDefines;
  113797. private _savedDepthWrite;
  113798. /**
  113799. * Instantiates a new outline renderer. (There could be only one per scene).
  113800. * @param scene Defines the scene it belongs to
  113801. */
  113802. constructor(scene: Scene);
  113803. /**
  113804. * Register the component to one instance of a scene.
  113805. */
  113806. register(): void;
  113807. /**
  113808. * Rebuilds the elements related to this component in case of
  113809. * context lost for instance.
  113810. */
  113811. rebuild(): void;
  113812. /**
  113813. * Disposes the component and the associated ressources.
  113814. */
  113815. dispose(): void;
  113816. /**
  113817. * Renders the outline in the canvas.
  113818. * @param subMesh Defines the sumesh to render
  113819. * @param batch Defines the batch of meshes in case of instances
  113820. * @param useOverlay Defines if the rendering is for the overlay or the outline
  113821. */
  113822. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  113823. /**
  113824. * Returns whether or not the outline renderer is ready for a given submesh.
  113825. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  113826. * @param subMesh Defines the submesh to check readyness for
  113827. * @param useInstances Defines wheter wee are trying to render instances or not
  113828. * @returns true if ready otherwise false
  113829. */
  113830. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113831. private _beforeRenderingMesh;
  113832. private _afterRenderingMesh;
  113833. }
  113834. }
  113835. declare module BABYLON {
  113836. /**
  113837. * Defines the list of states available for a task inside a AssetsManager
  113838. */
  113839. export enum AssetTaskState {
  113840. /**
  113841. * Initialization
  113842. */
  113843. INIT = 0,
  113844. /**
  113845. * Running
  113846. */
  113847. RUNNING = 1,
  113848. /**
  113849. * Done
  113850. */
  113851. DONE = 2,
  113852. /**
  113853. * Error
  113854. */
  113855. ERROR = 3
  113856. }
  113857. /**
  113858. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  113859. */
  113860. export abstract class AbstractAssetTask {
  113861. /**
  113862. * Task name
  113863. */ name: string;
  113864. /**
  113865. * Callback called when the task is successful
  113866. */
  113867. onSuccess: (task: any) => void;
  113868. /**
  113869. * Callback called when the task is not successful
  113870. */
  113871. onError: (task: any, message?: string, exception?: any) => void;
  113872. /**
  113873. * Creates a new AssetsManager
  113874. * @param name defines the name of the task
  113875. */
  113876. constructor(
  113877. /**
  113878. * Task name
  113879. */ name: string);
  113880. private _isCompleted;
  113881. private _taskState;
  113882. private _errorObject;
  113883. /**
  113884. * Get if the task is completed
  113885. */
  113886. readonly isCompleted: boolean;
  113887. /**
  113888. * Gets the current state of the task
  113889. */
  113890. readonly taskState: AssetTaskState;
  113891. /**
  113892. * Gets the current error object (if task is in error)
  113893. */
  113894. readonly errorObject: {
  113895. message?: string;
  113896. exception?: any;
  113897. };
  113898. /**
  113899. * Internal only
  113900. * @hidden
  113901. */
  113902. _setErrorObject(message?: string, exception?: any): void;
  113903. /**
  113904. * Execute the current task
  113905. * @param scene defines the scene where you want your assets to be loaded
  113906. * @param onSuccess is a callback called when the task is successfully executed
  113907. * @param onError is a callback called if an error occurs
  113908. */
  113909. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113910. /**
  113911. * Execute the current task
  113912. * @param scene defines the scene where you want your assets to be loaded
  113913. * @param onSuccess is a callback called when the task is successfully executed
  113914. * @param onError is a callback called if an error occurs
  113915. */
  113916. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  113917. /**
  113918. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  113919. * This can be used with failed tasks that have the reason for failure fixed.
  113920. */
  113921. reset(): void;
  113922. private onErrorCallback;
  113923. private onDoneCallback;
  113924. }
  113925. /**
  113926. * Define the interface used by progress events raised during assets loading
  113927. */
  113928. export interface IAssetsProgressEvent {
  113929. /**
  113930. * Defines the number of remaining tasks to process
  113931. */
  113932. remainingCount: number;
  113933. /**
  113934. * Defines the total number of tasks
  113935. */
  113936. totalCount: number;
  113937. /**
  113938. * Defines the task that was just processed
  113939. */
  113940. task: AbstractAssetTask;
  113941. }
  113942. /**
  113943. * Class used to share progress information about assets loading
  113944. */
  113945. export class AssetsProgressEvent implements IAssetsProgressEvent {
  113946. /**
  113947. * Defines the number of remaining tasks to process
  113948. */
  113949. remainingCount: number;
  113950. /**
  113951. * Defines the total number of tasks
  113952. */
  113953. totalCount: number;
  113954. /**
  113955. * Defines the task that was just processed
  113956. */
  113957. task: AbstractAssetTask;
  113958. /**
  113959. * Creates a AssetsProgressEvent
  113960. * @param remainingCount defines the number of remaining tasks to process
  113961. * @param totalCount defines the total number of tasks
  113962. * @param task defines the task that was just processed
  113963. */
  113964. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  113965. }
  113966. /**
  113967. * Define a task used by AssetsManager to load meshes
  113968. */
  113969. export class MeshAssetTask extends AbstractAssetTask {
  113970. /**
  113971. * Defines the name of the task
  113972. */
  113973. name: string;
  113974. /**
  113975. * Defines the list of mesh's names you want to load
  113976. */
  113977. meshesNames: any;
  113978. /**
  113979. * Defines the root url to use as a base to load your meshes and associated resources
  113980. */
  113981. rootUrl: string;
  113982. /**
  113983. * Defines the filename of the scene to load from
  113984. */
  113985. sceneFilename: string;
  113986. /**
  113987. * Gets the list of loaded meshes
  113988. */
  113989. loadedMeshes: Array<AbstractMesh>;
  113990. /**
  113991. * Gets the list of loaded particle systems
  113992. */
  113993. loadedParticleSystems: Array<IParticleSystem>;
  113994. /**
  113995. * Gets the list of loaded skeletons
  113996. */
  113997. loadedSkeletons: Array<Skeleton>;
  113998. /**
  113999. * Gets the list of loaded animation groups
  114000. */
  114001. loadedAnimationGroups: Array<AnimationGroup>;
  114002. /**
  114003. * Callback called when the task is successful
  114004. */
  114005. onSuccess: (task: MeshAssetTask) => void;
  114006. /**
  114007. * Callback called when the task is successful
  114008. */
  114009. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  114010. /**
  114011. * Creates a new MeshAssetTask
  114012. * @param name defines the name of the task
  114013. * @param meshesNames defines the list of mesh's names you want to load
  114014. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  114015. * @param sceneFilename defines the filename of the scene to load from
  114016. */
  114017. constructor(
  114018. /**
  114019. * Defines the name of the task
  114020. */
  114021. name: string,
  114022. /**
  114023. * Defines the list of mesh's names you want to load
  114024. */
  114025. meshesNames: any,
  114026. /**
  114027. * Defines the root url to use as a base to load your meshes and associated resources
  114028. */
  114029. rootUrl: string,
  114030. /**
  114031. * Defines the filename of the scene to load from
  114032. */
  114033. sceneFilename: string);
  114034. /**
  114035. * Execute the current task
  114036. * @param scene defines the scene where you want your assets to be loaded
  114037. * @param onSuccess is a callback called when the task is successfully executed
  114038. * @param onError is a callback called if an error occurs
  114039. */
  114040. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114041. }
  114042. /**
  114043. * Define a task used by AssetsManager to load text content
  114044. */
  114045. export class TextFileAssetTask extends AbstractAssetTask {
  114046. /**
  114047. * Defines the name of the task
  114048. */
  114049. name: string;
  114050. /**
  114051. * Defines the location of the file to load
  114052. */
  114053. url: string;
  114054. /**
  114055. * Gets the loaded text string
  114056. */
  114057. text: string;
  114058. /**
  114059. * Callback called when the task is successful
  114060. */
  114061. onSuccess: (task: TextFileAssetTask) => void;
  114062. /**
  114063. * Callback called when the task is successful
  114064. */
  114065. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  114066. /**
  114067. * Creates a new TextFileAssetTask object
  114068. * @param name defines the name of the task
  114069. * @param url defines the location of the file to load
  114070. */
  114071. constructor(
  114072. /**
  114073. * Defines the name of the task
  114074. */
  114075. name: string,
  114076. /**
  114077. * Defines the location of the file to load
  114078. */
  114079. url: string);
  114080. /**
  114081. * Execute the current task
  114082. * @param scene defines the scene where you want your assets to be loaded
  114083. * @param onSuccess is a callback called when the task is successfully executed
  114084. * @param onError is a callback called if an error occurs
  114085. */
  114086. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114087. }
  114088. /**
  114089. * Define a task used by AssetsManager to load binary data
  114090. */
  114091. export class BinaryFileAssetTask extends AbstractAssetTask {
  114092. /**
  114093. * Defines the name of the task
  114094. */
  114095. name: string;
  114096. /**
  114097. * Defines the location of the file to load
  114098. */
  114099. url: string;
  114100. /**
  114101. * Gets the lodaded data (as an array buffer)
  114102. */
  114103. data: ArrayBuffer;
  114104. /**
  114105. * Callback called when the task is successful
  114106. */
  114107. onSuccess: (task: BinaryFileAssetTask) => void;
  114108. /**
  114109. * Callback called when the task is successful
  114110. */
  114111. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  114112. /**
  114113. * Creates a new BinaryFileAssetTask object
  114114. * @param name defines the name of the new task
  114115. * @param url defines the location of the file to load
  114116. */
  114117. constructor(
  114118. /**
  114119. * Defines the name of the task
  114120. */
  114121. name: string,
  114122. /**
  114123. * Defines the location of the file to load
  114124. */
  114125. url: string);
  114126. /**
  114127. * Execute the current task
  114128. * @param scene defines the scene where you want your assets to be loaded
  114129. * @param onSuccess is a callback called when the task is successfully executed
  114130. * @param onError is a callback called if an error occurs
  114131. */
  114132. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114133. }
  114134. /**
  114135. * Define a task used by AssetsManager to load images
  114136. */
  114137. export class ImageAssetTask extends AbstractAssetTask {
  114138. /**
  114139. * Defines the name of the task
  114140. */
  114141. name: string;
  114142. /**
  114143. * Defines the location of the image to load
  114144. */
  114145. url: string;
  114146. /**
  114147. * Gets the loaded images
  114148. */
  114149. image: HTMLImageElement;
  114150. /**
  114151. * Callback called when the task is successful
  114152. */
  114153. onSuccess: (task: ImageAssetTask) => void;
  114154. /**
  114155. * Callback called when the task is successful
  114156. */
  114157. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  114158. /**
  114159. * Creates a new ImageAssetTask
  114160. * @param name defines the name of the task
  114161. * @param url defines the location of the image to load
  114162. */
  114163. constructor(
  114164. /**
  114165. * Defines the name of the task
  114166. */
  114167. name: string,
  114168. /**
  114169. * Defines the location of the image to load
  114170. */
  114171. url: string);
  114172. /**
  114173. * Execute the current task
  114174. * @param scene defines the scene where you want your assets to be loaded
  114175. * @param onSuccess is a callback called when the task is successfully executed
  114176. * @param onError is a callback called if an error occurs
  114177. */
  114178. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114179. }
  114180. /**
  114181. * Defines the interface used by texture loading tasks
  114182. */
  114183. export interface ITextureAssetTask<TEX extends BaseTexture> {
  114184. /**
  114185. * Gets the loaded texture
  114186. */
  114187. texture: TEX;
  114188. }
  114189. /**
  114190. * Define a task used by AssetsManager to load 2D textures
  114191. */
  114192. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  114193. /**
  114194. * Defines the name of the task
  114195. */
  114196. name: string;
  114197. /**
  114198. * Defines the location of the file to load
  114199. */
  114200. url: string;
  114201. /**
  114202. * Defines if mipmap should not be generated (default is false)
  114203. */
  114204. noMipmap?: boolean | undefined;
  114205. /**
  114206. * Defines if texture must be inverted on Y axis (default is false)
  114207. */
  114208. invertY?: boolean | undefined;
  114209. /**
  114210. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114211. */
  114212. samplingMode: number;
  114213. /**
  114214. * Gets the loaded texture
  114215. */
  114216. texture: Texture;
  114217. /**
  114218. * Callback called when the task is successful
  114219. */
  114220. onSuccess: (task: TextureAssetTask) => void;
  114221. /**
  114222. * Callback called when the task is successful
  114223. */
  114224. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  114225. /**
  114226. * Creates a new TextureAssetTask object
  114227. * @param name defines the name of the task
  114228. * @param url defines the location of the file to load
  114229. * @param noMipmap defines if mipmap should not be generated (default is false)
  114230. * @param invertY defines if texture must be inverted on Y axis (default is false)
  114231. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114232. */
  114233. constructor(
  114234. /**
  114235. * Defines the name of the task
  114236. */
  114237. name: string,
  114238. /**
  114239. * Defines the location of the file to load
  114240. */
  114241. url: string,
  114242. /**
  114243. * Defines if mipmap should not be generated (default is false)
  114244. */
  114245. noMipmap?: boolean | undefined,
  114246. /**
  114247. * Defines if texture must be inverted on Y axis (default is false)
  114248. */
  114249. invertY?: boolean | undefined,
  114250. /**
  114251. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114252. */
  114253. samplingMode?: number);
  114254. /**
  114255. * Execute the current task
  114256. * @param scene defines the scene where you want your assets to be loaded
  114257. * @param onSuccess is a callback called when the task is successfully executed
  114258. * @param onError is a callback called if an error occurs
  114259. */
  114260. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114261. }
  114262. /**
  114263. * Define a task used by AssetsManager to load cube textures
  114264. */
  114265. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  114266. /**
  114267. * Defines the name of the task
  114268. */
  114269. name: string;
  114270. /**
  114271. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114272. */
  114273. url: string;
  114274. /**
  114275. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114276. */
  114277. extensions?: string[] | undefined;
  114278. /**
  114279. * Defines if mipmaps should not be generated (default is false)
  114280. */
  114281. noMipmap?: boolean | undefined;
  114282. /**
  114283. * Defines the explicit list of files (undefined by default)
  114284. */
  114285. files?: string[] | undefined;
  114286. /**
  114287. * Gets the loaded texture
  114288. */
  114289. texture: CubeTexture;
  114290. /**
  114291. * Callback called when the task is successful
  114292. */
  114293. onSuccess: (task: CubeTextureAssetTask) => void;
  114294. /**
  114295. * Callback called when the task is successful
  114296. */
  114297. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  114298. /**
  114299. * Creates a new CubeTextureAssetTask
  114300. * @param name defines the name of the task
  114301. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114302. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114303. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114304. * @param files defines the explicit list of files (undefined by default)
  114305. */
  114306. constructor(
  114307. /**
  114308. * Defines the name of the task
  114309. */
  114310. name: string,
  114311. /**
  114312. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114313. */
  114314. url: string,
  114315. /**
  114316. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114317. */
  114318. extensions?: string[] | undefined,
  114319. /**
  114320. * Defines if mipmaps should not be generated (default is false)
  114321. */
  114322. noMipmap?: boolean | undefined,
  114323. /**
  114324. * Defines the explicit list of files (undefined by default)
  114325. */
  114326. files?: string[] | undefined);
  114327. /**
  114328. * Execute the current task
  114329. * @param scene defines the scene where you want your assets to be loaded
  114330. * @param onSuccess is a callback called when the task is successfully executed
  114331. * @param onError is a callback called if an error occurs
  114332. */
  114333. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114334. }
  114335. /**
  114336. * Define a task used by AssetsManager to load HDR cube textures
  114337. */
  114338. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  114339. /**
  114340. * Defines the name of the task
  114341. */
  114342. name: string;
  114343. /**
  114344. * Defines the location of the file to load
  114345. */
  114346. url: string;
  114347. /**
  114348. * Defines the desired size (the more it increases the longer the generation will be)
  114349. */
  114350. size: number;
  114351. /**
  114352. * Defines if mipmaps should not be generated (default is false)
  114353. */
  114354. noMipmap: boolean;
  114355. /**
  114356. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114357. */
  114358. generateHarmonics: boolean;
  114359. /**
  114360. * 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)
  114361. */
  114362. gammaSpace: boolean;
  114363. /**
  114364. * Internal Use Only
  114365. */
  114366. reserved: boolean;
  114367. /**
  114368. * Gets the loaded texture
  114369. */
  114370. texture: HDRCubeTexture;
  114371. /**
  114372. * Callback called when the task is successful
  114373. */
  114374. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  114375. /**
  114376. * Callback called when the task is successful
  114377. */
  114378. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  114379. /**
  114380. * Creates a new HDRCubeTextureAssetTask object
  114381. * @param name defines the name of the task
  114382. * @param url defines the location of the file to load
  114383. * @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.
  114384. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114385. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114386. * @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)
  114387. * @param reserved Internal use only
  114388. */
  114389. constructor(
  114390. /**
  114391. * Defines the name of the task
  114392. */
  114393. name: string,
  114394. /**
  114395. * Defines the location of the file to load
  114396. */
  114397. url: string,
  114398. /**
  114399. * Defines the desired size (the more it increases the longer the generation will be)
  114400. */
  114401. size: number,
  114402. /**
  114403. * Defines if mipmaps should not be generated (default is false)
  114404. */
  114405. noMipmap?: boolean,
  114406. /**
  114407. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114408. */
  114409. generateHarmonics?: boolean,
  114410. /**
  114411. * 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)
  114412. */
  114413. gammaSpace?: boolean,
  114414. /**
  114415. * Internal Use Only
  114416. */
  114417. reserved?: boolean);
  114418. /**
  114419. * Execute the current task
  114420. * @param scene defines the scene where you want your assets to be loaded
  114421. * @param onSuccess is a callback called when the task is successfully executed
  114422. * @param onError is a callback called if an error occurs
  114423. */
  114424. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114425. }
  114426. /**
  114427. * Define a task used by AssetsManager to load Equirectangular cube textures
  114428. */
  114429. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  114430. /**
  114431. * Defines the name of the task
  114432. */
  114433. name: string;
  114434. /**
  114435. * Defines the location of the file to load
  114436. */
  114437. url: string;
  114438. /**
  114439. * Defines the desired size (the more it increases the longer the generation will be)
  114440. */
  114441. size: number;
  114442. /**
  114443. * Defines if mipmaps should not be generated (default is false)
  114444. */
  114445. noMipmap: boolean;
  114446. /**
  114447. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114448. * but the standard material would require them in Gamma space) (default is true)
  114449. */
  114450. gammaSpace: boolean;
  114451. /**
  114452. * Gets the loaded texture
  114453. */
  114454. texture: EquiRectangularCubeTexture;
  114455. /**
  114456. * Callback called when the task is successful
  114457. */
  114458. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  114459. /**
  114460. * Callback called when the task is successful
  114461. */
  114462. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  114463. /**
  114464. * Creates a new EquiRectangularCubeTextureAssetTask object
  114465. * @param name defines the name of the task
  114466. * @param url defines the location of the file to load
  114467. * @param size defines the desired size (the more it increases the longer the generation will be)
  114468. * If the size is omitted this implies you are using a preprocessed cubemap.
  114469. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114470. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  114471. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  114472. * (default is true)
  114473. */
  114474. constructor(
  114475. /**
  114476. * Defines the name of the task
  114477. */
  114478. name: string,
  114479. /**
  114480. * Defines the location of the file to load
  114481. */
  114482. url: string,
  114483. /**
  114484. * Defines the desired size (the more it increases the longer the generation will be)
  114485. */
  114486. size: number,
  114487. /**
  114488. * Defines if mipmaps should not be generated (default is false)
  114489. */
  114490. noMipmap?: boolean,
  114491. /**
  114492. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114493. * but the standard material would require them in Gamma space) (default is true)
  114494. */
  114495. gammaSpace?: boolean);
  114496. /**
  114497. * Execute the current task
  114498. * @param scene defines the scene where you want your assets to be loaded
  114499. * @param onSuccess is a callback called when the task is successfully executed
  114500. * @param onError is a callback called if an error occurs
  114501. */
  114502. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114503. }
  114504. /**
  114505. * This class can be used to easily import assets into a scene
  114506. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  114507. */
  114508. export class AssetsManager {
  114509. private _scene;
  114510. private _isLoading;
  114511. protected _tasks: AbstractAssetTask[];
  114512. protected _waitingTasksCount: number;
  114513. protected _totalTasksCount: number;
  114514. /**
  114515. * Callback called when all tasks are processed
  114516. */
  114517. onFinish: (tasks: AbstractAssetTask[]) => void;
  114518. /**
  114519. * Callback called when a task is successful
  114520. */
  114521. onTaskSuccess: (task: AbstractAssetTask) => void;
  114522. /**
  114523. * Callback called when a task had an error
  114524. */
  114525. onTaskError: (task: AbstractAssetTask) => void;
  114526. /**
  114527. * Callback called when a task is done (whatever the result is)
  114528. */
  114529. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  114530. /**
  114531. * Observable called when all tasks are processed
  114532. */
  114533. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  114534. /**
  114535. * Observable called when a task had an error
  114536. */
  114537. onTaskErrorObservable: Observable<AbstractAssetTask>;
  114538. /**
  114539. * Observable called when all tasks were executed
  114540. */
  114541. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  114542. /**
  114543. * Observable called when a task is done (whatever the result is)
  114544. */
  114545. onProgressObservable: Observable<IAssetsProgressEvent>;
  114546. /**
  114547. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  114548. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114549. */
  114550. useDefaultLoadingScreen: boolean;
  114551. /**
  114552. * Creates a new AssetsManager
  114553. * @param scene defines the scene to work on
  114554. */
  114555. constructor(scene: Scene);
  114556. /**
  114557. * Add a MeshAssetTask to the list of active tasks
  114558. * @param taskName defines the name of the new task
  114559. * @param meshesNames defines the name of meshes to load
  114560. * @param rootUrl defines the root url to use to locate files
  114561. * @param sceneFilename defines the filename of the scene file
  114562. * @returns a new MeshAssetTask object
  114563. */
  114564. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  114565. /**
  114566. * Add a TextFileAssetTask to the list of active tasks
  114567. * @param taskName defines the name of the new task
  114568. * @param url defines the url of the file to load
  114569. * @returns a new TextFileAssetTask object
  114570. */
  114571. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  114572. /**
  114573. * Add a BinaryFileAssetTask to the list of active tasks
  114574. * @param taskName defines the name of the new task
  114575. * @param url defines the url of the file to load
  114576. * @returns a new BinaryFileAssetTask object
  114577. */
  114578. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  114579. /**
  114580. * Add a ImageAssetTask to the list of active tasks
  114581. * @param taskName defines the name of the new task
  114582. * @param url defines the url of the file to load
  114583. * @returns a new ImageAssetTask object
  114584. */
  114585. addImageTask(taskName: string, url: string): ImageAssetTask;
  114586. /**
  114587. * Add a TextureAssetTask to the list of active tasks
  114588. * @param taskName defines the name of the new task
  114589. * @param url defines the url of the file to load
  114590. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114591. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  114592. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  114593. * @returns a new TextureAssetTask object
  114594. */
  114595. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  114596. /**
  114597. * Add a CubeTextureAssetTask to the list of active tasks
  114598. * @param taskName defines the name of the new task
  114599. * @param url defines the url of the file to load
  114600. * @param extensions defines the extension to use to load the cube map (can be null)
  114601. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114602. * @param files defines the list of files to load (can be null)
  114603. * @returns a new CubeTextureAssetTask object
  114604. */
  114605. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  114606. /**
  114607. *
  114608. * Add a HDRCubeTextureAssetTask to the list of active tasks
  114609. * @param taskName defines the name of the new task
  114610. * @param url defines the url of the file to load
  114611. * @param size defines the size you want for the cubemap (can be null)
  114612. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114613. * @param generateHarmonics defines if you want to automatically generate (true by default)
  114614. * @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)
  114615. * @param reserved Internal use only
  114616. * @returns a new HDRCubeTextureAssetTask object
  114617. */
  114618. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  114619. /**
  114620. *
  114621. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  114622. * @param taskName defines the name of the new task
  114623. * @param url defines the url of the file to load
  114624. * @param size defines the size you want for the cubemap (can be null)
  114625. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114626. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  114627. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  114628. * @returns a new EquiRectangularCubeTextureAssetTask object
  114629. */
  114630. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  114631. /**
  114632. * Remove a task from the assets manager.
  114633. * @param task the task to remove
  114634. */
  114635. removeTask(task: AbstractAssetTask): void;
  114636. private _decreaseWaitingTasksCount;
  114637. private _runTask;
  114638. /**
  114639. * Reset the AssetsManager and remove all tasks
  114640. * @return the current instance of the AssetsManager
  114641. */
  114642. reset(): AssetsManager;
  114643. /**
  114644. * Start the loading process
  114645. * @return the current instance of the AssetsManager
  114646. */
  114647. load(): AssetsManager;
  114648. /**
  114649. * Start the loading process as an async operation
  114650. * @return a promise returning the list of failed tasks
  114651. */
  114652. loadAsync(): Promise<void>;
  114653. }
  114654. }
  114655. declare module BABYLON {
  114656. /**
  114657. * Wrapper class for promise with external resolve and reject.
  114658. */
  114659. export class Deferred<T> {
  114660. /**
  114661. * The promise associated with this deferred object.
  114662. */
  114663. readonly promise: Promise<T>;
  114664. private _resolve;
  114665. private _reject;
  114666. /**
  114667. * The resolve method of the promise associated with this deferred object.
  114668. */
  114669. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  114670. /**
  114671. * The reject method of the promise associated with this deferred object.
  114672. */
  114673. readonly reject: (reason?: any) => void;
  114674. /**
  114675. * Constructor for this deferred object.
  114676. */
  114677. constructor();
  114678. }
  114679. }
  114680. declare module BABYLON {
  114681. /**
  114682. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  114683. */
  114684. export class MeshExploder {
  114685. private _centerMesh;
  114686. private _meshes;
  114687. private _meshesOrigins;
  114688. private _toCenterVectors;
  114689. private _scaledDirection;
  114690. private _newPosition;
  114691. private _centerPosition;
  114692. /**
  114693. * Explodes meshes from a center mesh.
  114694. * @param meshes The meshes to explode.
  114695. * @param centerMesh The mesh to be center of explosion.
  114696. */
  114697. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  114698. private _setCenterMesh;
  114699. /**
  114700. * Get class name
  114701. * @returns "MeshExploder"
  114702. */
  114703. getClassName(): string;
  114704. /**
  114705. * "Exploded meshes"
  114706. * @returns Array of meshes with the centerMesh at index 0.
  114707. */
  114708. getMeshes(): Array<Mesh>;
  114709. /**
  114710. * Explodes meshes giving a specific direction
  114711. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  114712. */
  114713. explode(direction?: number): void;
  114714. }
  114715. }
  114716. declare module BABYLON {
  114717. /**
  114718. * Class used to help managing file picking and drag'n'drop
  114719. */
  114720. export class FilesInput {
  114721. /**
  114722. * List of files ready to be loaded
  114723. */
  114724. static readonly FilesToLoad: {
  114725. [key: string]: File;
  114726. };
  114727. /**
  114728. * Callback called when a file is processed
  114729. */
  114730. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  114731. private _engine;
  114732. private _currentScene;
  114733. private _sceneLoadedCallback;
  114734. private _progressCallback;
  114735. private _additionalRenderLoopLogicCallback;
  114736. private _textureLoadingCallback;
  114737. private _startingProcessingFilesCallback;
  114738. private _onReloadCallback;
  114739. private _errorCallback;
  114740. private _elementToMonitor;
  114741. private _sceneFileToLoad;
  114742. private _filesToLoad;
  114743. /**
  114744. * Creates a new FilesInput
  114745. * @param engine defines the rendering engine
  114746. * @param scene defines the hosting scene
  114747. * @param sceneLoadedCallback callback called when scene is loaded
  114748. * @param progressCallback callback called to track progress
  114749. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  114750. * @param textureLoadingCallback callback called when a texture is loading
  114751. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  114752. * @param onReloadCallback callback called when a reload is requested
  114753. * @param errorCallback callback call if an error occurs
  114754. */
  114755. 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);
  114756. private _dragEnterHandler;
  114757. private _dragOverHandler;
  114758. private _dropHandler;
  114759. /**
  114760. * Calls this function to listen to drag'n'drop events on a specific DOM element
  114761. * @param elementToMonitor defines the DOM element to track
  114762. */
  114763. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  114764. /**
  114765. * Release all associated resources
  114766. */
  114767. dispose(): void;
  114768. private renderFunction;
  114769. private drag;
  114770. private drop;
  114771. private _traverseFolder;
  114772. private _processFiles;
  114773. /**
  114774. * Load files from a drop event
  114775. * @param event defines the drop event to use as source
  114776. */
  114777. loadFiles(event: any): void;
  114778. private _processReload;
  114779. /**
  114780. * Reload the current scene from the loaded files
  114781. */
  114782. reload(): void;
  114783. }
  114784. }
  114785. declare module BABYLON {
  114786. /**
  114787. * Defines the root class used to create scene optimization to use with SceneOptimizer
  114788. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114789. */
  114790. export class SceneOptimization {
  114791. /**
  114792. * Defines the priority of this optimization (0 by default which means first in the list)
  114793. */
  114794. priority: number;
  114795. /**
  114796. * Gets a string describing the action executed by the current optimization
  114797. * @returns description string
  114798. */
  114799. getDescription(): string;
  114800. /**
  114801. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114802. * @param scene defines the current scene where to apply this optimization
  114803. * @param optimizer defines the current optimizer
  114804. * @returns true if everything that can be done was applied
  114805. */
  114806. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114807. /**
  114808. * Creates the SceneOptimization object
  114809. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114810. * @param desc defines the description associated with the optimization
  114811. */
  114812. constructor(
  114813. /**
  114814. * Defines the priority of this optimization (0 by default which means first in the list)
  114815. */
  114816. priority?: number);
  114817. }
  114818. /**
  114819. * Defines an optimization used to reduce the size of render target textures
  114820. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114821. */
  114822. export class TextureOptimization extends SceneOptimization {
  114823. /**
  114824. * Defines the priority of this optimization (0 by default which means first in the list)
  114825. */
  114826. priority: number;
  114827. /**
  114828. * 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
  114829. */
  114830. maximumSize: number;
  114831. /**
  114832. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114833. */
  114834. step: number;
  114835. /**
  114836. * Gets a string describing the action executed by the current optimization
  114837. * @returns description string
  114838. */
  114839. getDescription(): string;
  114840. /**
  114841. * Creates the TextureOptimization object
  114842. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114843. * @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
  114844. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114845. */
  114846. constructor(
  114847. /**
  114848. * Defines the priority of this optimization (0 by default which means first in the list)
  114849. */
  114850. priority?: number,
  114851. /**
  114852. * 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
  114853. */
  114854. maximumSize?: number,
  114855. /**
  114856. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114857. */
  114858. step?: number);
  114859. /**
  114860. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114861. * @param scene defines the current scene where to apply this optimization
  114862. * @param optimizer defines the current optimizer
  114863. * @returns true if everything that can be done was applied
  114864. */
  114865. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114866. }
  114867. /**
  114868. * Defines an optimization used to increase or decrease the rendering resolution
  114869. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114870. */
  114871. export class HardwareScalingOptimization extends SceneOptimization {
  114872. /**
  114873. * Defines the priority of this optimization (0 by default which means first in the list)
  114874. */
  114875. priority: number;
  114876. /**
  114877. * Defines the maximum scale to use (2 by default)
  114878. */
  114879. maximumScale: number;
  114880. /**
  114881. * Defines the step to use between two passes (0.5 by default)
  114882. */
  114883. step: number;
  114884. private _currentScale;
  114885. private _directionOffset;
  114886. /**
  114887. * Gets a string describing the action executed by the current optimization
  114888. * @return description string
  114889. */
  114890. getDescription(): string;
  114891. /**
  114892. * Creates the HardwareScalingOptimization object
  114893. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114894. * @param maximumScale defines the maximum scale to use (2 by default)
  114895. * @param step defines the step to use between two passes (0.5 by default)
  114896. */
  114897. constructor(
  114898. /**
  114899. * Defines the priority of this optimization (0 by default which means first in the list)
  114900. */
  114901. priority?: number,
  114902. /**
  114903. * Defines the maximum scale to use (2 by default)
  114904. */
  114905. maximumScale?: number,
  114906. /**
  114907. * Defines the step to use between two passes (0.5 by default)
  114908. */
  114909. step?: number);
  114910. /**
  114911. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114912. * @param scene defines the current scene where to apply this optimization
  114913. * @param optimizer defines the current optimizer
  114914. * @returns true if everything that can be done was applied
  114915. */
  114916. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114917. }
  114918. /**
  114919. * Defines an optimization used to remove shadows
  114920. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114921. */
  114922. export class ShadowsOptimization extends SceneOptimization {
  114923. /**
  114924. * Gets a string describing the action executed by the current optimization
  114925. * @return description string
  114926. */
  114927. getDescription(): string;
  114928. /**
  114929. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114930. * @param scene defines the current scene where to apply this optimization
  114931. * @param optimizer defines the current optimizer
  114932. * @returns true if everything that can be done was applied
  114933. */
  114934. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114935. }
  114936. /**
  114937. * Defines an optimization used to turn post-processes off
  114938. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114939. */
  114940. export class PostProcessesOptimization extends SceneOptimization {
  114941. /**
  114942. * Gets a string describing the action executed by the current optimization
  114943. * @return description string
  114944. */
  114945. getDescription(): string;
  114946. /**
  114947. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114948. * @param scene defines the current scene where to apply this optimization
  114949. * @param optimizer defines the current optimizer
  114950. * @returns true if everything that can be done was applied
  114951. */
  114952. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114953. }
  114954. /**
  114955. * Defines an optimization used to turn lens flares off
  114956. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114957. */
  114958. export class LensFlaresOptimization extends SceneOptimization {
  114959. /**
  114960. * Gets a string describing the action executed by the current optimization
  114961. * @return description string
  114962. */
  114963. getDescription(): string;
  114964. /**
  114965. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114966. * @param scene defines the current scene where to apply this optimization
  114967. * @param optimizer defines the current optimizer
  114968. * @returns true if everything that can be done was applied
  114969. */
  114970. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114971. }
  114972. /**
  114973. * Defines an optimization based on user defined callback.
  114974. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114975. */
  114976. export class CustomOptimization extends SceneOptimization {
  114977. /**
  114978. * Callback called to apply the custom optimization.
  114979. */
  114980. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  114981. /**
  114982. * Callback called to get custom description
  114983. */
  114984. onGetDescription: () => string;
  114985. /**
  114986. * Gets a string describing the action executed by the current optimization
  114987. * @returns description string
  114988. */
  114989. getDescription(): string;
  114990. /**
  114991. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114992. * @param scene defines the current scene where to apply this optimization
  114993. * @param optimizer defines the current optimizer
  114994. * @returns true if everything that can be done was applied
  114995. */
  114996. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114997. }
  114998. /**
  114999. * Defines an optimization used to turn particles off
  115000. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115001. */
  115002. export class ParticlesOptimization extends SceneOptimization {
  115003. /**
  115004. * Gets a string describing the action executed by the current optimization
  115005. * @return description string
  115006. */
  115007. getDescription(): string;
  115008. /**
  115009. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115010. * @param scene defines the current scene where to apply this optimization
  115011. * @param optimizer defines the current optimizer
  115012. * @returns true if everything that can be done was applied
  115013. */
  115014. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115015. }
  115016. /**
  115017. * Defines an optimization used to turn render targets off
  115018. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115019. */
  115020. export class RenderTargetsOptimization extends SceneOptimization {
  115021. /**
  115022. * Gets a string describing the action executed by the current optimization
  115023. * @return description string
  115024. */
  115025. getDescription(): string;
  115026. /**
  115027. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115028. * @param scene defines the current scene where to apply this optimization
  115029. * @param optimizer defines the current optimizer
  115030. * @returns true if everything that can be done was applied
  115031. */
  115032. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115033. }
  115034. /**
  115035. * Defines an optimization used to merge meshes with compatible materials
  115036. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115037. */
  115038. export class MergeMeshesOptimization extends SceneOptimization {
  115039. private static _UpdateSelectionTree;
  115040. /**
  115041. * Gets or sets a boolean which defines if optimization octree has to be updated
  115042. */
  115043. /**
  115044. * Gets or sets a boolean which defines if optimization octree has to be updated
  115045. */
  115046. static UpdateSelectionTree: boolean;
  115047. /**
  115048. * Gets a string describing the action executed by the current optimization
  115049. * @return description string
  115050. */
  115051. getDescription(): string;
  115052. private _canBeMerged;
  115053. /**
  115054. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115055. * @param scene defines the current scene where to apply this optimization
  115056. * @param optimizer defines the current optimizer
  115057. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  115058. * @returns true if everything that can be done was applied
  115059. */
  115060. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  115061. }
  115062. /**
  115063. * Defines a list of options used by SceneOptimizer
  115064. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115065. */
  115066. export class SceneOptimizerOptions {
  115067. /**
  115068. * Defines the target frame rate to reach (60 by default)
  115069. */
  115070. targetFrameRate: number;
  115071. /**
  115072. * Defines the interval between two checkes (2000ms by default)
  115073. */
  115074. trackerDuration: number;
  115075. /**
  115076. * Gets the list of optimizations to apply
  115077. */
  115078. optimizations: SceneOptimization[];
  115079. /**
  115080. * Creates a new list of options used by SceneOptimizer
  115081. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  115082. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  115083. */
  115084. constructor(
  115085. /**
  115086. * Defines the target frame rate to reach (60 by default)
  115087. */
  115088. targetFrameRate?: number,
  115089. /**
  115090. * Defines the interval between two checkes (2000ms by default)
  115091. */
  115092. trackerDuration?: number);
  115093. /**
  115094. * Add a new optimization
  115095. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  115096. * @returns the current SceneOptimizerOptions
  115097. */
  115098. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  115099. /**
  115100. * Add a new custom optimization
  115101. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  115102. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  115103. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115104. * @returns the current SceneOptimizerOptions
  115105. */
  115106. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  115107. /**
  115108. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  115109. * @param targetFrameRate defines the target frame rate (60 by default)
  115110. * @returns a SceneOptimizerOptions object
  115111. */
  115112. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115113. /**
  115114. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  115115. * @param targetFrameRate defines the target frame rate (60 by default)
  115116. * @returns a SceneOptimizerOptions object
  115117. */
  115118. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115119. /**
  115120. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  115121. * @param targetFrameRate defines the target frame rate (60 by default)
  115122. * @returns a SceneOptimizerOptions object
  115123. */
  115124. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115125. }
  115126. /**
  115127. * Class used to run optimizations in order to reach a target frame rate
  115128. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115129. */
  115130. export class SceneOptimizer implements IDisposable {
  115131. private _isRunning;
  115132. private _options;
  115133. private _scene;
  115134. private _currentPriorityLevel;
  115135. private _targetFrameRate;
  115136. private _trackerDuration;
  115137. private _currentFrameRate;
  115138. private _sceneDisposeObserver;
  115139. private _improvementMode;
  115140. /**
  115141. * Defines an observable called when the optimizer reaches the target frame rate
  115142. */
  115143. onSuccessObservable: Observable<SceneOptimizer>;
  115144. /**
  115145. * Defines an observable called when the optimizer enables an optimization
  115146. */
  115147. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  115148. /**
  115149. * Defines an observable called when the optimizer is not able to reach the target frame rate
  115150. */
  115151. onFailureObservable: Observable<SceneOptimizer>;
  115152. /**
  115153. * Gets a boolean indicating if the optimizer is in improvement mode
  115154. */
  115155. readonly isInImprovementMode: boolean;
  115156. /**
  115157. * Gets the current priority level (0 at start)
  115158. */
  115159. readonly currentPriorityLevel: number;
  115160. /**
  115161. * Gets the current frame rate checked by the SceneOptimizer
  115162. */
  115163. readonly currentFrameRate: number;
  115164. /**
  115165. * Gets or sets the current target frame rate (60 by default)
  115166. */
  115167. /**
  115168. * Gets or sets the current target frame rate (60 by default)
  115169. */
  115170. targetFrameRate: number;
  115171. /**
  115172. * Gets or sets the current interval between two checks (every 2000ms by default)
  115173. */
  115174. /**
  115175. * Gets or sets the current interval between two checks (every 2000ms by default)
  115176. */
  115177. trackerDuration: number;
  115178. /**
  115179. * Gets the list of active optimizations
  115180. */
  115181. readonly optimizations: SceneOptimization[];
  115182. /**
  115183. * Creates a new SceneOptimizer
  115184. * @param scene defines the scene to work on
  115185. * @param options defines the options to use with the SceneOptimizer
  115186. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  115187. * @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)
  115188. */
  115189. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  115190. /**
  115191. * Stops the current optimizer
  115192. */
  115193. stop(): void;
  115194. /**
  115195. * Reset the optimizer to initial step (current priority level = 0)
  115196. */
  115197. reset(): void;
  115198. /**
  115199. * Start the optimizer. By default it will try to reach a specific framerate
  115200. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  115201. */
  115202. start(): void;
  115203. private _checkCurrentState;
  115204. /**
  115205. * Release all resources
  115206. */
  115207. dispose(): void;
  115208. /**
  115209. * Helper function to create a SceneOptimizer with one single line of code
  115210. * @param scene defines the scene to work on
  115211. * @param options defines the options to use with the SceneOptimizer
  115212. * @param onSuccess defines a callback to call on success
  115213. * @param onFailure defines a callback to call on failure
  115214. * @returns the new SceneOptimizer object
  115215. */
  115216. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  115217. }
  115218. }
  115219. declare module BABYLON {
  115220. /**
  115221. * Class used to serialize a scene into a string
  115222. */
  115223. export class SceneSerializer {
  115224. /**
  115225. * Clear cache used by a previous serialization
  115226. */
  115227. static ClearCache(): void;
  115228. /**
  115229. * Serialize a scene into a JSON compatible object
  115230. * @param scene defines the scene to serialize
  115231. * @returns a JSON compatible object
  115232. */
  115233. static Serialize(scene: Scene): any;
  115234. /**
  115235. * Serialize a mesh into a JSON compatible object
  115236. * @param toSerialize defines the mesh to serialize
  115237. * @param withParents defines if parents must be serialized as well
  115238. * @param withChildren defines if children must be serialized as well
  115239. * @returns a JSON compatible object
  115240. */
  115241. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  115242. }
  115243. }
  115244. declare module BABYLON {
  115245. /**
  115246. * Class used to host texture specific utilities
  115247. */
  115248. export class TextureTools {
  115249. /**
  115250. * Uses the GPU to create a copy texture rescaled at a given size
  115251. * @param texture Texture to copy from
  115252. * @param width defines the desired width
  115253. * @param height defines the desired height
  115254. * @param useBilinearMode defines if bilinear mode has to be used
  115255. * @return the generated texture
  115256. */
  115257. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  115258. }
  115259. }
  115260. declare module BABYLON {
  115261. /**
  115262. * This represents the different options avilable for the video capture.
  115263. */
  115264. export interface VideoRecorderOptions {
  115265. /** Defines the mime type of the video */
  115266. mimeType: string;
  115267. /** Defines the video the video should be recorded at */
  115268. fps: number;
  115269. /** Defines the chunk size for the recording data */
  115270. recordChunckSize: number;
  115271. /** The audio tracks to attach to the record */
  115272. audioTracks?: MediaStreamTrack[];
  115273. }
  115274. /**
  115275. * This can helps recording videos from BabylonJS.
  115276. * This is based on the available WebRTC functionalities of the browser.
  115277. *
  115278. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  115279. */
  115280. export class VideoRecorder {
  115281. private static readonly _defaultOptions;
  115282. /**
  115283. * Returns wehther or not the VideoRecorder is available in your browser.
  115284. * @param engine Defines the Babylon Engine to check the support for
  115285. * @returns true if supported otherwise false
  115286. */
  115287. static IsSupported(engine: Engine): boolean;
  115288. private readonly _options;
  115289. private _canvas;
  115290. private _mediaRecorder;
  115291. private _recordedChunks;
  115292. private _fileName;
  115293. private _resolve;
  115294. private _reject;
  115295. /**
  115296. * True wether a recording is already in progress.
  115297. */
  115298. readonly isRecording: boolean;
  115299. /**
  115300. * Create a new VideoCapture object which can help converting what you see in Babylon to
  115301. * a video file.
  115302. * @param engine Defines the BabylonJS Engine you wish to record
  115303. * @param options Defines options that can be used to customized the capture
  115304. */
  115305. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  115306. /**
  115307. * Stops the current recording before the default capture timeout passed in the startRecording
  115308. * functions.
  115309. */
  115310. stopRecording(): void;
  115311. /**
  115312. * Starts recording the canvas for a max duration specified in parameters.
  115313. * @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.
  115314. * @param maxDuration Defines the maximum recording time in seconds.
  115315. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  115316. * @return a promise callback at the end of the recording with the video data in Blob.
  115317. */
  115318. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  115319. /**
  115320. * Releases internal resources used during the recording.
  115321. */
  115322. dispose(): void;
  115323. private _handleDataAvailable;
  115324. private _handleError;
  115325. private _handleStop;
  115326. }
  115327. }
  115328. declare module BABYLON {
  115329. /**
  115330. * Class containing a set of static utilities functions for screenshots
  115331. */
  115332. export class ScreenshotTools {
  115333. /**
  115334. * Captures a screenshot of the current rendering
  115335. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115336. * @param engine defines the rendering engine
  115337. * @param camera defines the source camera
  115338. * @param size This parameter can be set to a single number or to an object with the
  115339. * following (optional) properties: precision, width, height. If a single number is passed,
  115340. * it will be used for both width and height. If an object is passed, the screenshot size
  115341. * will be derived from the parameters. The precision property is a multiplier allowing
  115342. * rendering at a higher or lower resolution
  115343. * @param successCallback defines the callback receives a single parameter which contains the
  115344. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115345. * src parameter of an <img> to display it
  115346. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115347. * Check your browser for supported MIME types
  115348. */
  115349. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  115350. /**
  115351. * Generates an image screenshot from the specified camera.
  115352. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115353. * @param engine The engine to use for rendering
  115354. * @param camera The camera to use for rendering
  115355. * @param size This parameter can be set to a single number or to an object with the
  115356. * following (optional) properties: precision, width, height. If a single number is passed,
  115357. * it will be used for both width and height. If an object is passed, the screenshot size
  115358. * will be derived from the parameters. The precision property is a multiplier allowing
  115359. * rendering at a higher or lower resolution
  115360. * @param successCallback The callback receives a single parameter which contains the
  115361. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115362. * src parameter of an <img> to display it
  115363. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115364. * Check your browser for supported MIME types
  115365. * @param samples Texture samples (default: 1)
  115366. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115367. * @param fileName A name for for the downloaded file.
  115368. */
  115369. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115370. }
  115371. }
  115372. declare module BABYLON {
  115373. /**
  115374. * A cursor which tracks a point on a path
  115375. */
  115376. export class PathCursor {
  115377. private path;
  115378. /**
  115379. * Stores path cursor callbacks for when an onchange event is triggered
  115380. */
  115381. private _onchange;
  115382. /**
  115383. * The value of the path cursor
  115384. */
  115385. value: number;
  115386. /**
  115387. * The animation array of the path cursor
  115388. */
  115389. animations: Animation[];
  115390. /**
  115391. * Initializes the path cursor
  115392. * @param path The path to track
  115393. */
  115394. constructor(path: Path2);
  115395. /**
  115396. * Gets the cursor point on the path
  115397. * @returns A point on the path cursor at the cursor location
  115398. */
  115399. getPoint(): Vector3;
  115400. /**
  115401. * Moves the cursor ahead by the step amount
  115402. * @param step The amount to move the cursor forward
  115403. * @returns This path cursor
  115404. */
  115405. moveAhead(step?: number): PathCursor;
  115406. /**
  115407. * Moves the cursor behind by the step amount
  115408. * @param step The amount to move the cursor back
  115409. * @returns This path cursor
  115410. */
  115411. moveBack(step?: number): PathCursor;
  115412. /**
  115413. * Moves the cursor by the step amount
  115414. * If the step amount is greater than one, an exception is thrown
  115415. * @param step The amount to move the cursor
  115416. * @returns This path cursor
  115417. */
  115418. move(step: number): PathCursor;
  115419. /**
  115420. * Ensures that the value is limited between zero and one
  115421. * @returns This path cursor
  115422. */
  115423. private ensureLimits;
  115424. /**
  115425. * Runs onchange callbacks on change (used by the animation engine)
  115426. * @returns This path cursor
  115427. */
  115428. private raiseOnChange;
  115429. /**
  115430. * Executes a function on change
  115431. * @param f A path cursor onchange callback
  115432. * @returns This path cursor
  115433. */
  115434. onchange(f: (cursor: PathCursor) => void): PathCursor;
  115435. }
  115436. }
  115437. declare module BABYLON {
  115438. /** @hidden */
  115439. export var blurPixelShader: {
  115440. name: string;
  115441. shader: string;
  115442. };
  115443. }
  115444. declare module BABYLON {
  115445. /** @hidden */
  115446. export var bones300Declaration: {
  115447. name: string;
  115448. shader: string;
  115449. };
  115450. }
  115451. declare module BABYLON {
  115452. /** @hidden */
  115453. export var instances300Declaration: {
  115454. name: string;
  115455. shader: string;
  115456. };
  115457. }
  115458. declare module BABYLON {
  115459. /** @hidden */
  115460. export var pointCloudVertexDeclaration: {
  115461. name: string;
  115462. shader: string;
  115463. };
  115464. }
  115465. // Mixins
  115466. interface Window {
  115467. mozIndexedDB: IDBFactory;
  115468. webkitIndexedDB: IDBFactory;
  115469. msIndexedDB: IDBFactory;
  115470. webkitURL: typeof URL;
  115471. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  115472. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  115473. WebGLRenderingContext: WebGLRenderingContext;
  115474. MSGesture: MSGesture;
  115475. CANNON: any;
  115476. AudioContext: AudioContext;
  115477. webkitAudioContext: AudioContext;
  115478. PointerEvent: any;
  115479. Math: Math;
  115480. Uint8Array: Uint8ArrayConstructor;
  115481. Float32Array: Float32ArrayConstructor;
  115482. mozURL: typeof URL;
  115483. msURL: typeof URL;
  115484. VRFrameData: any; // WebVR, from specs 1.1
  115485. DracoDecoderModule: any;
  115486. setImmediate(handler: (...args: any[]) => void): number;
  115487. }
  115488. interface HTMLCanvasElement {
  115489. requestPointerLock(): void;
  115490. msRequestPointerLock?(): void;
  115491. mozRequestPointerLock?(): void;
  115492. webkitRequestPointerLock?(): void;
  115493. /** Track wether a record is in progress */
  115494. isRecording: boolean;
  115495. /** Capture Stream method defined by some browsers */
  115496. captureStream(fps?: number): MediaStream;
  115497. }
  115498. interface CanvasRenderingContext2D {
  115499. msImageSmoothingEnabled: boolean;
  115500. }
  115501. interface MouseEvent {
  115502. mozMovementX: number;
  115503. mozMovementY: number;
  115504. webkitMovementX: number;
  115505. webkitMovementY: number;
  115506. msMovementX: number;
  115507. msMovementY: number;
  115508. }
  115509. interface Navigator {
  115510. mozGetVRDevices: (any: any) => any;
  115511. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115512. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115513. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115514. webkitGetGamepads(): Gamepad[];
  115515. msGetGamepads(): Gamepad[];
  115516. webkitGamepads(): Gamepad[];
  115517. }
  115518. interface HTMLVideoElement {
  115519. mozSrcObject: any;
  115520. }
  115521. interface Math {
  115522. fround(x: number): number;
  115523. imul(a: number, b: number): number;
  115524. }
  115525. interface WebGLProgram {
  115526. context?: WebGLRenderingContext;
  115527. vertexShader?: WebGLShader;
  115528. fragmentShader?: WebGLShader;
  115529. isParallelCompiled: boolean;
  115530. onCompiled?: () => void;
  115531. }
  115532. interface WebGLRenderingContext {
  115533. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  115534. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  115535. vertexAttribDivisor(index: number, divisor: number): void;
  115536. createVertexArray(): any;
  115537. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  115538. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  115539. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  115540. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  115541. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  115542. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  115543. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  115544. // Queries
  115545. createQuery(): WebGLQuery;
  115546. deleteQuery(query: WebGLQuery): void;
  115547. beginQuery(target: number, query: WebGLQuery): void;
  115548. endQuery(target: number): void;
  115549. getQueryParameter(query: WebGLQuery, pname: number): any;
  115550. getQuery(target: number, pname: number): any;
  115551. MAX_SAMPLES: number;
  115552. RGBA8: number;
  115553. READ_FRAMEBUFFER: number;
  115554. DRAW_FRAMEBUFFER: number;
  115555. UNIFORM_BUFFER: number;
  115556. HALF_FLOAT_OES: number;
  115557. RGBA16F: number;
  115558. RGBA32F: number;
  115559. R32F: number;
  115560. RG32F: number;
  115561. RGB32F: number;
  115562. R16F: number;
  115563. RG16F: number;
  115564. RGB16F: number;
  115565. RED: number;
  115566. RG: number;
  115567. R8: number;
  115568. RG8: number;
  115569. UNSIGNED_INT_24_8: number;
  115570. DEPTH24_STENCIL8: number;
  115571. /* Multiple Render Targets */
  115572. drawBuffers(buffers: number[]): void;
  115573. readBuffer(src: number): void;
  115574. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  115575. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  115576. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  115577. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  115578. // Occlusion Query
  115579. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  115580. ANY_SAMPLES_PASSED: number;
  115581. QUERY_RESULT_AVAILABLE: number;
  115582. QUERY_RESULT: number;
  115583. }
  115584. interface WebGLBuffer {
  115585. references: number;
  115586. capacity: number;
  115587. is32Bits: boolean;
  115588. }
  115589. interface WebGLProgram {
  115590. transformFeedback?: WebGLTransformFeedback | null;
  115591. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  115592. }
  115593. interface EXT_disjoint_timer_query {
  115594. QUERY_COUNTER_BITS_EXT: number;
  115595. TIME_ELAPSED_EXT: number;
  115596. TIMESTAMP_EXT: number;
  115597. GPU_DISJOINT_EXT: number;
  115598. QUERY_RESULT_EXT: number;
  115599. QUERY_RESULT_AVAILABLE_EXT: number;
  115600. queryCounterEXT(query: WebGLQuery, target: number): void;
  115601. createQueryEXT(): WebGLQuery;
  115602. beginQueryEXT(target: number, query: WebGLQuery): void;
  115603. endQueryEXT(target: number): void;
  115604. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  115605. deleteQueryEXT(query: WebGLQuery): void;
  115606. }
  115607. interface WebGLUniformLocation {
  115608. _currentState: any;
  115609. }
  115610. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  115611. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  115612. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  115613. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115614. interface WebGLRenderingContext {
  115615. readonly RASTERIZER_DISCARD: number;
  115616. readonly DEPTH_COMPONENT24: number;
  115617. readonly TEXTURE_3D: number;
  115618. readonly TEXTURE_2D_ARRAY: number;
  115619. readonly TEXTURE_COMPARE_FUNC: number;
  115620. readonly TEXTURE_COMPARE_MODE: number;
  115621. readonly COMPARE_REF_TO_TEXTURE: number;
  115622. readonly TEXTURE_WRAP_R: number;
  115623. readonly HALF_FLOAT: number;
  115624. readonly RGB8: number;
  115625. readonly RED_INTEGER: number;
  115626. readonly RG_INTEGER: number;
  115627. readonly RGB_INTEGER: number;
  115628. readonly RGBA_INTEGER: number;
  115629. readonly R8_SNORM: number;
  115630. readonly RG8_SNORM: number;
  115631. readonly RGB8_SNORM: number;
  115632. readonly RGBA8_SNORM: number;
  115633. readonly R8I: number;
  115634. readonly RG8I: number;
  115635. readonly RGB8I: number;
  115636. readonly RGBA8I: number;
  115637. readonly R8UI: number;
  115638. readonly RG8UI: number;
  115639. readonly RGB8UI: number;
  115640. readonly RGBA8UI: number;
  115641. readonly R16I: number;
  115642. readonly RG16I: number;
  115643. readonly RGB16I: number;
  115644. readonly RGBA16I: number;
  115645. readonly R16UI: number;
  115646. readonly RG16UI: number;
  115647. readonly RGB16UI: number;
  115648. readonly RGBA16UI: number;
  115649. readonly R32I: number;
  115650. readonly RG32I: number;
  115651. readonly RGB32I: number;
  115652. readonly RGBA32I: number;
  115653. readonly R32UI: number;
  115654. readonly RG32UI: number;
  115655. readonly RGB32UI: number;
  115656. readonly RGBA32UI: number;
  115657. readonly RGB10_A2UI: number;
  115658. readonly R11F_G11F_B10F: number;
  115659. readonly RGB9_E5: number;
  115660. readonly RGB10_A2: number;
  115661. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  115662. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  115663. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  115664. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  115665. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  115666. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  115667. 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;
  115668. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  115669. readonly TRANSFORM_FEEDBACK: number;
  115670. readonly INTERLEAVED_ATTRIBS: number;
  115671. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  115672. createTransformFeedback(): WebGLTransformFeedback;
  115673. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  115674. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  115675. beginTransformFeedback(primitiveMode: number): void;
  115676. endTransformFeedback(): void;
  115677. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  115678. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115679. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115680. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115681. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  115682. }
  115683. interface ImageBitmap {
  115684. readonly width: number;
  115685. readonly height: number;
  115686. close(): void;
  115687. }
  115688. interface WebGLQuery extends WebGLObject {
  115689. }
  115690. declare var WebGLQuery: {
  115691. prototype: WebGLQuery;
  115692. new(): WebGLQuery;
  115693. };
  115694. interface WebGLSampler extends WebGLObject {
  115695. }
  115696. declare var WebGLSampler: {
  115697. prototype: WebGLSampler;
  115698. new(): WebGLSampler;
  115699. };
  115700. interface WebGLSync extends WebGLObject {
  115701. }
  115702. declare var WebGLSync: {
  115703. prototype: WebGLSync;
  115704. new(): WebGLSync;
  115705. };
  115706. interface WebGLTransformFeedback extends WebGLObject {
  115707. }
  115708. declare var WebGLTransformFeedback: {
  115709. prototype: WebGLTransformFeedback;
  115710. new(): WebGLTransformFeedback;
  115711. };
  115712. interface WebGLVertexArrayObject extends WebGLObject {
  115713. }
  115714. declare var WebGLVertexArrayObject: {
  115715. prototype: WebGLVertexArrayObject;
  115716. new(): WebGLVertexArrayObject;
  115717. };
  115718. // Type definitions for WebVR API
  115719. // Project: https://w3c.github.io/webvr/
  115720. // Definitions by: six a <https://github.com/lostfictions>
  115721. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115722. interface VRDisplay extends EventTarget {
  115723. /**
  115724. * Dictionary of capabilities describing the VRDisplay.
  115725. */
  115726. readonly capabilities: VRDisplayCapabilities;
  115727. /**
  115728. * z-depth defining the far plane of the eye view frustum
  115729. * enables mapping of values in the render target depth
  115730. * attachment to scene coordinates. Initially set to 10000.0.
  115731. */
  115732. depthFar: number;
  115733. /**
  115734. * z-depth defining the near plane of the eye view frustum
  115735. * enables mapping of values in the render target depth
  115736. * attachment to scene coordinates. Initially set to 0.01.
  115737. */
  115738. depthNear: number;
  115739. /**
  115740. * An identifier for this distinct VRDisplay. Used as an
  115741. * association point in the Gamepad API.
  115742. */
  115743. readonly displayId: number;
  115744. /**
  115745. * A display name, a user-readable name identifying it.
  115746. */
  115747. readonly displayName: string;
  115748. readonly isConnected: boolean;
  115749. readonly isPresenting: boolean;
  115750. /**
  115751. * If this VRDisplay supports room-scale experiences, the optional
  115752. * stage attribute contains details on the room-scale parameters.
  115753. */
  115754. readonly stageParameters: VRStageParameters | null;
  115755. /**
  115756. * Passing the value returned by `requestAnimationFrame` to
  115757. * `cancelAnimationFrame` will unregister the callback.
  115758. * @param handle Define the hanle of the request to cancel
  115759. */
  115760. cancelAnimationFrame(handle: number): void;
  115761. /**
  115762. * Stops presenting to the VRDisplay.
  115763. * @returns a promise to know when it stopped
  115764. */
  115765. exitPresent(): Promise<void>;
  115766. /**
  115767. * Return the current VREyeParameters for the given eye.
  115768. * @param whichEye Define the eye we want the parameter for
  115769. * @returns the eye parameters
  115770. */
  115771. getEyeParameters(whichEye: string): VREyeParameters;
  115772. /**
  115773. * Populates the passed VRFrameData with the information required to render
  115774. * the current frame.
  115775. * @param frameData Define the data structure to populate
  115776. * @returns true if ok otherwise false
  115777. */
  115778. getFrameData(frameData: VRFrameData): boolean;
  115779. /**
  115780. * Get the layers currently being presented.
  115781. * @returns the list of VR layers
  115782. */
  115783. getLayers(): VRLayer[];
  115784. /**
  115785. * Return a VRPose containing the future predicted pose of the VRDisplay
  115786. * when the current frame will be presented. The value returned will not
  115787. * change until JavaScript has returned control to the browser.
  115788. *
  115789. * The VRPose will contain the position, orientation, velocity,
  115790. * and acceleration of each of these properties.
  115791. * @returns the pose object
  115792. */
  115793. getPose(): VRPose;
  115794. /**
  115795. * Return the current instantaneous pose of the VRDisplay, with no
  115796. * prediction applied.
  115797. * @returns the current instantaneous pose
  115798. */
  115799. getImmediatePose(): VRPose;
  115800. /**
  115801. * The callback passed to `requestAnimationFrame` will be called
  115802. * any time a new frame should be rendered. When the VRDisplay is
  115803. * presenting the callback will be called at the native refresh
  115804. * rate of the HMD. When not presenting this function acts
  115805. * identically to how window.requestAnimationFrame acts. Content should
  115806. * make no assumptions of frame rate or vsync behavior as the HMD runs
  115807. * asynchronously from other displays and at differing refresh rates.
  115808. * @param callback Define the eaction to run next frame
  115809. * @returns the request handle it
  115810. */
  115811. requestAnimationFrame(callback: FrameRequestCallback): number;
  115812. /**
  115813. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  115814. * Repeat calls while already presenting will update the VRLayers being displayed.
  115815. * @param layers Define the list of layer to present
  115816. * @returns a promise to know when the request has been fulfilled
  115817. */
  115818. requestPresent(layers: VRLayer[]): Promise<void>;
  115819. /**
  115820. * Reset the pose for this display, treating its current position and
  115821. * orientation as the "origin/zero" values. VRPose.position,
  115822. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  115823. * updated when calling resetPose(). This should be called in only
  115824. * sitting-space experiences.
  115825. */
  115826. resetPose(): void;
  115827. /**
  115828. * The VRLayer provided to the VRDisplay will be captured and presented
  115829. * in the HMD. Calling this function has the same effect on the source
  115830. * canvas as any other operation that uses its source image, and canvases
  115831. * created without preserveDrawingBuffer set to true will be cleared.
  115832. * @param pose Define the pose to submit
  115833. */
  115834. submitFrame(pose?: VRPose): void;
  115835. }
  115836. declare var VRDisplay: {
  115837. prototype: VRDisplay;
  115838. new(): VRDisplay;
  115839. };
  115840. interface VRLayer {
  115841. leftBounds?: number[] | Float32Array | null;
  115842. rightBounds?: number[] | Float32Array | null;
  115843. source?: HTMLCanvasElement | null;
  115844. }
  115845. interface VRDisplayCapabilities {
  115846. readonly canPresent: boolean;
  115847. readonly hasExternalDisplay: boolean;
  115848. readonly hasOrientation: boolean;
  115849. readonly hasPosition: boolean;
  115850. readonly maxLayers: number;
  115851. }
  115852. interface VREyeParameters {
  115853. /** @deprecated */
  115854. readonly fieldOfView: VRFieldOfView;
  115855. readonly offset: Float32Array;
  115856. readonly renderHeight: number;
  115857. readonly renderWidth: number;
  115858. }
  115859. interface VRFieldOfView {
  115860. readonly downDegrees: number;
  115861. readonly leftDegrees: number;
  115862. readonly rightDegrees: number;
  115863. readonly upDegrees: number;
  115864. }
  115865. interface VRFrameData {
  115866. readonly leftProjectionMatrix: Float32Array;
  115867. readonly leftViewMatrix: Float32Array;
  115868. readonly pose: VRPose;
  115869. readonly rightProjectionMatrix: Float32Array;
  115870. readonly rightViewMatrix: Float32Array;
  115871. readonly timestamp: number;
  115872. }
  115873. interface VRPose {
  115874. readonly angularAcceleration: Float32Array | null;
  115875. readonly angularVelocity: Float32Array | null;
  115876. readonly linearAcceleration: Float32Array | null;
  115877. readonly linearVelocity: Float32Array | null;
  115878. readonly orientation: Float32Array | null;
  115879. readonly position: Float32Array | null;
  115880. readonly timestamp: number;
  115881. }
  115882. interface VRStageParameters {
  115883. sittingToStandingTransform?: Float32Array;
  115884. sizeX?: number;
  115885. sizeY?: number;
  115886. }
  115887. interface Navigator {
  115888. getVRDisplays(): Promise<VRDisplay[]>;
  115889. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  115890. }
  115891. interface Window {
  115892. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  115893. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  115894. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  115895. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  115896. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  115897. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  115898. }
  115899. interface Gamepad {
  115900. readonly displayId: number;
  115901. }
  115902. interface XRDevice {
  115903. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  115904. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  115905. }
  115906. interface XRSession {
  115907. getInputSources(): Array<any>;
  115908. baseLayer: XRWebGLLayer;
  115909. requestFrameOfReference(type: string): Promise<void>;
  115910. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  115911. end(): Promise<void>;
  115912. requestAnimationFrame: Function;
  115913. addEventListener: Function;
  115914. }
  115915. interface XRSessionCreationOptions {
  115916. outputContext?: WebGLRenderingContext | null;
  115917. immersive?: boolean;
  115918. environmentIntegration?: boolean;
  115919. }
  115920. interface XRLayer {
  115921. getViewport: Function;
  115922. framebufferWidth: number;
  115923. framebufferHeight: number;
  115924. }
  115925. interface XRView {
  115926. projectionMatrix: Float32Array;
  115927. }
  115928. interface XRFrame {
  115929. getDevicePose: Function;
  115930. getInputPose: Function;
  115931. views: Array<XRView>;
  115932. baseLayer: XRLayer;
  115933. }
  115934. interface XRFrameOfReference {
  115935. }
  115936. interface XRWebGLLayer extends XRLayer {
  115937. framebuffer: WebGLFramebuffer;
  115938. }
  115939. declare var XRWebGLLayer: {
  115940. prototype: XRWebGLLayer;
  115941. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  115942. };